Gradle: Support K/N restricted distribution
Restricted distribution is a K/N distribution built for MacOS only alongside with a regular distribution and containing no platform libraries for MacOS. This commit allows switching between distribution types using a special project property. Issue #KT-32301 Fixed
This commit is contained in:
+1
-1
@@ -171,7 +171,7 @@ extra["versions.trove4j"] = "1.0.20181211"
|
||||
extra["versions.ktor-network"] = "1.0.1"
|
||||
|
||||
if (!project.hasProperty("versions.kotlin-native")) {
|
||||
extra["versions.kotlin-native"] = "1.3-dev-9780"
|
||||
extra["versions.kotlin-native"] = "1.3.50-dev-11052"
|
||||
}
|
||||
|
||||
val isTeamcityBuild = project.kotlinBuildProperties.isTeamcityBuild
|
||||
|
||||
+14
@@ -1302,6 +1302,20 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
assertSuccessful()
|
||||
assertTrue(output.contains("Kotlin/Native distribution: "))
|
||||
}
|
||||
|
||||
build("tasks", "-Pkotlin.native.restrictedDistribution=true") {
|
||||
assertSuccessful()
|
||||
val dists = output.lineSequence().filter {
|
||||
it.contains("Kotlin/Native distribution: ")
|
||||
}
|
||||
|
||||
// Restricted distribution is available for Mac hosts only.
|
||||
if (HostManager.hostIsMac) {
|
||||
assertTrue(dists.all { it.contains("-restricted-") })
|
||||
} else {
|
||||
assertTrue(dists.none { it.contains("-restricted-") })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
@@ -108,6 +108,17 @@ internal class PropertiesProvider(private val project: Project) {
|
||||
val individualTaskReports: Boolean?
|
||||
get() = booleanProperty("kotlin.tests.individualTaskReports")
|
||||
|
||||
/**
|
||||
* Forces using a "restricted" distribution of Kotlin/Native.
|
||||
*
|
||||
* A restricted distribution is available for MacOS only and doesn't contain platform libraries.
|
||||
* If a host platform is not MacOS, the flag is ignored.
|
||||
*/
|
||||
val nativeRestrictedDistribution: Boolean?
|
||||
get() = booleanProperty("kotlin.native.restrictedDistribution")
|
||||
|
||||
// TODO: Add other native props here.
|
||||
|
||||
private fun booleanProperty(propName: String): Boolean? =
|
||||
property(propName)?.toBoolean()
|
||||
|
||||
|
||||
+10
-1
@@ -14,6 +14,7 @@ import org.gradle.api.logging.Logger
|
||||
import org.jetbrains.kotlin.compilerRunner.KonanCompilerRunner
|
||||
import org.jetbrains.kotlin.compilerRunner.konanVersion
|
||||
import org.jetbrains.kotlin.gradle.logging.kotlinInfo
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
||||
import org.jetbrains.kotlin.konan.KonanVersion
|
||||
import org.jetbrains.kotlin.konan.MetaVersion
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
@@ -39,11 +40,19 @@ class NativeCompilerDownloader(
|
||||
private val logger: Logger
|
||||
get() = project.logger
|
||||
|
||||
// We provide restricted distributions only for Mac.
|
||||
private val restrictedDistribution: Boolean
|
||||
get() = HostManager.hostIsMac && PropertiesProvider(project).nativeRestrictedDistribution ?: false
|
||||
|
||||
private val simpleOsName: String
|
||||
get() = HostManager.simpleOsName()
|
||||
|
||||
private val dependencyName: String
|
||||
get() = "kotlin-native-$simpleOsName"
|
||||
get() = if (restrictedDistribution) {
|
||||
"kotlin-native-restricted-$simpleOsName"
|
||||
} else {
|
||||
"kotlin-native-$simpleOsName"
|
||||
}
|
||||
|
||||
private val dependencyNameWithVersion: String
|
||||
get() = "$dependencyName-$compilerVersion"
|
||||
|
||||
Reference in New Issue
Block a user