44 */
55package aws.sdk.kotlin.gradle.kmp
66
7+ import aws.sdk.kotlin.gradle.util.prop
78import org.gradle.api.Project
89import org.gradle.api.tasks.testing.Test
910import 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 )
5152fun 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,32 @@ 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 {
121+ configureLinux()
122+ configureMacos()
123+ configureWindows()
124+ }
125+ }
116126 }
117127
118128 kmpExt.configureSourceSetsConvention()
@@ -155,14 +165,31 @@ fun Project.configureJvm() {
155165
156166fun Project.configureLinux () {
157167 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()
168+ linuxX64()
169+ linuxArm64() // FIXME - Okio missing arm64 target support
170+ }
171+ }
172+
173+ fun Project.configureApple () {
174+ kotlin {
175+ configureMacos()
176+ iosSimulatorArm64()
177+ iosArm64()
178+ iosX64()
179+ }
180+ }
181+
182+ fun Project.configureMacos () {
183+ kotlin {
184+ macosX64()
185+ macosArm64()
186+ }
187+ }
188+
189+ fun Project.configureWindows () {
190+ kotlin {
191+ // FIXME Set up Docker files and CMake tasks for Windows
192+ // mingwX64()
166193 }
167194}
168195
@@ -179,8 +206,5 @@ fun KotlinMultiplatformExtension.configureSourceSetsConvention() {
179206 }
180207}
181208
182- internal inline fun <T > withIf (condition : Boolean , receiver : T , block : T .() -> Unit ) {
183- if (condition) {
184- receiver.block()
185- }
186- }
209+ val Project .JVM_ENABLED get() = prop(" aws.kotlin.jvm" )?.let { it == " true" } ? : true
210+ val Project .NATIVE_ENABLED get() = prop(" aws.kotlin.native" )?.let { it == " true" } ? : true
0 commit comments