Moved KonanTargets to be mostly pairs.
Moved nice device and generic os names to be target aliases.
This commit is contained in:
committed by
alexander-gorshenev
parent
0c8ca828eb
commit
0570e281a9
+1
-1
@@ -47,7 +47,7 @@ class ToolConfig(userProvidedTargetName: String?, flavor: KotlinPlatform) {
|
||||
val sysRoot = platform.absoluteTargetSysRoot
|
||||
|
||||
val libclang = when (host) {
|
||||
KonanTarget.MINGW -> "$llvmHome/bin/libclang.dll"
|
||||
KonanTarget.MINGW_X64 -> "$llvmHome/bin/libclang.dll"
|
||||
else -> "$llvmHome/lib/${System.mapLibraryName("clang")}"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ class KonanConfig(val project: Project, val configuration: CompilerConfiguration
|
||||
|
||||
init {
|
||||
if (!platformManager.isEnabled(target)) {
|
||||
error("Target $target is not available on the ${HostManager.host} host")
|
||||
error("Target ${target.visibleName} is not available on the ${HostManager.hostName} host")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -166,8 +166,8 @@ internal class LinkStage(val context: Context) {
|
||||
val framework = File(context.config.outputFile)
|
||||
val dylibName = framework.name.removeSuffix(".framework")
|
||||
val dylibRelativePath = when (target) {
|
||||
KonanTarget.IPHONE, KonanTarget.IPHONE_SIM -> dylibName
|
||||
KonanTarget.MACBOOK -> "Versions/A/$dylibName"
|
||||
KonanTarget.IOS_ARM64, KonanTarget.IOS_X64 -> dylibName
|
||||
KonanTarget.MACOS_X64 -> "Versions/A/$dylibName"
|
||||
else -> error(target)
|
||||
}
|
||||
frameworkLinkerArgs = listOf("-install_name", "@rpath/${framework.name}/$dylibRelativePath")
|
||||
|
||||
+1
-1
@@ -454,7 +454,7 @@ internal class Llvm(val context: Context, val llvmModule: LLVMModuleRef) {
|
||||
}
|
||||
|
||||
private val personalityFunctionName = when (target) {
|
||||
KonanTarget.MINGW -> "__gxx_personality_seh0"
|
||||
KonanTarget.MINGW_X64 -> "__gxx_personality_seh0"
|
||||
else -> "__gxx_personality_v0"
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -2268,8 +2268,8 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
||||
// unaligned fields (there are some complicated exceptions currently ignored). The latter condition
|
||||
// is "encoded" by stub generator by emitting either `getMessenger` or `getMessengerLU` intrinsic call.
|
||||
val isStret = when (context.config.target) {
|
||||
KonanTarget.MACBOOK, KonanTarget.IPHONE_SIM -> isLU // x86_64
|
||||
KonanTarget.IPHONE -> false // aarch64
|
||||
KonanTarget.MACOS_X64, KonanTarget.IOS_X64 -> isLU // x86_64
|
||||
KonanTarget.IOS_ARM64 -> false // aarch64
|
||||
else -> TODO()
|
||||
}
|
||||
|
||||
|
||||
+13
-13
@@ -44,8 +44,8 @@ internal class ObjCExport(val context: Context) {
|
||||
|
||||
val framework = File(context.config.outputFile)
|
||||
val frameworkContents = when (target) {
|
||||
KonanTarget.IPHONE, KonanTarget.IPHONE_SIM -> framework
|
||||
KonanTarget.MACBOOK -> framework.child("Versions/A")
|
||||
KonanTarget.IOS_ARM64, KonanTarget.IOS_X64 -> framework
|
||||
KonanTarget.MACOS_X64 -> framework.child("Versions/A")
|
||||
else -> error(target)
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ internal class ObjCExport(val context: Context) {
|
||||
|
||||
emitInfoPlist(frameworkContents, frameworkName)
|
||||
|
||||
if (target == KonanTarget.MACBOOK) {
|
||||
if (target == KonanTarget.MACOS_X64) {
|
||||
framework.child("Versions/Current").createAsSymlink("A")
|
||||
for (child in listOf(frameworkName, "Headers", "Modules", "Resources")) {
|
||||
framework.child(child).createAsSymlink("Versions/Current/$child")
|
||||
@@ -86,9 +86,9 @@ internal class ObjCExport(val context: Context) {
|
||||
|
||||
private fun emitInfoPlist(frameworkContents: File, name: String) {
|
||||
val directory = when (target) {
|
||||
KonanTarget.IPHONE,
|
||||
KonanTarget.IPHONE_SIM -> frameworkContents
|
||||
KonanTarget.MACBOOK -> frameworkContents.child("Resources").also { it.mkdirs() }
|
||||
KonanTarget.IOS_ARM64,
|
||||
KonanTarget.IOS_X64 -> frameworkContents
|
||||
KonanTarget.MACOS_X64 -> frameworkContents.child("Resources").also { it.mkdirs() }
|
||||
else -> error(target)
|
||||
}
|
||||
|
||||
@@ -97,9 +97,9 @@ internal class ObjCExport(val context: Context) {
|
||||
val bundleId = pkg.child(Name.identifier(name)).asString()
|
||||
|
||||
val platform = when (target) {
|
||||
KonanTarget.IPHONE -> "iPhoneOS"
|
||||
KonanTarget.IPHONE_SIM -> "iPhoneSimulator"
|
||||
KonanTarget.MACBOOK -> "MacOSX"
|
||||
KonanTarget.IOS_ARM64 -> "iPhoneOS"
|
||||
KonanTarget.IOS_X64 -> "iPhoneSimulator"
|
||||
KonanTarget.MACOS_X64 -> "MacOSX"
|
||||
else -> error(target)
|
||||
}
|
||||
val properties = context.config.platform.configurables as AppleConfigurables
|
||||
@@ -134,8 +134,8 @@ internal class ObjCExport(val context: Context) {
|
||||
|
||||
|
||||
contents.append(when (target) {
|
||||
KonanTarget.IPHONE,
|
||||
KonanTarget.IPHONE_SIM -> """
|
||||
KonanTarget.IOS_ARM64,
|
||||
KonanTarget.IOS_X64 -> """
|
||||
| <key>MinimumOSVersion</key>
|
||||
| <string>$minimumOsVersion</string>
|
||||
| <key>UIDeviceFamily</key>
|
||||
@@ -145,11 +145,11 @@ internal class ObjCExport(val context: Context) {
|
||||
| </array>
|
||||
|
||||
""".trimMargin()
|
||||
KonanTarget.MACBOOK -> ""
|
||||
KonanTarget.MACOS_X64 -> ""
|
||||
else -> error(target)
|
||||
})
|
||||
|
||||
if (target == KonanTarget.IPHONE) {
|
||||
if (target == KonanTarget.IOS_ARM64) {
|
||||
contents.append("""
|
||||
| <key>UIRequiredDeviceCapabilities</key>
|
||||
| <array>
|
||||
|
||||
@@ -30,7 +30,7 @@ open class KlibInstall: Exec() {
|
||||
val result = super.configure(config)
|
||||
val konanHomePath = project.findProperty("konan.home") ?: "dist"
|
||||
val konanHome = project.rootProject.file(konanHomePath)
|
||||
val suffix = if (HostManager.host == KonanTarget.MINGW) ".bat" else ""
|
||||
val suffix = if (HostManager.host == KonanTarget.MINGW_X64) ".bat" else ""
|
||||
val klibProgram = "$konanHome/bin/klib$suffix"
|
||||
|
||||
doFirst {
|
||||
|
||||
@@ -35,7 +35,7 @@ private ArrayList<DefFile> targetDefFiles(KonanTarget target) {
|
||||
.findAll { it.name.endsWith(".def") }
|
||||
// The libz.a/libz.so and zlib.h are missing in raspberrypi and mips sysroots.
|
||||
// Just workaround it until we have sysroots corrected.
|
||||
.findAll { ! ((target instanceof KonanTarget.RASPBERRYPI ||
|
||||
.findAll { ! ((target instanceof KonanTarget.LINUX_ARM32_HFP ||
|
||||
target instanceof KonanTarget.LINUX_MIPS32 ||
|
||||
target instanceof KonanTarget.LINUX_MIPSEL32) && it.name == 'zlib.def') }
|
||||
.collect { new DefFile(it, substitution) }
|
||||
|
||||
@@ -31,9 +31,9 @@ class AppleConfigurablesImpl(
|
||||
|
||||
override val absoluteTargetSysRoot: String get() = when (xcodePartsProvider) {
|
||||
is XcodePartsProvider.Local -> when (target) {
|
||||
KonanTarget.MACBOOK -> xcodePartsProvider.xcode.macosxSdk
|
||||
KonanTarget.IPHONE -> xcodePartsProvider.xcode.iphoneosSdk
|
||||
KonanTarget.IPHONE_SIM -> xcodePartsProvider.xcode.iphonesimulatorSdk
|
||||
KonanTarget.MACOS_X64 -> xcodePartsProvider.xcode.macosxSdk
|
||||
KonanTarget.IOS_ARM64 -> xcodePartsProvider.xcode.iphoneosSdk
|
||||
KonanTarget.IOS_X64 -> xcodePartsProvider.xcode.iphonesimulatorSdk
|
||||
else -> error(target)
|
||||
}
|
||||
XcodePartsProvider.InternalServer -> absolute(sdkDependency)
|
||||
|
||||
@@ -27,9 +27,9 @@ class ClangArgs(private val configurables: Configurables) : Configurables by con
|
||||
val specificClangArgs: List<String>
|
||||
get() {
|
||||
val result = when (target) {
|
||||
KonanTarget.LINUX ->
|
||||
KonanTarget.LINUX_X64 ->
|
||||
listOf("--sysroot=$absoluteTargetSysRoot")
|
||||
KonanTarget.RASPBERRYPI ->
|
||||
KonanTarget.LINUX_ARM32_HFP ->
|
||||
listOf("-target", targetArg!!,
|
||||
"-mfpu=vfp", "-mfloat-abi=hard",
|
||||
"--sysroot=$absoluteTargetSysRoot",
|
||||
@@ -49,16 +49,16 @@ class ClangArgs(private val configurables: Configurables) : Configurables by con
|
||||
"-I$absoluteTargetSysRoot/usr/include/c++/4.9.4",
|
||||
"-I$absoluteTargetSysRoot/usr/include/c++/4.9.4/mipsel-unknown-linux-gnu")
|
||||
|
||||
KonanTarget.MINGW ->
|
||||
KonanTarget.MINGW_X64 ->
|
||||
listOf("-target", targetArg!!, "--sysroot=$absoluteTargetSysRoot", "-Xclang", "-flto-visibility-public-std")
|
||||
|
||||
KonanTarget.MACBOOK ->
|
||||
KonanTarget.MACOS_X64 ->
|
||||
listOf("--sysroot=$absoluteTargetSysRoot", "-mmacosx-version-min=10.11")
|
||||
|
||||
KonanTarget.IPHONE ->
|
||||
KonanTarget.IOS_ARM64 ->
|
||||
listOf("-stdlib=libc++", "-arch", "arm64", "-isysroot", absoluteTargetSysRoot, "-miphoneos-version-min=8.0.0")
|
||||
|
||||
KonanTarget.IPHONE_SIM ->
|
||||
KonanTarget.IOS_X64 ->
|
||||
listOf("-stdlib=libc++", "-isysroot", absoluteTargetSysRoot, "-miphoneos-version-min=8.0.0")
|
||||
|
||||
KonanTarget.ANDROID_ARM32 ->
|
||||
@@ -106,10 +106,10 @@ class ClangArgs(private val configurables: Configurables) : Configurables by con
|
||||
|
||||
val clangArgsSpecificForKonanSources
|
||||
get() = when (target) {
|
||||
KonanTarget.LINUX ->
|
||||
KonanTarget.LINUX_X64 ->
|
||||
listOf("-DUSE_GCC_UNWIND=1", "-DUSE_ELF_SYMBOLS=1", "-DELFSIZE=64")
|
||||
|
||||
KonanTarget.RASPBERRYPI ->
|
||||
KonanTarget.LINUX_ARM32_HFP ->
|
||||
listOf("-DUSE_GCC_UNWIND=1", "-DUSE_ELF_SYMBOLS=1", "-DELFSIZE=32")
|
||||
|
||||
KonanTarget.LINUX_MIPS32 ->
|
||||
@@ -118,16 +118,16 @@ class ClangArgs(private val configurables: Configurables) : Configurables by con
|
||||
KonanTarget.LINUX_MIPSEL32 ->
|
||||
listOf("-DUSE_GCC_UNWIND=1", "-DUSE_ELF_SYMBOLS=1", "-DELFSIZE=32")
|
||||
|
||||
KonanTarget.MINGW ->
|
||||
KonanTarget.MINGW_X64 ->
|
||||
listOf("-DUSE_GCC_UNWIND=1", "-DUSE_PE_COFF_SYMBOLS=1", "-DKONAN_WINDOWS=1", "-DKONAN_NO_MEMMEM=1")
|
||||
|
||||
KonanTarget.MACBOOK ->
|
||||
KonanTarget.MACOS_X64 ->
|
||||
listOf("-DKONAN_OSX=1", "-DKONAN_OBJC_INTEROP=1")
|
||||
|
||||
KonanTarget.IPHONE ->
|
||||
KonanTarget.IOS_ARM64 ->
|
||||
listOf("-DKONAN_OBJC_INTEROP=1")
|
||||
|
||||
KonanTarget.IPHONE_SIM ->
|
||||
KonanTarget.IOS_X64 ->
|
||||
listOf("-DKONAN_OBJC_INTEROP=1")
|
||||
|
||||
KonanTarget.ANDROID_ARM32 ->
|
||||
@@ -150,9 +150,9 @@ class ClangArgs(private val configurables: Configurables) : Configurables by con
|
||||
private val host = HostManager.host
|
||||
|
||||
private val binDir = when (host) {
|
||||
KonanTarget.LINUX -> "$absoluteTargetToolchain/bin"
|
||||
KonanTarget.MINGW -> "$absoluteTargetToolchain/bin"
|
||||
KonanTarget.MACBOOK -> "$absoluteTargetToolchain/usr/bin"
|
||||
KonanTarget.LINUX_X64 -> "$absoluteTargetToolchain/bin"
|
||||
KonanTarget.MINGW_X64 -> "$absoluteTargetToolchain/bin"
|
||||
KonanTarget.MACOS_X64 -> "$absoluteTargetToolchain/usr/bin"
|
||||
else -> throw TargetSupportException("Unexpected host platform")
|
||||
}
|
||||
|
||||
|
||||
@@ -38,15 +38,15 @@ class ZephyrConfigurablesImpl(target: KonanTarget, properties: Properties, baseD
|
||||
|
||||
|
||||
fun loadConfigurables(target: KonanTarget, properties: Properties, baseDir: String?) = when (target) {
|
||||
KonanTarget.LINUX, KonanTarget.RASPBERRYPI ->
|
||||
KonanTarget.LINUX_X64, KonanTarget.LINUX_ARM32_HFP ->
|
||||
LinuxConfigurablesImpl(target, properties, baseDir)
|
||||
KonanTarget.LINUX_MIPS32, KonanTarget.LINUX_MIPSEL32 ->
|
||||
LinuxMIPSConfigurablesImpl(target, properties, baseDir)
|
||||
KonanTarget.MACBOOK, KonanTarget.IPHONE, KonanTarget.IPHONE_SIM ->
|
||||
KonanTarget.MACOS_X64, KonanTarget.IOS_ARM64, KonanTarget.IOS_X64 ->
|
||||
AppleConfigurablesImpl(target, properties, baseDir)
|
||||
KonanTarget.ANDROID_ARM32, KonanTarget.ANDROID_ARM64 ->
|
||||
AndroidConfigurablesImpl(target, properties, baseDir)
|
||||
KonanTarget.MINGW ->
|
||||
KonanTarget.MINGW_X64 ->
|
||||
MingwConfigurablesImpl(target, properties, baseDir)
|
||||
KonanTarget.WASM32 ->
|
||||
WasmConfigurablesImpl(target, properties, baseDir)
|
||||
|
||||
@@ -39,17 +39,17 @@ enum class Architecture(val bitness: Int) {
|
||||
}
|
||||
|
||||
sealed class KonanTarget(override val name: String, val family: Family, val architecture: Architecture, val detailedName: String) : Named {
|
||||
object ANDROID_ARM32 : KonanTarget( "android_arm32", Family.ANDROID, Architecture.ARM32, "android_arm32")
|
||||
object ANDROID_ARM64 : KonanTarget( "android_arm64", Family.ANDROID, Architecture.ARM64, "android_arm64")
|
||||
object IPHONE : KonanTarget( "iphone", Family.IOS, Architecture.ARM64, "ios")
|
||||
object IPHONE_SIM : KonanTarget( "iphone_sim", Family.IOS, Architecture.X64, "ios_sim")
|
||||
object LINUX : KonanTarget( "linux", Family.LINUX, Architecture.X64, "linux")
|
||||
object MINGW : KonanTarget( "mingw", Family.WINDOWS, Architecture.X64, "mingw")
|
||||
object MACBOOK : KonanTarget( "macbook", Family.OSX, Architecture.X64, "osx")
|
||||
object RASPBERRYPI : KonanTarget( "raspberrypi", Family.LINUX, Architecture.ARM32, "raspberrypi")
|
||||
object LINUX_MIPS32 : KonanTarget( "linux_mips32", Family.LINUX, Architecture.MIPS32, "linux_mips32")
|
||||
object LINUX_MIPSEL32 : KonanTarget( "linux_mipsel32", Family.LINUX, Architecture.MIPSEL32, "linux_mipsel32")
|
||||
object WASM32 : KonanTarget( "wasm32", Family.WASM, Architecture.WASM32, "wasm32")
|
||||
object ANDROID_ARM32 : KonanTarget( "android_arm32", Family.ANDROID, Architecture.ARM32, "android_arm32")
|
||||
object ANDROID_ARM64 : KonanTarget( "android_arm64", Family.ANDROID, Architecture.ARM64, "android_arm64")
|
||||
object IOS_ARM64 : KonanTarget( "ios_arm64", Family.IOS, Architecture.ARM64, "ios")
|
||||
object IOS_X64 : KonanTarget( "ios_x64", Family.IOS, Architecture.X64, "ios_sim")
|
||||
object LINUX_X64 : KonanTarget( "linux_x64", Family.LINUX, Architecture.X64, "linux")
|
||||
object MINGW_X64 : KonanTarget( "mingw_x64", Family.WINDOWS, Architecture.X64, "mingw")
|
||||
object MACOS_X64 : KonanTarget( "macos_x64", Family.OSX, Architecture.X64, "osx")
|
||||
object LINUX_ARM32_HFP :KonanTarget( "linux_arm32_hfp", Family.LINUX, Architecture.ARM32, "raspberrypi")
|
||||
object LINUX_MIPS32 : KonanTarget( "linux_mips32", Family.LINUX, Architecture.MIPS32, "linux_mips32")
|
||||
object LINUX_MIPSEL32 : KonanTarget( "linux_mipsel32", Family.LINUX, Architecture.MIPSEL32, "linux_mipsel32")
|
||||
object WASM32 : KonanTarget( "wasm32", Family.WASM, Architecture.WASM32, "wasm32")
|
||||
|
||||
// Tunable targets
|
||||
class ZEPHYR(val subName: String, val genericName: String = "zephyr") : KonanTarget("${genericName}_$subName", Family.ZEPHYR, Architecture.ARM32, "${genericName}_$subName")
|
||||
@@ -96,7 +96,8 @@ private class TargetManagerImpl(val userRequest: String?, val hostManager: HostM
|
||||
override fun list() {
|
||||
hostManager.enabled.forEach {
|
||||
val isDefault = if (it == target) "(default)" else ""
|
||||
println(String.format("%1$-30s%2$-10s", "${it.visibleName}:", "$isDefault"))
|
||||
val aliasList = HostManager.listAliases(it.visibleName).joinToString(", ")
|
||||
println(String.format("%1$-30s%2$-10s%3\$s", "${it.visibleName}:", "$isDefault", aliasList))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +105,8 @@ private class TargetManagerImpl(val userRequest: String?, val hostManager: HostM
|
||||
return if (userRequest == null || userRequest == "host") {
|
||||
HostManager.host
|
||||
} else {
|
||||
hostManager.targets[hostManager.known(userRequest)]!!
|
||||
val resolvedAlias = HostManager.resolveAlias(userRequest)
|
||||
hostManager.targets[hostManager.known(resolvedAlias)]!!
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +119,7 @@ open class HostManager(protected val distribution: Distribution = Distribution()
|
||||
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, IPHONE, IPHONE_SIM, LINUX, MINGW, MACBOOK, RASPBERRYPI, LINUX_MIPS32, LINUX_MIPSEL32, WASM32)
|
||||
private val predefinedTargets = listOf(ANDROID_ARM32, ANDROID_ARM64, IOS_ARM64, IOS_X64, LINUX_X64, MINGW_X64, MACOS_X64, LINUX_ARM32_HFP, LINUX_MIPS32, LINUX_MIPSEL32, WASM32)
|
||||
|
||||
private val zephyrSubtargets = distribution.availableSubTarget("zephyr").map { ZEPHYR(it) }
|
||||
|
||||
@@ -132,7 +134,7 @@ open class HostManager(protected val distribution: Distribution = Distribution()
|
||||
fun toKonanTargets(names: Iterable<String>): List<KonanTarget> {
|
||||
return names.map {
|
||||
if (it == "host") HostManager.host
|
||||
else targets[known(it)]!!
|
||||
else targets[known(resolveAlias(it))]!!
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,30 +147,30 @@ open class HostManager(protected val distribution: Distribution = Distribution()
|
||||
|
||||
fun targetByName(name: String): KonanTarget {
|
||||
if (name == "host") return host
|
||||
val target = targets[name]
|
||||
val target = targets[resolveAlias(name)]
|
||||
if (target == null) throw TargetSupportException("Unknown target name: $name")
|
||||
return target
|
||||
}
|
||||
|
||||
val enabled: List<KonanTarget> by lazy {
|
||||
when (host) {
|
||||
KonanTarget.LINUX -> listOf(
|
||||
KonanTarget.LINUX,
|
||||
KonanTarget.RASPBERRYPI,
|
||||
KonanTarget.LINUX_X64 -> listOf(
|
||||
KonanTarget.LINUX_X64,
|
||||
KonanTarget.LINUX_ARM32_HFP,
|
||||
KonanTarget.LINUX_MIPS32,
|
||||
KonanTarget.LINUX_MIPSEL32,
|
||||
KonanTarget.ANDROID_ARM32,
|
||||
KonanTarget.ANDROID_ARM64,
|
||||
KonanTarget.WASM32
|
||||
) + zephyrSubtargets
|
||||
KonanTarget.MINGW -> listOf(
|
||||
KonanTarget.MINGW,
|
||||
KonanTarget.MINGW_X64 -> listOf(
|
||||
KonanTarget.MINGW_X64,
|
||||
KonanTarget.WASM32
|
||||
) + zephyrSubtargets
|
||||
KonanTarget.MACBOOK -> listOf(
|
||||
KonanTarget.MACBOOK,
|
||||
KonanTarget.IPHONE,
|
||||
KonanTarget.IPHONE_SIM,
|
||||
KonanTarget.MACOS_X64 -> listOf(
|
||||
KonanTarget.MACOS_X64,
|
||||
KonanTarget.IOS_ARM64,
|
||||
KonanTarget.IOS_X64,
|
||||
KonanTarget.ANDROID_ARM32,
|
||||
KonanTarget.ANDROID_ARM64,
|
||||
KonanTarget.WASM32
|
||||
@@ -197,19 +199,11 @@ open class HostManager(protected val distribution: Distribution = Distribution()
|
||||
return if (hostOs == "osx") "macos" else hostOs
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun longerSystemName(): String = when (host) {
|
||||
KonanTarget.MACBOOK -> "darwin-macos"
|
||||
KonanTarget.LINUX -> "linux-x86-64"
|
||||
KonanTarget.MINGW -> "windows-x86-64"
|
||||
else -> throw TargetSupportException("Unknown host: $host")
|
||||
}
|
||||
|
||||
val jniHostPlatformIncludeDir: String
|
||||
get() = when(host) {
|
||||
KonanTarget.MACBOOK -> "darwin"
|
||||
KonanTarget.LINUX -> "linux"
|
||||
KonanTarget.MINGW ->"win32"
|
||||
KonanTarget.MACOS_X64 -> "darwin"
|
||||
KonanTarget.LINUX_X64 -> "linux"
|
||||
KonanTarget.MINGW_X64 ->"win32"
|
||||
else -> throw TargetSupportException("Unknown host: $host.")
|
||||
}
|
||||
|
||||
@@ -224,15 +218,15 @@ open class HostManager(protected val distribution: Distribution = Distribution()
|
||||
}
|
||||
|
||||
val host: KonanTarget = when (host_os()) {
|
||||
"osx" -> KonanTarget.MACBOOK
|
||||
"linux" -> KonanTarget.LINUX
|
||||
"windows" -> KonanTarget.MINGW
|
||||
"osx" -> KonanTarget.MACOS_X64
|
||||
"linux" -> KonanTarget.LINUX_X64
|
||||
"windows" -> KonanTarget.MINGW_X64
|
||||
else -> throw TargetSupportException("Unknown host target: ${host_os()} ${host_arch()}")
|
||||
}
|
||||
|
||||
val hostIsMac = (host == KonanTarget.MACBOOK)
|
||||
val hostIsLinux = (host == KonanTarget.LINUX)
|
||||
val hostIsMingw = (host == KonanTarget.MINGW)
|
||||
val hostIsMac = (host == KonanTarget.MACOS_X64)
|
||||
val hostIsLinux = (host == KonanTarget.LINUX_X64)
|
||||
val hostIsMingw = (host == KonanTarget.MINGW_X64)
|
||||
|
||||
val hostSuffix get() = host.detailedName
|
||||
@JvmStatic
|
||||
@@ -240,6 +234,30 @@ open class HostManager(protected val distribution: Distribution = Distribution()
|
||||
|
||||
val knownTargetTemplates = listOf("zephyr")
|
||||
|
||||
private val targetAliasResolutions = mapOf(
|
||||
"linux" to "linux_x64",
|
||||
"macbook" to "macos_x64",
|
||||
"macos" to "macos_x64",
|
||||
"imac" to "macos_x64",
|
||||
"raspberrypi" to "linux_arm32_hfp",
|
||||
"iphone" to "ios_arm64",
|
||||
"ipad" to "ios_arm64",
|
||||
"ios" to "ios_arm64",
|
||||
"iphone_sim" to "ios_x64",
|
||||
"mingw" to "mingw_x64"
|
||||
)
|
||||
|
||||
private val targetAliases: Map<String, List<String>> by lazy {
|
||||
val result = mutableMapOf<String, MutableList<String>>()
|
||||
targetAliasResolutions.entries.forEach {
|
||||
result.getOrPut(it.value, { mutableListOf() } ).add(it.key)
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
fun resolveAlias(request: String): String = targetAliasResolutions[request] ?: request
|
||||
|
||||
fun listAliases(target: String): List<String> = targetAliases[target] ?: emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@ abstract class LinkerFlags(val configurables: Configurables)
|
||||
protected val llvmLib = "${configurables.absoluteLlvmHome}/lib"
|
||||
|
||||
private val libLTODir = when (HostManager.host) {
|
||||
KonanTarget.MACBOOK, KonanTarget.LINUX -> llvmLib
|
||||
KonanTarget.MINGW -> llvmBin
|
||||
KonanTarget.MACOS_X64, KonanTarget.LINUX_X64 -> llvmLib
|
||||
KonanTarget.MINGW_X64 -> llvmBin
|
||||
else -> error("Don't know libLTO location for this platform.")
|
||||
}
|
||||
|
||||
@@ -306,15 +306,15 @@ open class ZephyrLinker(targetProperties: ZephyrConfigurables)
|
||||
|
||||
fun linker(configurables: Configurables): LinkerFlags =
|
||||
when (configurables.target) {
|
||||
KonanTarget.LINUX, KonanTarget.RASPBERRYPI ->
|
||||
KonanTarget.LINUX_X64, KonanTarget.LINUX_ARM32_HFP ->
|
||||
LinuxBasedLinker(configurables as LinuxConfigurables)
|
||||
KonanTarget.LINUX_MIPS32, KonanTarget.LINUX_MIPSEL32 ->
|
||||
LinuxBasedLinker(configurables as LinuxMIPSConfigurables)
|
||||
KonanTarget.MACBOOK, KonanTarget.IPHONE, KonanTarget.IPHONE_SIM ->
|
||||
KonanTarget.MACOS_X64, KonanTarget.IOS_ARM64, KonanTarget.IOS_X64 ->
|
||||
MacOSBasedLinker(configurables as AppleConfigurables)
|
||||
KonanTarget.ANDROID_ARM32, KonanTarget.ANDROID_ARM64 ->
|
||||
AndroidLinker(configurables as AndroidConfigurables)
|
||||
KonanTarget.MINGW ->
|
||||
KonanTarget.MINGW_X64 ->
|
||||
MingwLinker(configurables as MingwConfigurables)
|
||||
KonanTarget.WASM32 ->
|
||||
WasmLinker(configurables as WasmConfigurables)
|
||||
|
||||
+27
-19
@@ -49,19 +49,24 @@ abstract class KonanBuildingConfig<T: KonanBuildingTask>(private val name_: Stri
|
||||
get() = project.hostManager.toKonanTargets(targets).distinct()
|
||||
|
||||
init {
|
||||
for (target in konanTargets) {
|
||||
if (!project.hostManager.isEnabled(target)) {
|
||||
project.logger.warn("The target is not enabled on the current host: ${target.visibleName}")
|
||||
for (targetName in targets.distinct()) {
|
||||
val konanTarget = project.hostManager.targetByName(targetName)
|
||||
|
||||
if (!project.hostManager.isEnabled(konanTarget)) {
|
||||
project.logger.warn("The target is not enabled on the current host: $targetName")
|
||||
continue
|
||||
}
|
||||
if (!targetIsSupported(target)) {
|
||||
project.logger.warn("The target ${target.visibleName} is not supported by the artifact $name")
|
||||
if (!targetIsSupported(konanTarget)) {
|
||||
project.logger.warn("The target ${targetName} is not supported by the artifact $name")
|
||||
continue
|
||||
}
|
||||
super.add(createTask(target))
|
||||
if (this[konanTarget] == null) super.add(createTask(konanTarget))
|
||||
|
||||
if (targetName != konanTarget.visibleName) {
|
||||
createTargetAliasTaskIfDeclared(targetName)
|
||||
}
|
||||
}
|
||||
aggregateBuildTask = createAggregateTask()
|
||||
createHostTaskIfDeclared()
|
||||
}
|
||||
|
||||
protected open fun generateTaskName(target: KonanTarget) =
|
||||
@@ -70,12 +75,12 @@ abstract class KonanBuildingConfig<T: KonanBuildingTask>(private val name_: Stri
|
||||
protected open fun generateAggregateTaskName() =
|
||||
"compileKonan${name.capitalize()}"
|
||||
|
||||
protected open fun generateHostTaskName() =
|
||||
"compileKonan${name.capitalize()}Host"
|
||||
protected open fun generateTargetAliasTaskName(targetName: String) =
|
||||
"compileKonan${name.capitalize()}${targetName.capitalize()}"
|
||||
|
||||
protected abstract fun generateTaskDescription(task: T): String
|
||||
protected abstract fun generateAggregateTaskDescription(task: Task): String
|
||||
protected abstract fun generateHostTaskDescription(task: Task, hostTarget: KonanTarget): String
|
||||
protected abstract fun generateTargetAliasTaskDescription(task: Task, targetName: String): String
|
||||
|
||||
protected abstract val defaultBaseDir: File
|
||||
|
||||
@@ -102,19 +107,22 @@ abstract class KonanBuildingConfig<T: KonanBuildingTask>(private val name_: Stri
|
||||
this.filter {
|
||||
project.targetIsRequested(it.konanTarget)
|
||||
}.forEach {
|
||||
task.dependsOn(it)
|
||||
}
|
||||
task.dependsOn(it)
|
||||
}
|
||||
project.compileAllTask.dependsOn(task)
|
||||
}
|
||||
|
||||
protected fun createHostTaskIfDeclared(): Task? =
|
||||
this[HostManager.host]?.let { hostBuild ->
|
||||
project.tasks.create(generateHostTaskName()) {
|
||||
it.group = BasePlugin.BUILD_GROUP
|
||||
it.description = generateHostTaskDescription(it, hostBuild.konanTarget)
|
||||
it.dependsOn(hostBuild)
|
||||
}
|
||||
protected fun createTargetAliasTaskIfDeclared(targetName: String): Task? {
|
||||
val canonicalTarget = project.hostManager.targetByName(targetName)
|
||||
|
||||
return this[canonicalTarget]?.let { canonicalBuild ->
|
||||
project.tasks.create(generateTargetAliasTaskName(targetName)) {
|
||||
it.group = BasePlugin.BUILD_GROUP
|
||||
it.description = generateTargetAliasTaskDescription(it, targetName)
|
||||
it.dependsOn(canonicalBuild)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal operator fun get(target: KonanTarget) = targetToTask[target]
|
||||
|
||||
|
||||
+5
-5
@@ -40,8 +40,8 @@ abstract class KonanCompileConfig<T: KonanCompileTask>(name: String,
|
||||
override fun generateAggregateTaskDescription(task: Task) =
|
||||
"Build the Kotlin/Native $typeForDescription '${task.name}' for all supported and declared targets"
|
||||
|
||||
override fun generateHostTaskDescription(task: Task, hostTarget: KonanTarget) =
|
||||
"Build the Kotlin/Native $typeForDescription '${task.name}' for current host"
|
||||
override fun generateTargetAliasTaskDescription(task: Task, targetName: String) =
|
||||
"Build the Kotlin/Native $typeForDescription '${task.name}' for target '$targetName'"
|
||||
|
||||
override fun srcDir(dir: Any) = forEach { it.srcDir(dir) }
|
||||
override fun srcFiles(vararg files: Any) = forEach { it.srcFiles(*files) }
|
||||
@@ -123,7 +123,7 @@ open class KonanFramework(name: String,
|
||||
get() = project.konanBinBaseDir
|
||||
|
||||
override fun targetIsSupported(target: KonanTarget): Boolean =
|
||||
target == MACBOOK || target == IPHONE || target == IPHONE_SIM
|
||||
target == MACOS_X64 || target == IOS_ARM64 || target == IOS_X64
|
||||
}
|
||||
|
||||
open class KonanLibrary(name: String,
|
||||
@@ -162,8 +162,8 @@ open class KonanBitcode(name: String,
|
||||
override fun generateAggregateTaskDescription(task: Task) =
|
||||
"Generates bitcode for the artifact '${task.name}' for all supported and declared targets'"
|
||||
|
||||
override fun generateHostTaskDescription(task: Task, hostTarget: KonanTarget) =
|
||||
"Generates bitcode for the artifact '${task.name}' for current host"
|
||||
override fun generateTargetAliasTaskDescription(task: Task, targetName: String) =
|
||||
"Generates bitcode for the artifact '${task.name}' for '$targetName'"
|
||||
|
||||
override val defaultBaseDir: File
|
||||
get() = project.konanBitcodeBaseDir
|
||||
|
||||
+2
-2
@@ -42,8 +42,8 @@ open class KonanInteropLibrary(name: String,
|
||||
override fun generateAggregateTaskDescription(task: Task) =
|
||||
"Build the Kotlin/Native interop library '${task.name}' for all supported and declared targets'"
|
||||
|
||||
override fun generateHostTaskDescription(task: Task, hostTarget: KonanTarget) =
|
||||
"Build the Kotlin/Native interop library '${task.name}' for current host"
|
||||
override fun generateTargetAliasTaskDescription(task: Task, targetName: String) =
|
||||
"Build the Kotlin/Native interop library '${task.name}' for '$targetName'"
|
||||
|
||||
override val defaultBaseDir: File
|
||||
get() = project.konanLibsBaseDir
|
||||
|
||||
+3
-2
@@ -19,7 +19,8 @@ package org.jetbrains.kotlin.gradle.plugin
|
||||
import org.gradle.api.Named
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.jetbrains.kotlin.gradle.plugin.tasks.host
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.konan.util.DependencyProcessor
|
||||
|
||||
internal interface KonanToolRunner: Named {
|
||||
@@ -81,7 +82,7 @@ internal class KonanInteropRunner(project: Project)
|
||||
: KonanCliRunner("cinterop", "Kotlin/Native cinterop tool", project)
|
||||
{
|
||||
init {
|
||||
if (project.host == "mingw") {
|
||||
if (HostManager.host == KonanTarget.MINGW_X64) {
|
||||
//TODO: Oh-ho-ho fix it in more convinient way.
|
||||
environment.put("PATH", DependencyProcessor.defaultDependenciesRoot.absolutePath +
|
||||
"\\msys2-mingw-w64-x86_64-gcc-7.2.0-clang-llvm-5.0.0-windows-x86-64" +
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ class TaskSpecification extends BaseKonanSpecification {
|
||||
"includeDirs" | ""
|
||||
}
|
||||
|
||||
@Requires({ HostManager.host instanceof KonanTarget.MACBOOK })
|
||||
@Requires({ HostManager.host instanceof KonanTarget.MACOS_X64 })
|
||||
def 'Plugin should create framework tasks only for Apple targets'() {
|
||||
when:
|
||||
def project = KonanProject.createEmpty(projectDirectory) { KonanProject it ->
|
||||
|
||||
Reference in New Issue
Block a user