Refactoring: Keep predefined K/N targets inside of KonanTarget.Companion
This commit is contained in:
+2
-8
@@ -607,6 +607,8 @@ tasks {
|
|||||||
|
|
||||||
register("toolsTest") {
|
register("toolsTest") {
|
||||||
dependsOn(":tools:kotlinp:test")
|
dependsOn(":tools:kotlinp:test")
|
||||||
|
dependsOn(":native:kotlin-native-utils:test")
|
||||||
|
dependsOn(":native:kotlin-klib-commonizer:test")
|
||||||
}
|
}
|
||||||
|
|
||||||
register("examplesTest") {
|
register("examplesTest") {
|
||||||
@@ -637,13 +639,6 @@ tasks {
|
|||||||
dependsOn(":jps-plugin:test")
|
dependsOn(":jps-plugin:test")
|
||||||
}
|
}
|
||||||
|
|
||||||
register("konan-tests") {
|
|
||||||
dependsOn("dist")
|
|
||||||
dependsOn(
|
|
||||||
":native:kotlin-klib-commonizer:test"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
register("idea-plugin-main-tests") {
|
register("idea-plugin-main-tests") {
|
||||||
dependsOn("dist")
|
dependsOn("dist")
|
||||||
dependsOn(":idea:test")
|
dependsOn(":idea:test")
|
||||||
@@ -725,7 +720,6 @@ tasks {
|
|||||||
dependsOn(
|
dependsOn(
|
||||||
"idea-plugin-tests",
|
"idea-plugin-tests",
|
||||||
"jps-tests",
|
"jps-tests",
|
||||||
"konan-tests",
|
|
||||||
"plugins-tests",
|
"plugins-tests",
|
||||||
"android-ide-tests",
|
"android-ide-tests",
|
||||||
":generators:test"
|
":generators:test"
|
||||||
|
|||||||
@@ -8,11 +8,14 @@ description = "Kotlin/Native utils"
|
|||||||
dependencies {
|
dependencies {
|
||||||
compile(kotlinStdlib())
|
compile(kotlinStdlib())
|
||||||
compile(project(":kotlin-util-io"))
|
compile(project(":kotlin-util-io"))
|
||||||
}
|
|
||||||
|
testCompile(commonDep("junit:junit"))
|
||||||
|
testCompileOnly(project(":kotlin-reflect-api"))
|
||||||
|
testRuntime(project(":kotlin-reflect"))}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
"main" { projectDefault() }
|
"main" { projectDefault() }
|
||||||
"test" { none() }
|
"test" { projectDefault() }
|
||||||
}
|
}
|
||||||
|
|
||||||
publish()
|
publish()
|
||||||
|
|||||||
@@ -12,23 +12,11 @@ open class HostManager(protected val distribution: Distribution = Distribution()
|
|||||||
|
|
||||||
fun targetManager(userRequest: String? = null): TargetManager = TargetManagerImpl(userRequest, this)
|
fun targetManager(userRequest: String? = null): TargetManager = TargetManagerImpl(userRequest, this)
|
||||||
|
|
||||||
// TODO: need a better way to enumerated predefined targets.
|
|
||||||
private val predefinedTargets = listOf(
|
|
||||||
ANDROID_ARM32, ANDROID_ARM64, ANDROID_X86, ANDROID_X64,
|
|
||||||
IOS_ARM32, IOS_ARM64, IOS_X64,
|
|
||||||
WATCHOS_ARM32, WATCHOS_ARM64,
|
|
||||||
WATCHOS_X86, WATCHOS_X64,
|
|
||||||
TVOS_ARM64, TVOS_X64,
|
|
||||||
LINUX_X64, LINUX_ARM32_HFP, LINUX_ARM64, LINUX_MIPS32, LINUX_MIPSEL32,
|
|
||||||
MINGW_X64, MINGW_X86,
|
|
||||||
MACOS_X64,
|
|
||||||
WASM32)
|
|
||||||
|
|
||||||
private val zephyrSubtargets = distribution.availableSubTarget("zephyr").map { ZEPHYR(it) }
|
private val zephyrSubtargets = distribution.availableSubTarget("zephyr").map { ZEPHYR(it) }
|
||||||
private val experimentalEnabled = experimental || distribution.experimentalEnabled
|
private val experimentalEnabled = experimental || distribution.experimentalEnabled
|
||||||
private val configurableSubtargets = zephyrSubtargets
|
private val configurableSubtargets = zephyrSubtargets
|
||||||
|
|
||||||
val targetValues: List<KonanTarget> by lazy { predefinedTargets + configurableSubtargets }
|
val targetValues: List<KonanTarget> by lazy { KonanTarget.predefinedTargets.toList() + configurableSubtargets }
|
||||||
|
|
||||||
val targets = targetValues.associateBy { it.visibleName }
|
val targets = targetValues.associateBy { it.visibleName }
|
||||||
|
|
||||||
|
|||||||
@@ -36,4 +36,21 @@ sealed class KonanTarget(override val name: String, val family: Family, val arch
|
|||||||
KonanTarget("${genericName}_$subName", Family.ZEPHYR, Architecture.ARM32)
|
KonanTarget("${genericName}_$subName", Family.ZEPHYR, Architecture.ARM32)
|
||||||
|
|
||||||
override fun toString() = name
|
override fun toString() = name
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
// TODO: need a better way to enumerated predefined targets.
|
||||||
|
val predefinedTargets by lazy {
|
||||||
|
setOf(
|
||||||
|
ANDROID_X64, ANDROID_X86, ANDROID_ARM32, ANDROID_ARM64,
|
||||||
|
IOS_ARM32, IOS_ARM64, IOS_X64,
|
||||||
|
WATCHOS_ARM32, WATCHOS_ARM64, WATCHOS_X86, WATCHOS_X64,
|
||||||
|
TVOS_ARM64, TVOS_X64,
|
||||||
|
LINUX_X64,
|
||||||
|
MINGW_X86, MINGW_X64,
|
||||||
|
MACOS_X64,
|
||||||
|
LINUX_ARM64, LINUX_ARM32_HFP, LINUX_MIPS32, LINUX_MIPSEL32,
|
||||||
|
WASM32
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.konan.target
|
||||||
|
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class KonanTargetTest {
|
||||||
|
@Test
|
||||||
|
fun allPredefinedTargetsRegistered() {
|
||||||
|
assertEquals(
|
||||||
|
"Some of predefined KonanTarget instances are not listed in 'KonanTarget.predefinedTargets'",
|
||||||
|
KonanTarget::class.sealedSubclasses.mapNotNull { it.objectInstance }.toSet(),
|
||||||
|
KonanTarget.predefinedTargets
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user