dependencies: Add "airplane mode"
The patch adds airplaneMode parameter in konan.properties. If airplaneMode = true the dependency downloader will throw an exception instead of downloading a missing dependency.
This commit is contained in:
@@ -17,6 +17,10 @@
|
||||
# TODO: Do we need a $variable substitution mechanism here?
|
||||
dependenciesUrl = http://download.jetbrains.com/kotlin/native
|
||||
|
||||
# Don't check dependencies on a server.
|
||||
# If true, dependency downloader will throw an exception if a dependency isn't found in konan.home.
|
||||
airplaneMode = false
|
||||
|
||||
# Mac OS X.
|
||||
llvmVersion.osx = 3.9.0
|
||||
llvmHome.osx = clang-llvm-3.9.0-darwin-macos
|
||||
|
||||
@@ -25,7 +25,14 @@ import kotlin.concurrent.thread
|
||||
import kotlin.concurrent.withLock
|
||||
|
||||
// TODO: Try to use some dependency management system (Ivy?)
|
||||
class DependencyDownloader(dependenciesRoot: File, val dependenciesUrl: String, val dependencies: List<String>) {
|
||||
/**
|
||||
* Inspects [dependencies] and downloads all the missing ones into [dependenciesDirectory] from [dependenciesUrl].
|
||||
* If [airplaneMode] is true will throw a RuntimeException instead of downloading.
|
||||
*/
|
||||
class DependencyDownloader(dependenciesRoot: File,
|
||||
val dependenciesUrl: String,
|
||||
val dependencies: List<String>,
|
||||
val airplaneMode: Boolean = false) {
|
||||
|
||||
val dependenciesDirectory = dependenciesRoot.apply { mkdirs() }
|
||||
val cacheDirectory = System.getProperty("user.home")?.let {
|
||||
@@ -85,7 +92,14 @@ class DependencyDownloader(dependenciesRoot: File, val dependenciesUrl: String,
|
||||
|
||||
val archive = File(cacheDirectory.canonicalPath, "$depName.$archiveExtension")
|
||||
if (!archive.exists()) {
|
||||
download(depName, archive)
|
||||
if (!airplaneMode) {
|
||||
download(depName, archive)
|
||||
} else {
|
||||
throw RuntimeException("""
|
||||
Cannot find a dependency locally: $dependency.
|
||||
Set `airplaneMode = false` in konan.properties to download it.
|
||||
""".trimIndent())
|
||||
}
|
||||
}
|
||||
extract(archive, dependenciesDirectory)
|
||||
extractedDependencies.addWithSave(depName)
|
||||
|
||||
@@ -27,7 +27,8 @@ class Helper0(val dependenciesDir: String,
|
||||
DependencyDownloader(
|
||||
File(dependenciesDir),
|
||||
properties.getProperty("dependenciesUrl", "https://download.jetbrains.com/kotlin/native"),
|
||||
dependencies
|
||||
dependencies,
|
||||
airplaneMode = properties.getProperty("airplaneMode")?.toBoolean() ?: false
|
||||
).run()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user