[build][platform libs] order build of libraries in topological order
This commit is contained in:
committed by
Vasily Levchenko
parent
f6c040ea3d
commit
910e79a482
+1
-1
@@ -63,7 +63,7 @@ class LibraryReaderImpl(var libraryFile: File, val currentAbiVersion: Int,
|
|||||||
get() = (realFiles.includedDir.listFiles).map{it.absolutePath}
|
get() = (realFiles.includedDir.listFiles).map{it.absolutePath}
|
||||||
|
|
||||||
override val linkerOpts: List<String>
|
override val linkerOpts: List<String>
|
||||||
get() = manifestProperties.propertyList("linkerOpts", target!!.targetSuffix)
|
get() = manifestProperties.propertyList("linkerOpts", target!!.detailedName)
|
||||||
|
|
||||||
val moduleHeaderData: ByteArray by lazy {
|
val moduleHeaderData: ByteArray by lazy {
|
||||||
reader.loadSerializedModule()
|
reader.loadSerializedModule()
|
||||||
|
|||||||
+18
-12
@@ -16,6 +16,7 @@
|
|||||||
import groovy.io.FileType
|
import groovy.io.FileType
|
||||||
import org.jetbrains.kotlin.konan.target.*
|
import org.jetbrains.kotlin.konan.target.*
|
||||||
import org.jetbrains.kotlin.konan.properties.*
|
import org.jetbrains.kotlin.konan.properties.*
|
||||||
|
import org.jetbrains.kotlin.konan.util.*
|
||||||
|
|
||||||
defaultTasks 'clean', 'dist'
|
defaultTasks 'clean', 'dist'
|
||||||
|
|
||||||
@@ -267,19 +268,20 @@ targetList.each { target ->
|
|||||||
|
|
||||||
targetDefFiles(target).forEach{
|
targetDefFiles(target).forEach{
|
||||||
defFile ->
|
defFile ->
|
||||||
def taskName = defFileToTaskName(target, defFile)
|
def taskName = defFileToTaskName(target, defFile.name)
|
||||||
def suffix = null
|
def suffix = null
|
||||||
if (new PlatformInfo().isWindows())
|
if (new PlatformInfo().isWindows())
|
||||||
suffix = 'bat'
|
suffix = 'bat'
|
||||||
task(taskName, type:GradleBuild) {
|
task(taskName, type:GradleBuild) {
|
||||||
dependsOn ':tools:kotlin-native-gradle-plugin:jar'
|
dependsOn ':tools:kotlin-native-gradle-plugin:jar'
|
||||||
|
dependsOn defFile.config.depends.collect{defFileToTaskName(target, it)}
|
||||||
tasks = ['clean', 'klibInstall']
|
tasks = ['clean', 'klibInstall']
|
||||||
buildFile project('klib').file('platform.gradle')
|
buildFile project('klib').file('platform.gradle')
|
||||||
dir project(':klib').projectDir
|
dir project(':klib').projectDir
|
||||||
startParameter.projectProperties = [
|
startParameter.projectProperties = [
|
||||||
'kotlin_version' : kotlin_version,
|
'kotlin_version' : kotlin_version,
|
||||||
'name' : defToLibName(defFile),
|
'name' : defFile.name,
|
||||||
'defFile' : defFile.absolutePath,
|
'defFile' : defFile.file.absolutePath,
|
||||||
'konan.home' : project.file('dist'),
|
'konan.home' : project.file('dist'),
|
||||||
'target' : target,
|
'target' : target,
|
||||||
'suffix' : suffix
|
'suffix' : suffix
|
||||||
@@ -288,27 +290,31 @@ targetList.each { target ->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<File> targetDefFiles(String target) {
|
private ArrayList<DefFile> targetDefFiles(String target) {
|
||||||
def platform = targetToPlatform(target)
|
def platform = targetToPlatform(target)
|
||||||
project(':klib').file("src/platform/$platform").listFiles().findAll { it.name.endsWith(".def") }
|
def substitution = ['arch': target,
|
||||||
|
'os' : targetToOs(target)]
|
||||||
|
project(':klib').file("src/platform/$platform")
|
||||||
|
.listFiles()
|
||||||
|
.findAll { it.name.endsWith(".def") }
|
||||||
|
.collect { new DefFile(it, substitution) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private String targetToPlatform(String target) {
|
private String targetToPlatform(String target) {
|
||||||
new TargetManager(target).target.platform.name().toLowerCase()
|
new TargetManager(target).target.family.name().toLowerCase()
|
||||||
}
|
}
|
||||||
|
|
||||||
private String defFileToTaskName(String target, File defFile) {
|
private String targetToOs(String target) {
|
||||||
def libname = defToLibName(defFile)
|
new TargetManager(target).target.detailedName.toLowerCase()
|
||||||
return "$target-$libname".toString()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String defToLibName(File defFile) {
|
private String defFileToTaskName(String target, String name) {
|
||||||
defFile.name.split('\\.').dropRight(1).join('.')
|
return "$target-$name".toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
task distPlatformLibs {
|
task distPlatformLibs {
|
||||||
def target = TargetManager.host.name().toLowerCase()
|
def target = TargetManager.host.name().toLowerCase()
|
||||||
dependsOn targetDefFiles(target).collect {defFileToTaskName(target, it)}
|
dependsOn targetDefFiles(target).collect {defFileToTaskName(target, it.name)}
|
||||||
}
|
}
|
||||||
|
|
||||||
task dist {
|
task dist {
|
||||||
|
|||||||
@@ -16,49 +16,37 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.konan.target
|
package org.jetbrains.kotlin.konan.target
|
||||||
|
|
||||||
enum class Platform {
|
enum class Family(name:String, val exeSuffix:String) {
|
||||||
OSX,
|
OSX("osx", "kexe"),
|
||||||
LINUX,
|
LINUX("linux", "kexe"),
|
||||||
WINDOWS,
|
WINDOWS("windows", "exe"),
|
||||||
ANDROID,
|
ANDROID("android", "so"),
|
||||||
WASM
|
WASM("wasm", "wasm")
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class KonanTarget(val targetSuffix: String, val programSuffix: String, var enabled: Boolean = false) {
|
|
||||||
ANDROID_ARM32("android_arm32", "so"),
|
enum class KonanTarget(val family: Family, val detailedName: String, var enabled: Boolean = false) {
|
||||||
ANDROID_ARM64("android_arm64", "so"),
|
ANDROID_ARM32(Family.ANDROID, "android_arm32"),
|
||||||
IPHONE("ios", "kexe"),
|
ANDROID_ARM64(Family.ANDROID, "android_arm64"),
|
||||||
IPHONE_SIM("ios_sim", "kexe"),
|
IPHONE(Family.OSX, "ios"),
|
||||||
LINUX("linux", "kexe"),
|
IPHONE_SIM(Family.OSX, "ios_sim"),
|
||||||
MINGW("mingw", "exe"),
|
LINUX(Family.LINUX, "linux"),
|
||||||
MACBOOK("osx", "kexe"),
|
MINGW(Family.WINDOWS, "mingw"),
|
||||||
RASPBERRYPI("raspberrypi", "kexe"),
|
MACBOOK(Family.OSX, "osx"),
|
||||||
LINUX_MIPS32("linux_mips32", "kexe"),
|
RASPBERRYPI(Family.LINUX, "raspberrypi"),
|
||||||
LINUX_MIPSEL32("linux_mipsel32", "kexe"),
|
LINUX_MIPS32(Family.LINUX, "linux_mips32"),
|
||||||
WASM32("wasm32", "wasm");
|
LINUX_MIPSEL32(Family.LINUX, "linux_mipsel32"),
|
||||||
|
WASM32(Family.WASM, "wasm32");
|
||||||
|
|
||||||
val userName get() = name.toLowerCase()
|
val userName get() = name.toLowerCase()
|
||||||
val platform get() = when (this) {
|
|
||||||
ANDROID_ARM32 -> Platform.ANDROID
|
|
||||||
ANDROID_ARM64 -> Platform.ANDROID
|
|
||||||
IPHONE -> Platform.OSX
|
|
||||||
IPHONE_SIM -> Platform.OSX
|
|
||||||
MACBOOK -> Platform.OSX
|
|
||||||
RASPBERRYPI -> Platform.LINUX
|
|
||||||
LINUX -> Platform.LINUX
|
|
||||||
LINUX_MIPS32 -> Platform.LINUX
|
|
||||||
LINUX_MIPSEL32 -> Platform.LINUX
|
|
||||||
MINGW -> Platform.WINDOWS
|
|
||||||
WASM32 -> Platform.WASM
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hostTargetSuffix(host: KonanTarget, target: KonanTarget) =
|
fun hostTargetSuffix(host: KonanTarget, target: KonanTarget) =
|
||||||
if (target == host) host.targetSuffix else "${host.targetSuffix}-${target.targetSuffix}"
|
if (target == host) host.detailedName else "${host.detailedName}-${target.detailedName}"
|
||||||
|
|
||||||
enum class CompilerOutputKind {
|
enum class CompilerOutputKind {
|
||||||
PROGRAM {
|
PROGRAM {
|
||||||
override fun suffix(target: KonanTarget?) = ".${target!!.programSuffix}"
|
override fun suffix(target: KonanTarget?) = ".${target!!.family.exeSuffix}"
|
||||||
},
|
},
|
||||||
LIBRARY {
|
LIBRARY {
|
||||||
override fun suffix(target: KonanTarget?) = ".klib"
|
override fun suffix(target: KonanTarget?) = ".klib"
|
||||||
@@ -102,9 +90,7 @@ class TargetManager(val userRequest: String? = null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val hostTargetSuffix get() = hostTargetSuffix(host, target)
|
val hostTargetSuffix get() = hostTargetSuffix(host, target)
|
||||||
val targetSuffix get() = target.targetSuffix
|
val targetSuffix get() = target.detailedName
|
||||||
|
|
||||||
val programSuffix get() = CompilerOutputKind.PROGRAM.suffix(target)
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
@@ -157,7 +143,7 @@ class TargetManager(val userRequest: String? = null) {
|
|||||||
else -> throw TargetSupportException("Unknown host target: ${host_os()} ${host_arch()}")
|
else -> throw TargetSupportException("Unknown host target: ${host_os()} ${host_arch()}")
|
||||||
}
|
}
|
||||||
|
|
||||||
val hostSuffix get() = host.targetSuffix
|
val hostSuffix get() = host.detailedName
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
val hostName get() = host.name.toLowerCase()
|
val hostName get() = host.name.toLowerCase()
|
||||||
|
|
||||||
|
|||||||
@@ -19,16 +19,16 @@ package org.jetbrains.kotlin.konan.properties
|
|||||||
import org.jetbrains.kotlin.konan.target.*
|
import org.jetbrains.kotlin.konan.target.*
|
||||||
|
|
||||||
fun Properties.hostString(name: String): String?
|
fun Properties.hostString(name: String): String?
|
||||||
= this.propertyString(name, TargetManager.host.targetSuffix)
|
= this.propertyString(name, TargetManager.host.detailedName)
|
||||||
|
|
||||||
fun Properties.hostList(name: String): List<String>
|
fun Properties.hostList(name: String): List<String>
|
||||||
= this.propertyList(name, TargetManager.host.targetSuffix)
|
= this.propertyList(name, TargetManager.host.detailedName)
|
||||||
|
|
||||||
fun Properties.targetString(name: String, target: KonanTarget): String?
|
fun Properties.targetString(name: String, target: KonanTarget): String?
|
||||||
= this.propertyString(name, target.targetSuffix)
|
= this.propertyString(name, target.detailedName)
|
||||||
|
|
||||||
fun Properties.targetList(name: String, target: KonanTarget): List<String>
|
fun Properties.targetList(name: String, target: KonanTarget): List<String>
|
||||||
= this.propertyList(name, target.targetSuffix)
|
= this.propertyList(name, target.detailedName)
|
||||||
|
|
||||||
fun Properties.hostTargetString(name: String, target: KonanTarget): String?
|
fun Properties.hostTargetString(name: String, target: KonanTarget): String?
|
||||||
= this.propertyString(name, hostTargetSuffix(TargetManager.host, target))
|
= this.propertyString(name, hostTargetSuffix(TargetManager.host, target))
|
||||||
|
|||||||
Reference in New Issue
Block a user