[native] Drop deprecated Kotlin/Native targets (4/8)
We still want to report a readable error on using removed targets rather than just an "Unknown target"-exception. As previous commits has removed actual KonanTarget-entries, the check has to be adjusted to work on plain strings. ^KT-64517
This commit is contained in:
committed by
Space Team
parent
29e90d70c6
commit
4957d99fd6
+22
-13
@@ -25,14 +25,22 @@ import org.jetbrains.kotlin.library.uniqueName
|
|||||||
import org.jetbrains.kotlin.protobuf.ExtensionRegistryLite
|
import org.jetbrains.kotlin.protobuf.ExtensionRegistryLite
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
// Extracted from KonanTarget class to avoid problems with kotlin-native-shared.
|
/**
|
||||||
private val deprecatedTargets = setOf(
|
* [this] is a value passed to `-target` CLI-argument (see [KonanConfigKeys.TARGET])
|
||||||
KonanTarget.WATCHOS_X86,
|
* Returns 'true' if this argument is most likely a removed [KonanTarget], allowing for a
|
||||||
KonanTarget.IOS_ARM32,
|
* more readable and graceful error message.
|
||||||
KonanTarget.MINGW_X86,
|
*/
|
||||||
KonanTarget.LINUX_MIPS32,
|
private fun String.looksLikeRemovedTarget(): Boolean =
|
||||||
KonanTarget.LINUX_MIPSEL32,
|
// NB: zephyr had loadable targets, so the full value was of form 'zephyr_<subtarget>'
|
||||||
KonanTarget.WASM32
|
this in removedTargetsNames || this.startsWith("zephyr_")
|
||||||
|
|
||||||
|
private val removedTargetsNames = setOf(
|
||||||
|
"ios_arm32",
|
||||||
|
"watchos_x86",
|
||||||
|
"linux_mips32",
|
||||||
|
"linux_mipsel32",
|
||||||
|
"mingw_x86",
|
||||||
|
"wasm32"
|
||||||
)
|
)
|
||||||
|
|
||||||
private val softDeprecatedTargets = setOf(
|
private val softDeprecatedTargets = setOf(
|
||||||
@@ -87,6 +95,12 @@ class KonanDriver(
|
|||||||
configuration.put(KonanConfigKeys.MAKE_PER_FILE_CACHE, true)
|
configuration.put(KonanConfigKeys.MAKE_PER_FILE_CACHE, true)
|
||||||
configuration.put(KonanConfigKeys.FILES_TO_CACHE, fileNames)
|
configuration.put(KonanConfigKeys.FILES_TO_CACHE, fileNames)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val target = configuration.get(KonanConfigKeys.TARGET)
|
||||||
|
if (target != null && target.looksLikeRemovedTarget()) {
|
||||||
|
configuration.report(CompilerMessageSeverity.ERROR,
|
||||||
|
"target $target is no longer available. See: $DEPRECATION_LINK")
|
||||||
|
}
|
||||||
var konanConfig = KonanConfig(project, configuration)
|
var konanConfig = KonanConfig(project, configuration)
|
||||||
|
|
||||||
if (configuration.get(KonanConfigKeys.LIST_TARGETS) == true) {
|
if (configuration.get(KonanConfigKeys.LIST_TARGETS) == true) {
|
||||||
@@ -94,11 +108,6 @@ class KonanDriver(
|
|||||||
}
|
}
|
||||||
if (konanConfig.infoArgsOnly) return
|
if (konanConfig.infoArgsOnly) return
|
||||||
|
|
||||||
if (konanConfig.target in deprecatedTargets || konanConfig.target is KonanTarget.ZEPHYR) {
|
|
||||||
configuration.report(CompilerMessageSeverity.ERROR,
|
|
||||||
"target ${konanConfig.target} is no longer available. See: $DEPRECATION_LINK")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Avoid showing warning twice in 2-phase compilation.
|
// Avoid showing warning twice in 2-phase compilation.
|
||||||
if (konanConfig.produce != CompilerOutputKind.LIBRARY && konanConfig.target in softDeprecatedTargets) {
|
if (konanConfig.produce != CompilerOutputKind.LIBRARY && konanConfig.target in softDeprecatedTargets) {
|
||||||
configuration.report(CompilerMessageSeverity.STRONG_WARNING,
|
configuration.report(CompilerMessageSeverity.STRONG_WARNING,
|
||||||
|
|||||||
Reference in New Issue
Block a user