Skip to content

Commit cc418dc

Browse files
build: fix multiplatform publication
1 parent db8eb81 commit cc418dc

4 files changed

Lines changed: 63 additions & 51 deletions

File tree

build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
2-
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
1+
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsEnvSpec
2+
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsPlugin
33

44
plugins {
55
alias(libs.plugins.kotlin.mpp) apply false
@@ -25,8 +25,8 @@ subprojects {
2525
}
2626
}
2727

28-
plugins.withType<NodeJsRootPlugin> {
29-
the<NodeJsRootExtension>().download = false
28+
plugins.withType<NodeJsPlugin> {
29+
the<NodeJsEnvSpec>().download = false
3030
}
3131

3232
tasks.dokkaHtmlMultiModule {

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[versions]
22
kotlin-stdlib = "2.1.0"
33
kotlin-serialization = "1.7.3"
4-
android-gradle = {strictly = "8.5.2"}
4+
android-gradle = {strictly = "8.7.3"}
55
dokka = "1.9.20"
66

77
[libraries]

kbigint-serialization/build.gradle.kts

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,17 @@ kotlin {
4848
compilerOptions.target.set("es2015")
4949
}
5050

51-
when {
52-
os.isLinux -> {
53-
linuxX64()
54-
linuxArm64()
55-
}
56-
os.isWindows -> {
57-
mingwX64()
58-
}
59-
os.isMacOsX -> {
60-
macosX64()
61-
macosArm64()
62-
iosArm64()
63-
iosSimulatorArm64()
64-
}
65-
else -> {
66-
val arch = System.getProperty("os.arch")
67-
throw GradleException("Unsupported platform: $os ($arch)")
68-
}
69-
}
51+
linuxX64 {}
52+
linuxArm64 {}
53+
54+
mingwX64 {}
55+
56+
macosX64 {}
57+
macosArm64 {}
58+
iosArm64 {}
59+
iosSimulatorArm64 {}
60+
61+
applyDefaultHierarchyTemplate()
7062

7163
jvmToolchain(17)
7264

@@ -101,7 +93,7 @@ kotlin {
10193

10294
android {
10395
namespace = "$group.serialization"
104-
compileSdk = 34
96+
compileSdk = 35
10597
defaultConfig {
10698
minSdk = 21
10799
}
@@ -120,7 +112,7 @@ tasks.dokkaHtmlPartial {
120112
pluginsMapConfiguration.set(
121113
mapOf(
122114
"org.jetbrains.dokka.base.DokkaBase" to
123-
"""{"footerMessage": "(c) 2024 ObserverOfTime"}"""
115+
"""{"footerMessage": "(c) 2025 ObserverOfTime"}"""
124116
)
125117
)
126118
dokkaSourceSets.configureEach {

kbigint/build.gradle.kts

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
import java.io.ByteArrayOutputStream
22
import org.gradle.internal.os.OperatingSystem
33
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
4+
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
45
import org.jetbrains.kotlin.gradle.tasks.CInteropProcess
56

67
val os: OperatingSystem = OperatingSystem.current()
78
val libsDir = layout.buildDirectory.get().dir("tmp").dir("libs")
89
val libtommathDir = projectDir.resolve("src/nativeInterop/libtommath")
910

11+
fun KotlinNativeTarget.libtommath() {
12+
compilations.configureEach {
13+
cinterops.create("tommath") {
14+
includeDirs.allHeaders(libtommathDir)
15+
extraOpts("-libraryPath", libsDir.dir(konanTarget.name))
16+
}
17+
}
18+
}
19+
1020
plugins {
1121
`maven-publish`
1222
signing
@@ -50,27 +60,17 @@ kotlin {
5060
compilerOptions.target.set("es2015")
5161
}
5262

53-
when {
54-
os.isLinux -> listOf(linuxX64(), linuxArm64())
55-
os.isWindows -> listOf(mingwX64())
56-
os.isMacOsX -> listOf(
57-
macosArm64(),
58-
macosX64(),
59-
iosArm64(),
60-
iosSimulatorArm64()
61-
)
62-
else -> {
63-
val arch = System.getProperty("os.arch")
64-
throw GradleException("Unsupported platform: $os ($arch)")
65-
}
66-
}.forEach {
67-
it.compilations.configureEach {
68-
cinterops.create("tommath") {
69-
includeDirs.allHeaders(libtommathDir)
70-
extraOpts("-libraryPath", libsDir.dir(konanTarget.name))
71-
}
72-
}
73-
}
63+
linuxX64 { libtommath() }
64+
linuxArm64 { libtommath() }
65+
66+
mingwX64 { libtommath() }
67+
68+
macosArm64 { libtommath() }
69+
macosX64 { libtommath() }
70+
iosArm64 { libtommath() }
71+
iosSimulatorArm64 { libtommath() }
72+
73+
applyDefaultHierarchyTemplate()
7474

7575
jvmToolchain(17)
7676

@@ -106,7 +106,7 @@ kotlin {
106106

107107
android {
108108
namespace = group.toString()
109-
compileSdk = 34
109+
compileSdk = 35
110110
defaultConfig {
111111
minSdk = 21
112112
}
@@ -129,7 +129,6 @@ if (os.isLinux) {
129129

130130
environment["ARFLAGS"] = "rcs"
131131
environment["CFLAGS"] = "-O2 -DMP_NO_FILE -DMP_USE_ENUMS"
132-
environment["CC"] = "gcc"
133132
}
134133

135134
copy {
@@ -151,7 +150,28 @@ if (os.isLinux) {
151150
environment["ARFLAGS"] = "rcs"
152151
environment["CFLAGS"] = "-O2 -DMP_NO_FILE -DMP_USE_ENUMS"
153152
environment["CROSS_COMPILE"] = "aarch64-linux-gnu-"
154-
environment["CC"] = "aarch64-linux-gnu-gcc"
153+
}
154+
155+
copy {
156+
from(libtommathDir.resolve("libtommath.a"))
157+
into(libsDir.dir(konanTarget.name))
158+
}
159+
}
160+
}
161+
162+
tasks.getByName<CInteropProcess>("cinteropTommathMingwX64") {
163+
outputs.file(libsDir.dir(konanTarget.name).file("libtommath.a"))
164+
165+
doFirst {
166+
exec {
167+
executable = "make"
168+
workingDir = libtommathDir
169+
args("clean", "libtommath.a")
170+
171+
environment["ARFLAGS"] = "rcs"
172+
environment["CFLAGS"] = "-O2 -DMP_NO_FILE -DMP_USE_ENUMS" +
173+
" -Wno-expansion-to-defined -Wno-declaration-after-statement -Wno-bad-function-cast"
174+
environment["CROSS_COMPILE"] = "x86_64-w64-mingw32-"
155175
}
156176

157177
copy {
@@ -306,7 +326,7 @@ tasks.dokkaHtmlPartial {
306326
pluginsMapConfiguration.set(
307327
mapOf(
308328
"org.jetbrains.dokka.base.DokkaBase" to
309-
"""{"footerMessage": "(c) 2024 ObserverOfTime"}"""
329+
"""{"footerMessage": "(c) 2025 ObserverOfTime"}"""
310330
)
311331
)
312332
dokkaSourceSets.configureEach {

0 commit comments

Comments
 (0)