Skip to content

Commit d75ce27

Browse files
authored
Merge pull request #77 from touchlab/kpg/andriod_native_targets
Kpg/andriod native targets
2 parents 4be4e28 + fc9f39e commit d75ce27

14 files changed

Lines changed: 2125 additions & 29 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,11 @@ jobs:
1212
build:
1313
strategy:
1414
matrix:
15-
os: [macOS-latest, windows-latest]
15+
os: [macOS-latest]
1616
runs-on: ${{matrix.os}}
1717
steps:
1818
- name: Checkout the repo
1919
uses: actions/checkout@v2
20-
- name: Install msys2
21-
if: matrix.os == 'windows-latest'
22-
uses: msys2/setup-msys2@v2
23-
with:
24-
msystem: MINGW64
25-
update: true
26-
install: git mingw-w64-x86_64-toolchain
2720
- name: Validate Gradle Wrapper
2821
uses: gradle/wrapper-validation-action@v1
2922
- name: Cache gradle
@@ -41,7 +34,7 @@ jobs:
4134
restore-keys: |
4235
${{ runner.os }}-gradle-
4336
- name: Build
44-
run: ./gradlew build --no-daemon --stacktrace
37+
run: ./gradlew build -x jsIrBrowserTest --no-daemon --stacktrace
4538

4639
env:
4740
GRADLE_OPTS: -Dkotlin.incremental=false -Dorg.gradle.jvmargs="-Xmx3g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:MaxMetaspaceSize=512m"

.github/workflows/deploy.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
build:
1313
strategy:
1414
matrix:
15-
os: [macOS-11, ubuntu-latest]
15+
os: [macOS-latest, ubuntu-latest]
1616
runs-on: ${{matrix.os}}
1717
steps:
1818
- name: Checkout the repo
@@ -34,15 +34,15 @@ jobs:
3434
restore-keys: |
3535
${{ runner.os }}-gradle-
3636
- name: Publish Mac/Windows Artifacts
37-
if: matrix.os == 'macOS-11'
38-
run: ./gradlew publish --no-daemon --stacktrace
37+
if: matrix.os == 'macOS-latest'
38+
run: ./gradlew publish -x check --no-daemon --stacktrace
3939
env:
4040
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
4141
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
4242
ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
4343
- name: Publish Linux Artifacts
4444
if: matrix.os == 'ubuntu-latest'
45-
run: ./gradlew publishLinux --no-daemon --stacktrace
45+
run: ./gradlew publishLinux -x check --no-daemon --stacktrace
4646
env:
4747
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
4848
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
kotlin.code.style=official
1818
org.gradle.jvmargs=-Xmx2g
19-
KOTLIN_VERSION=1.6.10
19+
KOTLIN_VERSION=1.6.20
2020
GROUP=co.touchlab
21-
VERSION_NAME=1.2.1
22-
TESTHELP_VERSION=0.6.1
21+
VERSION_NAME=1.2.2
22+
TESTHELP_VERSION=0.6.3
2323
POM_URL=https://github.com/touchlab/Stately
2424
POM_DESCRIPTION=Multithreaded Kotlin Multiplatform Utilities
2525
POM_NAME=Stately

kotlin-js-store/yarn.lock

Lines changed: 1970 additions & 0 deletions
Large diffs are not rendered by default.

stately-collections/build.gradle

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ kotlin {
4949
watchosSimulatorArm64()
5050
tvosSimulatorArm64()
5151

52+
androidNativeArm32()
53+
androidNativeArm64()
54+
androidNativeX86()
55+
androidNativeX64()
56+
5257
sourceSets {
5358
commonMain {
5459
dependencies {
@@ -160,6 +165,22 @@ kotlin {
160165
linuxMips32Main {
161166
dependsOn nativeCommonMain
162167
}
168+
169+
androidNativeArm32Main {
170+
dependsOn nativeCommonMain
171+
}
172+
173+
androidNativeArm64Main {
174+
dependsOn nativeCommonMain
175+
}
176+
177+
androidNativeX86Main {
178+
dependsOn nativeCommonMain
179+
}
180+
181+
androidNativeX64Main {
182+
dependsOn nativeCommonMain
183+
}
163184
}
164185
}
165186

stately-collections/src/nativeCommonMain/kotlin/co/touchlab/stately/collections/SharedCollections.kt

Lines changed: 0 additions & 10 deletions
This file was deleted.

stately-common/build.gradle

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,18 @@ kotlin {
4040
watchosSimulatorArm64()
4141
tvosSimulatorArm64()
4242

43+
4344
mingwX64()
4445
mingwX86()
4546
linuxX64()
4647
linuxArm32Hfp()
4748
linuxMips32()
4849

50+
androidNativeArm32()
51+
androidNativeArm64()
52+
androidNativeX86()
53+
androidNativeX64()
54+
4955
sourceSets {
5056
commonMain {
5157
dependencies {
@@ -155,6 +161,22 @@ kotlin {
155161
linuxMips32Main {
156162
dependsOn nativeCommonMain
157163
}
164+
165+
androidNativeArm32Main {
166+
dependsOn nativeCommonMain
167+
}
168+
169+
androidNativeArm64Main {
170+
dependsOn nativeCommonMain
171+
}
172+
173+
androidNativeX86Main {
174+
dependsOn nativeCommonMain
175+
}
176+
177+
androidNativeX64Main {
178+
dependsOn nativeCommonMain
179+
}
158180
}
159181
}
160182

stately-concurrency/build.gradle

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ kotlin {
5050
linuxArm32Hfp()
5151
linuxMips32()
5252

53+
androidNativeArm32()
54+
androidNativeArm64()
55+
androidNativeX86()
56+
androidNativeX64()
57+
5358
sourceSets {
5459
commonMain {
5560
dependencies {
@@ -107,6 +112,10 @@ kotlin {
107112
dependsOn nativeCommonMain
108113
}
109114

115+
pthreadAndroidMain {
116+
dependsOn nativeCommonMain
117+
}
118+
110119
macosX64Main {
111120
dependsOn darwinMain
112121
}
@@ -171,6 +180,19 @@ kotlin {
171180
linuxMips32Main {
172181
dependsOn pthreadMain
173182
}
183+
184+
androidNativeArm32Main {
185+
dependsOn pthreadAndroidMain
186+
}
187+
androidNativeArm64Main {
188+
dependsOn pthreadAndroidMain
189+
}
190+
androidNativeX86Main {
191+
dependsOn pthreadAndroidMain
192+
}
193+
androidNativeX64Main {
194+
dependsOn pthreadAndroidMain
195+
}
174196
}
175197
}
176198

stately-concurrency/src/mingwX64Main/kotlin/co/touchlab/stately/concurrency/Lock.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ actual class Lock actual constructor() {
5151

5252
actual inline fun Lock.close() {
5353
internalClose()
54-
}
54+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package co.touchlab.stately.concurrency
2+
3+
import kotlinx.cinterop.Arena
4+
import kotlinx.cinterop.alloc
5+
import kotlinx.cinterop.ptr
6+
import platform.posix.PTHREAD_MUTEX_RECURSIVE
7+
import platform.posix.pthread_mutex_destroy
8+
import platform.posix.pthread_mutex_init
9+
import platform.posix.pthread_mutex_lock
10+
import platform.posix.pthread_mutex_t
11+
import platform.posix.pthread_mutex_trylock
12+
import platform.posix.pthread_mutex_unlock
13+
import platform.posix.pthread_mutexattr_destroy
14+
import platform.posix.pthread_mutexattr_init
15+
import platform.posix.pthread_mutexattr_settype
16+
import platform.posix.pthread_mutexattr_tVar
17+
import kotlin.native.concurrent.freeze
18+
19+
/**
20+
* A simple lock.
21+
* Implementations of this class should be re-entrant.
22+
*/
23+
actual class Lock actual constructor() {
24+
private val arena = Arena()
25+
private val attr = arena.alloc<pthread_mutexattr_tVar>()
26+
private val mutex = arena.alloc<pthread_mutex_t>()
27+
28+
init {
29+
pthread_mutexattr_init(attr.ptr)
30+
pthread_mutexattr_settype(attr.ptr, PTHREAD_MUTEX_RECURSIVE.toInt())
31+
pthread_mutex_init(mutex.ptr, attr.ptr)
32+
freeze()
33+
}
34+
35+
actual fun lock() {
36+
pthread_mutex_lock(mutex.ptr)
37+
}
38+
39+
actual fun unlock() {
40+
pthread_mutex_unlock(mutex.ptr)
41+
}
42+
43+
actual fun tryLock(): Boolean = pthread_mutex_trylock(mutex.ptr) == 0
44+
45+
fun internalClose() {
46+
pthread_mutex_destroy(mutex.ptr)
47+
pthread_mutexattr_destroy(attr.ptr)
48+
arena.clear()
49+
}
50+
}
51+
52+
actual inline fun Lock.close() {
53+
internalClose()
54+
}

0 commit comments

Comments
 (0)