Nikolay Igotti
2019-11-07 10:13:11 +03:00
committed by GitHub
parent 7e52c96f2f
commit ff05a7d85a
2 changed files with 27 additions and 19 deletions
+3 -1
View File
@@ -360,7 +360,8 @@ task distDef(type: Copy) {
destinationDir distDir destinationDir distDir
from(project("platformLibs").file("src/platform")) { from(project("platformLibs").file("src/platform")) {
into('klib/platformDef') into('konan/platformDef')
include '**/*.def'
} }
} }
@@ -465,6 +466,7 @@ task crossDist {
} }
task bundle(type: (isWindows()) ? Zip : Tar) { task bundle(type: (isWindows()) ? Zip : Tar) {
dependsOn("distDef")
if (isMac()) { if (isMac()) {
dependsOn('bundleRestricted') dependsOn('bundleRestricted')
} }
@@ -34,14 +34,6 @@ fun generatePlatformLibraries(args: Array<String>) {
} }
private class DefFile(val name: String, val depends: MutableList<DefFile>) { private class DefFile(val name: String, val depends: MutableList<DefFile>) {
override fun hashCode(): Int {
return name.hashCode()
}
override fun equals(other: Any?): Boolean {
return other is DefFile && other.name == name
}
override fun toString(): String = "$name: [${depends.joinToString(separator = ", ") { it.name }}]" override fun toString(): String = "$name: [${depends.joinToString(separator = ", ") { it.name }}]"
} }
@@ -83,13 +75,16 @@ private fun generatePlatformLibraries(target: String, inputDirectory: File, outp
"-no-default-libs", "-no-endorsed-libs", "-Xpurge-user-libs", "-no-default-libs", "-no-endorsed-libs", "-Xpurge-user-libs",
*def.depends.flatMap { listOf("-l", "$outputDirectory/${it.name}") }.toTypedArray()) *def.depends.flatMap { listOf("-l", "$outputDirectory/${it.name}") }.toTypedArray())
println("Processing ${def.name}...") println("Processing ${def.name}...")
invokeInterop("native", args)?.let { K2Native.mainNoExit(it) } try {
org.jetbrains.kotlin.cli.klib.main(arrayOf("install", outKlib, invokeInterop("native", args)?.let { K2Native.mainNoExit(it) }
"-target", target, org.jetbrains.kotlin.cli.klib.main(arrayOf("install", outKlib,
"-repository", "${outputDirectory.absolutePath}" "-target", target,
)) "-repository", "${outputDirectory.absolutePath}"
if (!saveTemps) { ))
File("$outputDirectory/build-${def.name}").deleteRecursively() } finally {
if (!saveTemps) {
File("$outputDirectory/build-${def.name}").deleteRecursively()
}
} }
} }
println("generate platform libraries from $inputDirectory to $outputDirectory for $target") println("generate platform libraries from $inputDirectory to $outputDirectory for $target")
@@ -116,7 +111,7 @@ private fun generatePlatformLibraries(target: String, inputDirectory: File, outp
val numCores = Runtime.getRuntime().availableProcessors() val numCores = Runtime.getRuntime().availableProcessors()
val executorPool = ThreadPoolExecutor(numCores, numCores, val executorPool = ThreadPoolExecutor(numCores, numCores,
10, TimeUnit.SECONDS, ArrayBlockingQueue(1000), 10, TimeUnit.SECONDS, ArrayBlockingQueue(1000),
Executors.defaultThreadFactory(), RejectedExecutionHandler { r, executor -> Executors.defaultThreadFactory(), RejectedExecutionHandler { r, _ ->
println("Execution rejected: $r") println("Execution rejected: $r")
throw Error("Must not happen!") throw Error("Must not happen!")
}) })
@@ -128,9 +123,20 @@ private fun generatePlatformLibraries(target: String, inputDirectory: File, outp
while (def.depends.any { built[it] == 0 }) { while (def.depends.any { built[it] == 0 }) {
Thread.sleep(100) Thread.sleep(100)
} }
buildKlib(def) try {
built[def] = 1 if (def.depends.any { built[it] == 2 }) {
throw Error("There are failed dependencies for $def")
}
buildKlib(def)
built[def] = 1
} catch(e: Throwable) {
built[def] = 2
throw e
}
} }
} }
executorPool.shutdown() executorPool.shutdown()
if (!saveTemps) {
File("$outputDirectory/clangModulesCache").deleteRecursively()
}
} }