From 1cc83e880333f8aafae769c409189411bbdbacfe Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 23 Feb 2021 14:30:39 +0300 Subject: [PATCH] Adaptive native targets. --- CHANGELOG.md | 2 +- .../mipt/npm/gradle/KScienceNativePlugin.kt | 58 ++++++++++++------- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 567b28e..bf29ad3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added - +- Adaptive support for host OS in native ### Changed ### Deprecated diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceNativePlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceNativePlugin.kt index 7486de0..2d6406d 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceNativePlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceNativePlugin.kt @@ -18,10 +18,21 @@ class KScienceNativePlugin : Plugin { } configure { - //deploy mode - linuxX64() - mingwX64() - macosX64() + val hostOs = System.getProperty("os.name") + + val isLinux = hostOs == "Linux" + val isMinGw = hostOs.startsWith("Windows") + val isMacOs = hostOs == "Mac OS X" + + if (isLinux || isMinGw) { + linuxX64() + } + if (isMinGw) { + mingwX64() + } + if (isMacOs) { + macosX64() + } sourceSets { val commonMain by getting @@ -35,28 +46,33 @@ class KScienceNativePlugin : Plugin { dependsOn(commonTest) } - val linuxX64Main by getting { - dependsOn(nativeMain) + if (isLinux) { + val linuxX64Main by getting { + dependsOn(nativeMain) + } + val linuxX64Test by getting { + dependsOn(nativeTest) + } } - val mingwX64Main by getting { - dependsOn(nativeMain) + if (isMinGw) { + val mingwX64Main by getting { + dependsOn(nativeMain) + } + + val mingwX64Test by getting { + dependsOn(nativeTest) + } } - val macosX64Main by getting { - dependsOn(nativeMain) - } + if (isMacOs) { + val macosX64Main by getting { + dependsOn(nativeMain) + } - val linuxX64Test by getting { - dependsOn(nativeTest) - } - - val mingwX64Test by getting { - dependsOn(nativeTest) - } - - val macosX64Test by getting { - dependsOn(nativeTest) + val macosX64Test by getting { + dependsOn(nativeTest) + } } } }