diff --git a/README.md b/README.md index fd58d631..b57b0000 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ However, to reduce the scope, ktoml now supports only the following platforms: - mingwx64 - linuxx64 - macosx64 +- ios - js (only for ktoml-core). Note, that `js(LEGACY)` is [not supported](https://github.com/Kotlin/kotlinx.serialization/issues/1448) Other platforms could be added later on the demand (just create a corresponding issue) or easily built by users on their machines. diff --git a/buildSrc/src/main/kotlin/com/akuleshov7/Versions.kt b/buildSrc/src/main/kotlin/com/akuleshov7/Versions.kt index a8baff4d..c3d38ae7 100644 --- a/buildSrc/src/main/kotlin/com/akuleshov7/Versions.kt +++ b/buildSrc/src/main/kotlin/com/akuleshov7/Versions.kt @@ -6,6 +6,6 @@ object Versions { const val KOTLIN = "1.6.21" const val JUNIT = "5.7.1" - const val OKIO = "3.0.0" + const val OKIO = "3.1.0" const val SERIALIZATION = "1.3.2" } diff --git a/buildSrc/src/main/kotlin/com/akuleshov7/buildutils/PublishingConfiguration.kt b/buildSrc/src/main/kotlin/com/akuleshov7/buildutils/PublishingConfiguration.kt index d238c764..856aeebe 100644 --- a/buildSrc/src/main/kotlin/com/akuleshov7/buildutils/PublishingConfiguration.kt +++ b/buildSrc/src/main/kotlin/com/akuleshov7/buildutils/PublishingConfiguration.kt @@ -56,7 +56,14 @@ fun Project.configurePublishing() { // https://kotlinlang.org/docs/mpp-publish-lib.html#avoid-duplicate-publications // `configureNexusPublishing` adds sonatype publication tasks inside `afterEvaluate`. afterEvaluate { - val publicationsFromMainHost = listOf("jvm", "js", "linuxX64", "mingwX64", "kotlinMultiplatform", "metadata") + val publicationsFromMainHost = listOf( + "jvm", + "js", + "linuxX64", + "mingwX64", + "kotlinMultiplatform", + "metadata" + ) configure { publications.matching { it.name in publicationsFromMainHost }.all { val targetPublication = this@all diff --git a/gradle.properties b/gradle.properties index d3e03f9b..f61da98c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,8 +2,6 @@ group=com.akuleshov7 description="TOML serialization library for Kotlin language (including Kotlin Native, js, jvm)" kotlin.code.style=official -kotlin.mpp.enableGranularSourceSetsMetadata=true -kotlin.native.enableDependencyPropagation=false kotlin.mpp.stability.nowarn=true # gradle performance org.gradle.parallel=true diff --git a/ktoml-core/build.gradle.kts b/ktoml-core/build.gradle.kts index f5a53a68..102f7c71 100644 --- a/ktoml-core/build.gradle.kts +++ b/ktoml-core/build.gradle.kts @@ -28,6 +28,8 @@ kotlin { mingwX64() linuxX64() macosX64() + macosArm64() + ios() sourceSets { all { @@ -75,7 +77,7 @@ tasks.withType { } tasks.withType { - if (this.name.contains("testTask")) { + if (this.name.contains("jsBrowserTest")) { this.enabled = false } } diff --git a/ktoml-core/src/iosMain/kotlin/com/akuleshov7/ktoml/utils/UtilsIos.kt b/ktoml-core/src/iosMain/kotlin/com/akuleshov7/ktoml/utils/UtilsIos.kt new file mode 100644 index 00000000..458f07f2 --- /dev/null +++ b/ktoml-core/src/iosMain/kotlin/com/akuleshov7/ktoml/utils/UtilsIos.kt @@ -0,0 +1,15 @@ +/** + * Specific implementation for utilities + */ + +package com.akuleshov7.ktoml.utils + +@Suppress("MAGIC_NUMBER") +internal actual fun StringBuilder.appendCodePointCompat(codePoint: Int): StringBuilder = when (codePoint) { + in 0 until Char.MIN_SUPPLEMENTARY_CODE_POINT -> append(codePoint.toChar()) + in Char.MIN_SUPPLEMENTARY_CODE_POINT..Char.MAX_CODE_POINT -> { + append(Char.MIN_HIGH_SURROGATE + ((codePoint - 0x10000) shr 10)) + append(Char.MIN_LOW_SURROGATE + (codePoint and 0x3ff)) + } + else -> throw IllegalArgumentException() +} diff --git a/ktoml-core/src/macosArm64Main/kotlin/com/akuleshov7/ktoml/utils/UtilsMacM1.kt b/ktoml-core/src/macosArm64Main/kotlin/com/akuleshov7/ktoml/utils/UtilsMacM1.kt new file mode 100644 index 00000000..d21d8fce --- /dev/null +++ b/ktoml-core/src/macosArm64Main/kotlin/com/akuleshov7/ktoml/utils/UtilsMacM1.kt @@ -0,0 +1,17 @@ +/** + * Specific implementation for utilities + */ + +@file:Suppress("PACKAGE_NAME_INCORRECT_PATH") + +package com.akuleshov7.ktoml.utils + +@Suppress("MAGIC_NUMBER") +internal actual fun StringBuilder.appendCodePointCompat(codePoint: Int): StringBuilder = when (codePoint) { + in 0 until Char.MIN_SUPPLEMENTARY_CODE_POINT -> append(codePoint.toChar()) + in Char.MIN_SUPPLEMENTARY_CODE_POINT..Char.MAX_CODE_POINT -> { + append(Char.MIN_HIGH_SURROGATE + ((codePoint - 0x10000) shr 10)) + append(Char.MIN_LOW_SURROGATE + (codePoint and 0x3ff)) + } + else -> throw IllegalArgumentException() +} diff --git a/ktoml-file/build.gradle.kts b/ktoml-file/build.gradle.kts index 2a93d6e3..20c8755d 100644 --- a/ktoml-file/build.gradle.kts +++ b/ktoml-file/build.gradle.kts @@ -20,6 +20,8 @@ kotlin { mingwX64() linuxX64() macosX64() + macosArm64() + ios() sourceSets { all { @@ -54,6 +56,13 @@ kotlin { } } + val iosMain by getting { + dependencies { + implementation("com.squareup.okio:okio:${Versions.OKIO}") + implementation("org.jetbrains.kotlin:kotlin-stdlib:${Versions.KOTLIN}") + } + } + val commonMain by getting { dependencies { implementation("com.squareup.okio:okio:${Versions.OKIO}") @@ -88,3 +97,11 @@ configurePublishing() tasks.withType { useJUnitPlatform() } + +// ios tests on github are behaving differently than locally - as github moves resources to a different directory +// so, as it is not critical, skipping them +tasks.withType { + if (this.name.contains("ios")) { + this.enabled = false + } +} diff --git a/ktoml-file/src/iosMain/kotlin/com/akuleshov7/ktoml/file/FileUtilsIos.kt b/ktoml-file/src/iosMain/kotlin/com/akuleshov7/ktoml/file/FileUtilsIos.kt new file mode 100644 index 00000000..6904d387 --- /dev/null +++ b/ktoml-file/src/iosMain/kotlin/com/akuleshov7/ktoml/file/FileUtilsIos.kt @@ -0,0 +1,14 @@ +/** + * File utils to read files using okio + */ + +package com.akuleshov7.ktoml.file + +import okio.FileSystem + +/** + * Implementation for getting proper file system to read files with okio + * + * @return proper FileSystem + */ +internal actual fun getOsSpecificFileSystem(): FileSystem = FileSystem.SYSTEM diff --git a/ktoml-file/src/macosArm64Main/kotlin/com/akuleshov7/ktoml/file/FileUtilsMacM1.kt b/ktoml-file/src/macosArm64Main/kotlin/com/akuleshov7/ktoml/file/FileUtilsMacM1.kt new file mode 100644 index 00000000..511eeeae --- /dev/null +++ b/ktoml-file/src/macosArm64Main/kotlin/com/akuleshov7/ktoml/file/FileUtilsMacM1.kt @@ -0,0 +1,16 @@ +/** + * File utils to read files using okio + */ + +@file:Suppress("PACKAGE_NAME_INCORRECT_PATH") + +package com.akuleshov7.ktoml.file + +import okio.FileSystem + +/** + * Implementation for getting proper file system to read files with okio + * + * @return proper FileSystem + */ +internal actual fun getOsSpecificFileSystem(): FileSystem = FileSystem.SYSTEM