Skip to content

Commit e0dd277

Browse files
authored
Conditionally remove native targets that are removed in 1.9.20 (#3825)
1 parent bb54504 commit e0dd277

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@file:JvmName("KotlinVersion")
2+
3+
fun isKotlinVersionAtLeast(kotlinVersion: String, atLeastMajor: Int, atLeastMinor: Int, atLeastPatch: Int): Boolean {
4+
val (major, minor) = kotlinVersion
5+
.split('.')
6+
.take(2)
7+
.map { it.toInt() }
8+
val patch = kotlinVersion.substringAfterLast('.').substringBefore('-').toInt()
9+
return when {
10+
major > atLeastMajor -> true
11+
major < atLeastMajor -> false
12+
else -> (minor == atLeastMinor && patch >= atLeastPatch) || minor > atLeastMinor
13+
}
14+
}

gradle/compile-native-multiplatform.gradle

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1+
import static KotlinVersion.isKotlinVersionAtLeast
2+
13
/*
24
* Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
35
*/
46

57
project.ext.nativeMainSets = []
68
project.ext.nativeTestSets = []
79

10+
// TODO: this block should be removed when Kotlin version is updated to 1.9.20
11+
// Right now it is used for conditional removal of native targets that will be removed in 1.9.20 (iosArm32, watchosX86)
12+
// and is necessary for testing of Kotlin dev builds.
13+
def enableDeprecatedNativeTargets = !isKotlinVersionAtLeast(ext.kotlin_version, 1, 9, 20)
14+
815
kotlin {
916
targets {
1017
delegate.metaClass.addTarget = { preset ->
@@ -43,8 +50,10 @@ kotlin {
4350
addTarget(presets.watchosDeviceArm64)
4451

4552
// Deprecated, but were provided by coroutine; can be removed only when K/N drops the target
46-
addTarget(presets.iosArm32)
47-
addTarget(presets.watchosX86)
53+
if (enableDeprecatedNativeTargets) {
54+
addTarget(presets.iosArm32)
55+
addTarget(presets.watchosX86)
56+
}
4857
}
4958

5059
sourceSets {

0 commit comments

Comments
 (0)