[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:
Dmitry Savvinov
2024-01-16 17:21:12 +01:00
committed by Space Team
parent 29e90d70c6
commit 4957d99fd6
@@ -25,14 +25,22 @@ import org.jetbrains.kotlin.library.uniqueName
import org.jetbrains.kotlin.protobuf.ExtensionRegistryLite
import java.util.*
// Extracted from KonanTarget class to avoid problems with kotlin-native-shared.
private val deprecatedTargets = setOf(
KonanTarget.WATCHOS_X86,
KonanTarget.IOS_ARM32,
KonanTarget.MINGW_X86,
KonanTarget.LINUX_MIPS32,
KonanTarget.LINUX_MIPSEL32,
KonanTarget.WASM32
/**
* [this] is a value passed to `-target` CLI-argument (see [KonanConfigKeys.TARGET])
* Returns 'true' if this argument is most likely a removed [KonanTarget], allowing for a
* more readable and graceful error message.
*/
private fun String.looksLikeRemovedTarget(): Boolean =
// NB: zephyr had loadable targets, so the full value was of form 'zephyr_<subtarget>'
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(
@@ -87,6 +95,12 @@ class KonanDriver(
configuration.put(KonanConfigKeys.MAKE_PER_FILE_CACHE, true)
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)
if (configuration.get(KonanConfigKeys.LIST_TARGETS) == true) {
@@ -94,11 +108,6 @@ class KonanDriver(
}
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.
if (konanConfig.produce != CompilerOutputKind.LIBRARY && konanConfig.target in softDeprecatedTargets) {
configuration.report(CompilerMessageSeverity.STRONG_WARNING,