Skip to content

Commit

Permalink
Merge pull request #77 from touchlab/kpg/andriod_native_targets
Browse files Browse the repository at this point in the history
Kpg/andriod native targets
  • Loading branch information
kpgalligan committed Apr 16, 2022
2 parents 4be4e28 + fc9f39e commit d75ce27
Show file tree
Hide file tree
Showing 14 changed files with 2,125 additions and 29 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,11 @@ jobs:
build:
strategy:
matrix:
os: [macOS-latest, windows-latest]
os: [macOS-latest]
runs-on: ${{matrix.os}}
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Install msys2
if: matrix.os == 'windows-latest'
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: git mingw-w64-x86_64-toolchain
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Cache gradle
Expand All @@ -41,7 +34,7 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
- name: Build
run: ./gradlew build --no-daemon --stacktrace
run: ./gradlew build -x jsIrBrowserTest --no-daemon --stacktrace

env:
GRADLE_OPTS: -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx3g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:MaxMetaspaceSize=512m"
8 changes: 4 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
build:
strategy:
matrix:
os: [macOS-11, ubuntu-latest]
os: [macOS-latest, ubuntu-latest]
runs-on: ${{matrix.os}}
steps:
- name: Checkout the repo
Expand All @@ -34,15 +34,15 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
- name: Publish Mac/Windows Artifacts
if: matrix.os == 'macOS-11'
run: ./gradlew publish --no-daemon --stacktrace
if: matrix.os == 'macOS-latest'
run: ./gradlew publish -x check --no-daemon --stacktrace
env:
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
- name: Publish Linux Artifacts
if: matrix.os == 'ubuntu-latest'
run: ./gradlew publishLinux --no-daemon --stacktrace
run: ./gradlew publishLinux -x check --no-daemon --stacktrace
env:
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

kotlin.code.style=official
org.gradle.jvmargs=-Xmx2g
KOTLIN_VERSION=1.6.10
KOTLIN_VERSION=1.6.20
GROUP=co.touchlab
VERSION_NAME=1.2.1
TESTHELP_VERSION=0.6.1
VERSION_NAME=1.2.2
TESTHELP_VERSION=0.6.3
POM_URL=https://github.com/touchlab/Stately
POM_DESCRIPTION=Multithreaded Kotlin Multiplatform Utilities
POM_NAME=Stately
Expand Down
1,970 changes: 1,970 additions & 0 deletions kotlin-js-store/yarn.lock

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions stately-collections/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ kotlin {
watchosSimulatorArm64()
tvosSimulatorArm64()

androidNativeArm32()
androidNativeArm64()
androidNativeX86()
androidNativeX64()

sourceSets {
commonMain {
dependencies {
Expand Down Expand Up @@ -160,6 +165,22 @@ kotlin {
linuxMips32Main {
dependsOn nativeCommonMain
}

androidNativeArm32Main {
dependsOn nativeCommonMain
}

androidNativeArm64Main {
dependsOn nativeCommonMain
}

androidNativeX86Main {
dependsOn nativeCommonMain
}

androidNativeX64Main {
dependsOn nativeCommonMain
}
}
}

Expand Down

This file was deleted.

22 changes: 22 additions & 0 deletions stately-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,18 @@ kotlin {
watchosSimulatorArm64()
tvosSimulatorArm64()


mingwX64()
mingwX86()
linuxX64()
linuxArm32Hfp()
linuxMips32()

androidNativeArm32()
androidNativeArm64()
androidNativeX86()
androidNativeX64()

sourceSets {
commonMain {
dependencies {
Expand Down Expand Up @@ -155,6 +161,22 @@ kotlin {
linuxMips32Main {
dependsOn nativeCommonMain
}

androidNativeArm32Main {
dependsOn nativeCommonMain
}

androidNativeArm64Main {
dependsOn nativeCommonMain
}

androidNativeX86Main {
dependsOn nativeCommonMain
}

androidNativeX64Main {
dependsOn nativeCommonMain
}
}
}

Expand Down
22 changes: 22 additions & 0 deletions stately-concurrency/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ kotlin {
linuxArm32Hfp()
linuxMips32()

androidNativeArm32()
androidNativeArm64()
androidNativeX86()
androidNativeX64()

sourceSets {
commonMain {
dependencies {
Expand Down Expand Up @@ -107,6 +112,10 @@ kotlin {
dependsOn nativeCommonMain
}

pthreadAndroidMain {
dependsOn nativeCommonMain
}

macosX64Main {
dependsOn darwinMain
}
Expand Down Expand Up @@ -171,6 +180,19 @@ kotlin {
linuxMips32Main {
dependsOn pthreadMain
}

androidNativeArm32Main {
dependsOn pthreadAndroidMain
}
androidNativeArm64Main {
dependsOn pthreadAndroidMain
}
androidNativeX86Main {
dependsOn pthreadAndroidMain
}
androidNativeX64Main {
dependsOn pthreadAndroidMain
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ actual class Lock actual constructor() {

actual inline fun Lock.close() {
internalClose()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package co.touchlab.stately.concurrency

import kotlinx.cinterop.Arena
import kotlinx.cinterop.alloc
import kotlinx.cinterop.ptr
import platform.posix.PTHREAD_MUTEX_RECURSIVE
import platform.posix.pthread_mutex_destroy
import platform.posix.pthread_mutex_init
import platform.posix.pthread_mutex_lock
import platform.posix.pthread_mutex_t
import platform.posix.pthread_mutex_trylock
import platform.posix.pthread_mutex_unlock
import platform.posix.pthread_mutexattr_destroy
import platform.posix.pthread_mutexattr_init
import platform.posix.pthread_mutexattr_settype
import platform.posix.pthread_mutexattr_tVar
import kotlin.native.concurrent.freeze

/**
* A simple lock.
* Implementations of this class should be re-entrant.
*/
actual class Lock actual constructor() {
private val arena = Arena()
private val attr = arena.alloc<pthread_mutexattr_tVar>()
private val mutex = arena.alloc<pthread_mutex_t>()

init {
pthread_mutexattr_init(attr.ptr)
pthread_mutexattr_settype(attr.ptr, PTHREAD_MUTEX_RECURSIVE.toInt())
pthread_mutex_init(mutex.ptr, attr.ptr)
freeze()
}

actual fun lock() {
pthread_mutex_lock(mutex.ptr)
}

actual fun unlock() {
pthread_mutex_unlock(mutex.ptr)
}

actual fun tryLock(): Boolean = pthread_mutex_trylock(mutex.ptr) == 0

fun internalClose() {
pthread_mutex_destroy(mutex.ptr)
pthread_mutexattr_destroy(attr.ptr)
arena.clear()
}
}

actual inline fun Lock.close() {
internalClose()
}
5 changes: 5 additions & 0 deletions stately-iso-collections/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ kotlin {
linuxArm32Hfp()
linuxMips32()

androidNativeArm32()
androidNativeArm64()
androidNativeX86()
androidNativeX64()

sourceSets {
commonMain {
dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import co.touchlab.stately.isolate.StateHolder
import co.touchlab.stately.isolate.StateRunner
import co.touchlab.stately.isolate.createState

@ExperimentalStdlibApi
open class IsoArrayDeque<E>
internal constructor(stateHolder: StateHolder<ArrayDeque<E>>) :
IsoMutableList<E>(stateHolder) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package co.touchlab.stately.collections

class IsoArrayDequeTest : IsoMutableListTest() {
@UseExperimental(ExperimentalStdlibApi::class)
override fun defaultCollection(): IsoMutableCollection<SomeData> = IsoArrayDeque<SomeData>()
}
21 changes: 21 additions & 0 deletions stately-isolate/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ kotlin {
linuxArm32Hfp()
linuxMips32()

androidNativeArm32()
androidNativeArm64()
androidNativeX86()
androidNativeX64()

sourceSets {
commonMain {
dependencies {
Expand Down Expand Up @@ -157,6 +162,22 @@ kotlin {
linuxMips32Main {
dependsOn nativeCommonMain
}

androidNativeArm32Main {
dependsOn nativeCommonMain
}

androidNativeArm64Main {
dependsOn nativeCommonMain
}

androidNativeX86Main {
dependsOn nativeCommonMain
}

androidNativeX64Main {
dependsOn nativeCommonMain
}
}
}

Expand Down

0 comments on commit d75ce27

Please sign in to comment.