diff --git a/skainet-io/skainet-io-core/build.gradle.kts b/skainet-io/skainet-io-core/build.gradle.kts index eefa3860e..13dff0505 100644 --- a/skainet-io/skainet-io-core/build.gradle.kts +++ b/skainet-io/skainet-io-core/build.gradle.kts @@ -39,12 +39,13 @@ kotlin { macosArm64 () linuxX64 () linuxArm64 () - // androidNativeArm64 joins the existing 64-bit native targets in the shared nativeMain - // (PosixPreadRandomAccessSource uses posix pread, whose ssize_t/size_t are Long on all of - // them). androidNativeArm32 is intentionally NOT added here: those posix types are Int on - // 32-bit, and mixing widths in the shared nativeMain metadata is illegal — arm32 needs the - // posix source moved to a 64-bit-only source set (tracked as a follow-up). androidNativeArm64() + // androidNativeArm32 is 32-bit: posix ssize_t/size_t are Int here vs Long on every other + // native target. PosixPreadRandomAccessSource therefore lives in the 64-bit-only `native64Main` + // source set (wired below), NOT in the shared `nativeMain` — otherwise the shared native + // metadata compile fails ("numbers with different bit widths"). arm32 gets the rest of + // io-core (tokenizers etc.); on-device file I/O for arm32 is a separate concern. + androidNativeArm32() js { browser() @@ -60,7 +61,22 @@ kotlin { nodejs() } + // 64-bit-only intermediate source sets: hold the posix `pread` RandomAccessSource, whose + // ssize_t/size_t widths are uniform (Long) across every native target EXCEPT androidNativeArm32. + // Keeping it out of the all-native `nativeMain` avoids the mixed-width metadata compile error. + applyDefaultHierarchyTemplate() + val native64Targets = listOf("iosArm64", "iosSimulatorArm64", "macosArm64", "linuxX64", "linuxArm64", "androidNativeArm64") + sourceSets { + val nativeMain by getting + val nativeTest by getting + val native64Main by creating { dependsOn(nativeMain) } + val native64Test by creating { dependsOn(nativeTest) } + native64Targets.forEach { t -> + getByName("${t}Main").dependsOn(native64Main) + getByName("${t}Test").dependsOn(native64Test) + } + val commonMain by getting { dependencies { implementation(project(":skainet-lang:skainet-lang-core")) diff --git a/skainet-io/skainet-io-core/src/nativeMain/kotlin/sk/ainet/io/PosixPreadRandomAccessSource.kt b/skainet-io/skainet-io-core/src/native64Main/kotlin/sk/ainet/io/PosixPreadRandomAccessSource.kt similarity index 100% rename from skainet-io/skainet-io-core/src/nativeMain/kotlin/sk/ainet/io/PosixPreadRandomAccessSource.kt rename to skainet-io/skainet-io-core/src/native64Main/kotlin/sk/ainet/io/PosixPreadRandomAccessSource.kt diff --git a/skainet-io/skainet-io-core/src/nativeTest/kotlin/sk/ainet/io/PosixPreadRandomAccessSourceTest.kt b/skainet-io/skainet-io-core/src/native64Test/kotlin/sk/ainet/io/PosixPreadRandomAccessSourceTest.kt similarity index 100% rename from skainet-io/skainet-io-core/src/nativeTest/kotlin/sk/ainet/io/PosixPreadRandomAccessSourceTest.kt rename to skainet-io/skainet-io-core/src/native64Test/kotlin/sk/ainet/io/PosixPreadRandomAccessSourceTest.kt