Skip to content

Commit

Permalink
Added Ios and MacM1 targets (#148)
Browse files Browse the repository at this point in the history
### What's done:
- Added iOS and macosArm64 targets
  • Loading branch information
Wavesonics authored Jun 21, 2022
1 parent 3126f03 commit dfabe14
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/com/akuleshov7/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<PublishingExtension> {
publications.matching { it.name in publicationsFromMainHost }.all {
val targetPublication = this@all
Expand Down
2 changes: 0 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion ktoml-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ kotlin {
mingwX64()
linuxX64()
macosX64()
macosArm64()
ios()

sourceSets {
all {
Expand Down Expand Up @@ -75,7 +77,7 @@ tasks.withType<KotlinJvmTest> {
}

tasks.withType<KotlinJsTest> {
if (this.name.contains("testTask")) {
if (this.name.contains("jsBrowserTest")) {
this.enabled = false
}
}
Original file line number Diff line number Diff line change
@@ -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()
}
Original file line number Diff line number Diff line change
@@ -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()
}
17 changes: 17 additions & 0 deletions ktoml-file/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ kotlin {
mingwX64()
linuxX64()
macosX64()
macosArm64()
ios()

sourceSets {
all {
Expand Down Expand Up @@ -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}")
Expand Down Expand Up @@ -88,3 +97,11 @@ configurePublishing()
tasks.withType<KotlinJvmTest> {
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<org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest> {
if (this.name.contains("ios")) {
this.enabled = false
}
}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit dfabe14

Please sign in to comment.