Skip to content

Conditionally remove native targets that are removed in 1.9.20 #3825

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions buildSrc/src/main/kotlin/KotlinVersion.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@file:JvmName("KotlinVersion")

fun isKotlinVersionAtLeast(kotlinVersion: String, atLeastMajor: Int, atLeastMinor: Int, atLeastPatch: Int): Boolean {
val (major, minor) = kotlinVersion
.split('.')
.take(2)
.map { it.toInt() }
val patch = kotlinVersion.substringAfterLast('.').substringBefore('-').toInt()
return when {
major > atLeastMajor -> true
major < atLeastMajor -> false
else -> (minor == atLeastMinor && patch >= atLeastPatch) || minor > atLeastMinor
}
}
13 changes: 11 additions & 2 deletions gradle/compile-native-multiplatform.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import static KotlinVersion.isKotlinVersionAtLeast

/*
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/

project.ext.nativeMainSets = []
project.ext.nativeTestSets = []

// TODO: this block should be removed when Kotlin version is updated to 1.9.20
// Right now it is used for conditional removal of native targets that will be removed in 1.9.20 (iosArm32, watchosX86)
// and is necessary for testing of Kotlin dev builds.
def enableDeprecatedNativeTargets = !isKotlinVersionAtLeast(ext.kotlin_version, 1, 9, 20)

kotlin {
targets {
delegate.metaClass.addTarget = { preset ->
Expand Down Expand Up @@ -43,8 +50,10 @@ kotlin {
addTarget(presets.watchosDeviceArm64)

// Deprecated, but were provided by coroutine; can be removed only when K/N drops the target
addTarget(presets.iosArm32)
addTarget(presets.watchosX86)
if (enableDeprecatedNativeTargets) {
addTarget(presets.iosArm32)
addTarget(presets.watchosX86)
}
}

sourceSets {
Expand Down