Skip to content

Commit 6dc4f21

Browse files
committed
Enable all KMP targets (except Windows)
1 parent dc4dabb commit 6dc4f21

File tree

2 files changed

+39
-68
lines changed

2 files changed

+39
-68
lines changed

build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/ConfigureTargets.kt

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55
package aws.sdk.kotlin.gradle.kmp
66

7+
import aws.sdk.kotlin.gradle.util.prop
78
import org.gradle.api.Project
89
import org.gradle.api.tasks.testing.Test
910
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
@@ -45,7 +46,7 @@ val Project.hasWindows: Boolean get() = hasNative || files.any { it.name == "win
4546
* Test if a project follows the convention and needs configured for KMP (used in handful of spots where we have a
4647
* subproject that is just a container for other projects but isn't a KMP project itself).
4748
*/
48-
public val Project.needsKmpConfigured: Boolean get() = hasCommon || hasJvm || hasNative || hasJs
49+
public val Project.needsKmpConfigured: Boolean get() = hasCommon || hasJvm || hasNative || hasJs || hasJvmAndNative || hasDesktop || hasLinux || hasApple || hasWindows
4950

5051
@OptIn(ExperimentalKotlinGradlePluginApi::class)
5152
fun Project.configureKmpTargets() {
@@ -64,7 +65,8 @@ fun Project.configureKmpTargets() {
6465
return@withPlugin
6566
}
6667

67-
// configure the target hierarchy, this does not actually enable the targets, just their relationships
68+
// extend the default KMP target hierarchy
69+
// this does not actually enable the targets, just their relationships
6870
// see https://kotlinlang.org/docs/multiplatform-hierarchy.html#see-the-full-hierarchy-template
6971
kmpExt.applyDefaultHierarchyTemplate {
7072
if (hasJvmAndNative) {
@@ -95,24 +97,28 @@ fun Project.configureKmpTargets() {
9597
}
9698
}
9799

98-
// enable targets
100+
// enable the targets
99101
configureCommon()
100102

101103
if (hasJvm && JVM_ENABLED) {
102104
configureJvm()
103105
}
104106

105107
// FIXME Configure JS
106-
// FIXME Configure Apple
107-
// FIXME Configure Windows
108108

109-
withIf(hasLinux && NATIVE_ENABLED, kmpExt) {
110-
configureLinux()
111-
}
112-
113-
withIf(hasDesktop && NATIVE_ENABLED, kmpExt) {
114-
configureLinux()
115-
// FIXME Configure desktop
109+
if (NATIVE_ENABLED) {
110+
if (hasApple) {
111+
kmpExt.apply { configureApple() }
112+
}
113+
if (hasWindows) {
114+
kmpExt.apply { configureWindows() }
115+
}
116+
if (hasLinux) {
117+
kmpExt.apply { configureLinux() }
118+
}
119+
if (hasDesktop) {
120+
kmpExt.apply { configureWindows() }
121+
}
116122
}
117123

118124
kmpExt.configureSourceSetsConvention()
@@ -155,14 +161,25 @@ fun Project.configureJvm() {
155161

156162
fun Project.configureLinux() {
157163
kotlin {
158-
linuxX64 {
159-
// FIXME enable tests once the target is fully implemented
160-
tasks.named("linuxX64Test") {
161-
enabled = false
162-
}
163-
}
164-
// FIXME - Okio missing arm64 target support
165-
// linuxArm64()
164+
linuxX64()
165+
linuxArm64() // FIXME - Okio missing arm64 target support
166+
}
167+
}
168+
169+
fun Project.configureApple() {
170+
kotlin {
171+
macosX64()
172+
macosArm64()
173+
iosSimulatorArm64()
174+
iosArm64()
175+
iosX64()
176+
}
177+
}
178+
179+
fun Project.configureWindows() {
180+
kotlin {
181+
// FIXME Set up Docker files and CMake tasks for Windows
182+
// mingwX64()
166183
}
167184
}
168185

@@ -179,8 +196,5 @@ fun KotlinMultiplatformExtension.configureSourceSetsConvention() {
179196
}
180197
}
181198

182-
internal inline fun <T> withIf(condition: Boolean, receiver: T, block: T.() -> Unit) {
183-
if (condition) {
184-
receiver.block()
185-
}
186-
}
199+
val Project.JVM_ENABLED get() = prop("aws.kotlin.jvm")?.let { it == "true" } ?: true
200+
val Project.NATIVE_ENABLED get() = prop("aws.kotlin.native")?.let { it == "true" } ?: true

build-plugins/kmp-conventions/src/main/kotlin/aws/sdk/kotlin/gradle/kmp/IdeUtils.kt

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)