Skip to content

Commit 3b389bb

Browse files
committed
attempt to add all KMP platofrmd
1 parent 8108d15 commit 3b389bb

8 files changed

Lines changed: 134 additions & 26 deletions

File tree

build.gradle.kts

Lines changed: 64 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
//@file:Suppress("UNUSED_VARIABLE")
22

33
plugins {
4-
kotlin("multiplatform") version "1.7.21"
5-
kotlin("plugin.serialization") version "1.7.20"
4+
kotlin("multiplatform") version "1.9.22"
5+
kotlin("plugin.serialization") version "1.9.20"
66
`maven-publish`
77
}
88

99
group = "net.sergeych"
10-
version = "1.4.3"
10+
version = "1.4.5-SNAPSHOT"
1111

12-
val serialization_version = "1.3.3"
12+
val serialization_version = "1.6.3"
1313

1414
repositories {
1515
mavenCentral()
@@ -32,37 +32,75 @@ kotlin {
3232
}
3333
}
3434
}
35-
ios()
36-
val hostOs = System.getProperty("os.name")
37-
val isMingwX64 = hostOs.startsWith("Windows")
38-
val nativeTarget = when {
39-
hostOs == "Mac OS X" -> macosX64("native")
40-
hostOs == "Linux" -> linuxX64("native")
41-
isMingwX64 -> mingwX64("native")
42-
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
35+
36+
wasmJs {
37+
browser()
38+
binaries.executable()
39+
}
40+
41+
// val hostOs = System.getProperty("os.name")
42+
// val isMingwX64 = hostOs.startsWith("Windows")
43+
// val nativeTarget = when {
44+
// hostOs == "Mac OS X" -> macosX64("native")
45+
// hostOs == "Linux" -> linuxX64("native")
46+
// isMingwX64 -> mingwX64("native")
47+
// else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
48+
// }
49+
//
50+
// val publicationsFromMainHost =
51+
// listOf(jvm(), js()).map { it.name } + "kotlinMultiplatform"
52+
linuxX64("native") {
53+
binaries.staticLib {
54+
baseName = "mp_bintools"
55+
}
4356
}
4457

45-
val publicationsFromMainHost =
46-
listOf(jvm(), js()).map { it.name } + "kotlinMultiplatform"
58+
listOf(
59+
iosX64(),
60+
iosArm64(),
61+
iosSimulatorArm64()
62+
).forEach {
63+
it.binaries.framework {
64+
baseName = "mp_bintools"
65+
isStatic = true
66+
}
67+
}
68+
69+
listOf(
70+
macosX64(),
71+
macosArm64()
72+
).forEach {
73+
it.binaries.framework {
74+
baseName = "mp_bintools"
75+
isStatic = true
76+
}
77+
}
78+
79+
80+
mingwX64() {
81+
binaries.staticLib {
82+
baseName = "mp_bintools"
83+
}
84+
}
4785

4886
sourceSets {
4987
all {
5088
// languageSettings.optIn("kotlin.RequiresOptIn")
5189
// languageSettings.optIn("kotlinx.serialization.ExperimentalSerializationApi")
5290
// languageSettings.optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
53-
languageSettings.optIn("kotlin.ExperimentalUnsignedTypes")
91+
languageSettings.optIn("kotlin.ExperimentalUnsignedTypes")
5492
}
5593
val commonMain by getting {
5694
dependencies {
5795
api("org.jetbrains.kotlinx:kotlinx-serialization-json:$serialization_version")
58-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.3")
59-
api("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0")
96+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0")
97+
api("org.jetbrains.kotlinx:kotlinx-datetime:0.5.0")
6098
}
6199
}
62100
val commonTest by getting {
63101
dependencies {
64102
implementation(kotlin("test"))
65-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.1")
103+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.8.0")
66104
}
67105
}
68106
val jvmMain by getting
@@ -71,17 +109,19 @@ kotlin {
71109
val jsTest by getting
72110
val nativeMain by getting
73111
val nativeTest by getting
112+
val wasmJsMain by getting
113+
val wasmJsTest by getting
74114
}
75115

76116
publishing {
77117
publications {
78118

79-
matching { it.name in publicationsFromMainHost }.all {
80-
val targetPublication = this@all
81-
tasks.withType<AbstractPublishToMaven>()
82-
.matching { it.publication == targetPublication }
83-
.configureEach { onlyIf { findProperty("isMainHost") == "true" } }
84-
}
119+
// matching { it.name in publicationsFromMainHost }.all {
120+
// val targetPublication = this@all
121+
// tasks.withType<AbstractPublishToMaven>()
122+
// .matching { it.publication == targetPublication }
123+
// .configureEach { onlyIf { findProperty("isMainHost") == "true" } }
124+
// }
85125

86126
// create<MavenPublication>("maven") {
87127
// from(components["java"])

gradle.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
kotlin.code.style=official
2-
kotlin.mpp.enableGranularSourceSetsMetadata=true
3-
kotlin.native.enableDependencyPropagation=false
2+
#kotlin.mpp.enableGranularSourceSetsMetadata=true
3+
#kotlin.native.enableDependencyPropagation=false
44
kotlin.js.generate.executable.default=false
5+
kotlin.native.ignoreDisabledTargets=true
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package net.sergeych.sprintf
2+
3+
import kotlinx.datetime.Instant
4+
5+
actual fun ConvertToInstant(t: Any): Instant {
6+
// kotlin native date types... have no idea what these are
7+
// pls add your code here and create PR from it
8+
throw IllegalArgumentException("can't convert to time instant: $t")
9+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package net.sergeych.sprintf
2+
3+
/**
4+
* Platform could provide current locale based month name or return null to use English
5+
*/
6+
actual fun LocaleSpecificMonthName(monthNumber: Int): String? {
7+
// TODO: Get current locale mpnth name somehow
8+
return null
9+
}
10+
11+
actual fun LocaleSpecificAbbreviatedMonthName(monthNumber: Int): String? {
12+
// TODO extract local month name abbreviations
13+
return null
14+
}
15+
16+
actual fun LocaleSpecificDayName(isoDayNumber: Int): String? {
17+
return null
18+
}
19+
20+
actual fun LocaleSpecificAbbreviatedDayName(isoDayNumber: Int): String? {
21+
return null
22+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package net.sergeych.mp_logger
2+
3+
internal actual fun ConsoleLoggerSetup() {
4+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package net.sergeych.mp_logger
2+
3+
internal actual fun ConsoleLoggerSetup() {
4+
// nothing to do
5+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package net.sergeych.sprintf
2+
3+
/**
4+
* Platform could provide current locale based month name or return null to use English. Month number is 1..12
5+
* as default in date operations in java
6+
*/
7+
actual fun LocaleSpecificMonthName(monthNumber: Int): String? {
8+
return null
9+
}
10+
11+
actual fun LocaleSpecificAbbreviatedMonthName(monthNumber: Int): String? {
12+
return null
13+
}
14+
15+
actual fun LocaleSpecificDayName(isoDayNumber: Int): String? {
16+
return null
17+
}
18+
19+
actual fun LocaleSpecificAbbreviatedDayName(isoDayNumber: Int): String? {
20+
return null
21+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package net.sergeych.sprintf
2+
3+
import kotlinx.datetime.Instant
4+
actual fun ConvertToInstant(t: Any): Instant {
5+
throw IllegalArgumentException("Can't convert to LocalDateTime: $t")
6+
}

0 commit comments

Comments
 (0)