[build][platform libs] order build of libraries in topological order

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