tools: Add dependecy download helpers
This patch adds 2 helpers to download dependencies for compiler and stub generator during their execution. They take list of external dependencies as a parameter and directory where they must be located. Helpers check if these dependencies exist in the given directory and download not existing ones.
This commit is contained in:
@@ -16,17 +16,15 @@ import kotlin.reflect.KFunction
|
||||
|
||||
private fun maybeExecuteHelper(configuration: CompilerConfiguration) {
|
||||
try {
|
||||
val kClass = Class.forName("org.jetbrains.kotlin.konan.Helper0").kotlin
|
||||
val kClass = Class.forName("org.jetbrains.kotlin.konan.CompilerHelper0").kotlin
|
||||
val ctor = kClass.constructors.single() as KFunction<Runnable>
|
||||
val distribution = Distribution(configuration)
|
||||
val target = TargetManager(configuration)
|
||||
val result = ctor.call(
|
||||
distribution.konanHome, TargetManager.host, target.current)
|
||||
val result = ctor.call(distribution)
|
||||
result.run()
|
||||
} catch (notFound: ClassNotFoundException) {
|
||||
// Just ignore, no helper.
|
||||
} catch (e: Throwable) {
|
||||
println(e.toString())
|
||||
throw IllegalStateException("Cannot download dependencies.", e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-1
@@ -35,7 +35,13 @@ class Distribution(val config: CompilerConfiguration) {
|
||||
|
||||
val llvmHome = "$dependencies/${properties.propertyString("llvmHome.$suffix")}"
|
||||
val sysRoot = "$dependencies/${properties.propertyString("sysRoot.$suffix")}"
|
||||
val libGcc = "$dependencies/${properties.propertyString("libGcc.$suffix")}"
|
||||
val libGcc = "$dependencies/${properties.propertyString("libGcc.$suffix")}"
|
||||
|
||||
val targetSysRoot = if (properties.hasProperty("targetSysRoot.$suffix")) {
|
||||
"$dependencies/${properties.propertyString("targetSysRoot.$suffix")}"
|
||||
} else {
|
||||
sysRoot
|
||||
}
|
||||
|
||||
val llvmBin = "$llvmHome/bin"
|
||||
val llvmLib = "$llvmHome/lib"
|
||||
|
||||
+17
-5
@@ -4,12 +4,24 @@
|
||||
//
|
||||
package org.jetbrains.kotlin.konan
|
||||
|
||||
import org.jetbrains.kotlin.backend.konan.KonanTarget
|
||||
import org.jetbrains.kotlin.backend.konan.Distribution
|
||||
import org.jetbrains.kotlin.backend.konan.TargetManager
|
||||
|
||||
// Name it Helper0 so that it get loaded.
|
||||
class Helper0Disabled(
|
||||
val konanHome: String, val host: KonanTarget, val target: KonanTarget) : Runnable {
|
||||
// Name it CompilerHelper0 so that it get loaded.
|
||||
class CompilerHelper0Disabled(val distribution: Distribution) : Runnable {
|
||||
override fun run() {
|
||||
println("Running helper with $konanHome $host $target")
|
||||
println("Running helper with ${distribution.konanHome} ${distribution.target} ${TargetManager.host}")
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Example startup helper for Kotlin N stub generator. Compile to JAR and add it to
|
||||
// Kotlin N classpath - it will get loaded and executed automatically.
|
||||
//
|
||||
|
||||
// Name it InteropHelper0 so that it get loaded.
|
||||
class InteropHelper0Disabled(val dependenciesRoot: String, val dependencies: List<String>) : Runnable {
|
||||
override fun run() {
|
||||
println("Running helper with $dependenciesRoot $dependencies")
|
||||
}
|
||||
}
|
||||
+3
@@ -15,10 +15,13 @@ public class KonanProperties(val propertyFile: String) {
|
||||
}
|
||||
|
||||
fun propertyString(key: String): String? = properties.getProperty(key)
|
||||
fun propertyString(key: String, default: String) : String = properties.getProperty(key, default)
|
||||
|
||||
fun propertyList(key: String): List<String> {
|
||||
val value = properties.getProperty(key)
|
||||
return value?.split(' ') ?: listOf<String>()
|
||||
}
|
||||
|
||||
fun hasProperty(key: String): Boolean = properties.getProperty(key) != null
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
// TODO: Do we need a $variable substitution mechanism here?
|
||||
llvmVersion = 3.9.0
|
||||
dependenciesUrl = https://jetbrains.bintray.com/kotlin-native-dependencies
|
||||
|
||||
// macbook
|
||||
arch.osx = x86_64
|
||||
|
||||
@@ -25,8 +25,8 @@ dependencies {
|
||||
}
|
||||
}
|
||||
|
||||
def testOutputRoot = rootProject.file("test.output").absolutePath
|
||||
def externalTestsDir = project.file("external")
|
||||
ext.testOutputRoot = rootProject.file("test.output").absolutePath
|
||||
ext.externalTestsDir = project.file("external")
|
||||
externalTestsDir.mkdirs()
|
||||
|
||||
allprojects {
|
||||
|
||||
Reference in New Issue
Block a user