Skip to content

Commit 4963a4f

Browse files
authored
Merge pull request #393 from thisisthepy/feat/compose-kn-desktop-targets
Compose host: add macosArm64 and linuxX64 Kotlin/Native desktop targets (#191 Phase B)
2 parents 2f9267d + f16e5f2 commit 4963a4f

4 files changed

Lines changed: 26 additions & 3 deletions

File tree

‎.github/workflows/desktop.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ jobs:
7676
- name: Run Linux x86_64 Kotlin/Native Tests
7777
run: ./gradlew :python-multiplatform:linuxX64Test --rerun --console=plain
7878

79+
# The Compose host's linuxX64 target (#386): compiled here, since only the fork publishes the
80+
# Compose UI klibs for linuxX64.
81+
- name: Compile the Compose host for Linux x86_64 Kotlin/Native
82+
run: ./gradlew :python-multiplatform-compose:compileKotlinLinuxX64 --rerun --console=plain
83+
7984
# The dev agent's protocol on the other desktop OSes (#238). Its socket options differ per platform
8085
# (SO_EXCLUSIVEADDRUSE on Windows, SO_REUSEADDR on POSIX), and the port-takeover and restart tests are
8186
# what check them. Stdlib only: no JDK, no Gradle.

‎docs/SPEC.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,10 @@ All in `PM/commonTest`, so they run wherever the interpreter loads.
542542
the next frame with no host call; Python callables a root passed into composables are released when
543543
that root is replaced or the composition is disposed. The entry point names no library.
544544
`Status: implemented` on desktop, `python-multiplatform-compose/fixtures/compose/.../PythonAppViewRenderTest.kt`; the module
545-
compiles for Android, nothing runs there yet.
545+
compiles for Android, nothing runs there yet. It also compiles for the Kotlin/Native desktop targets
546+
`macosArm64` and `linuxX64` (#386, `commonMain -> desktopNativeMain -> {macosArm64Main, linuxX64Main}`;
547+
`linuxX64` exists only on the fork, upstream Compose publishes no `ui` klib for it); nothing runs there yet
548+
(#191 Phase B: the klib walker and a K/N app).
546549
- **B-9** A Python root keeps state across the recreation of its composition with
547550
`python.multiplatform.compose.rememberSaveableWrapper(initial)` (the pycomposeui function of that name),
548551
callable from Python inside a composition. A Python `int` (32 bit) becomes `rememberSaveable { mutableIntStateOf }`,

‎gradle.properties‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ kotlin.native.binary.sourceInfoType=libbacktrace
2121
#Compose
2222
org.jetbrains.compose.experimental.jscanvas.enabled=true
2323
org.jetbrains.compose.experimental.uikit.enabled=true
24+
# Compose gates its macosArm64 target behind this flag; :python-multiplatform-compose has it since #386.
25+
org.jetbrains.compose.experimental.macos.enabled=true
2426
# org.thisisthepy.compose:compose-gradle-plugin:1.11.1-ext.3's Maven Central POM marks
2527
# hot-reload-gradle-plugin as optional (shadow configuration), so Gradle does not place it on the
2628
# plugin classpath unless disabled or declared separately.

‎python-multiplatform-compose/build.gradle.kts‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
77
* composable.
88
*
99
* A separate module so that `:python-multiplatform` itself never depends on Compose (same naming as
10-
* `-ksp` and `-gradle-plugin`). JVM targets first -- desktop and Android share the code, which is all
11-
* in `commonMain`; iOS and wasm come later.
10+
* `-ksp` and `-gradle-plugin`). Desktop JVM, Android and Kotlin/Native desktop (macosArm64, linuxX64)
11+
* share the code, which is all in `commonMain`; iOS and wasm come later.
1212
*/
1313
plugins {
1414
alias(libs.plugins.kotlin.multiplatform)
@@ -35,13 +35,26 @@ kotlin {
3535
}
3636
}
3737

38+
// Kotlin/Native desktop (#191 Phase B, #386), the targets `:python-multiplatform` has since #370.
39+
// Upstream JetBrains Compose publishes no `ui` klib for linuxX64; the fork this repository builds
40+
// on publishes `runtime`, `runtime-saveable` and `ui` for both targets.
41+
macosArm64()
42+
linuxX64()
43+
3844
sourceSets {
3945
commonMain.dependencies {
4046
api(projects.pythonMultiplatform)
4147
api(compose.runtime)
4248
api(compose.ui)
4349
api(compose.runtimeSaveable)
4450
}
51+
// Same shape as the library's: commonMain -> desktopNativeMain -> {macosArm64Main, linuxX64Main}.
52+
// Empty today (the host is all commonMain); it is where K/N-desktop-only host code goes.
53+
val desktopNativeMain by creating {
54+
dependsOn(commonMain.get())
55+
}
56+
getByName("macosArm64Main").dependsOn(desktopNativeMain)
57+
getByName("linuxX64Main").dependsOn(desktopNativeMain)
4558
}
4659
}
4760

0 commit comments

Comments
 (0)