dependencies: Move dependency downloader into shared project

This commit is contained in:
Ilya Matveev
2017-08-18 17:03:48 +07:00
committed by ilmat192
parent fb15992546
commit 60ed6f6871
23 changed files with 370 additions and 587 deletions
@@ -33,28 +33,9 @@ import org.jetbrains.kotlin.config.addKotlinSourceRoots
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
import org.jetbrains.kotlin.konan.target.TargetManager
import org.jetbrains.kotlin.utils.KotlinPaths
import java.io.File
import kotlin.reflect.KFunction
// TODO: Don't use reflection?
private fun maybeExecuteHelper(targetName: String) {
try {
val kClass = Class.forName("org.jetbrains.kotlin.konan.Helper0").kotlin
@Suppress("UNCHECKED_CAST")
val ctor = kClass.constructors.single() as KFunction<Runnable>
val distribution = Distribution(TargetManager(targetName))
val result = ctor.call(
distribution.dependenciesDir,
distribution.properties,
distribution.dependencies
)
result.run()
} catch (notFound: ClassNotFoundException) {
// Just ignore, no helper.
} catch (e: Throwable) {
throw IllegalStateException("Cannot download dependencies.", e)
}
}
class K2Native : CLICompiler<K2NativeCompilerArguments>() {
override fun doExecute(@NotNull arguments: K2NativeCompilerArguments, @NotNull configuration: CompilerConfiguration, @NotNull rootDisposable: Disposable, @Nullable paths: KotlinPaths?): ExitCode {
@@ -85,7 +66,6 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
return this?.asList<String>() ?: listOf<String>()
}
// It is executed before doExecute().
override fun setupPlatformSpecificArgumentsAndServices(
configuration: CompilerConfiguration,
@@ -152,8 +132,6 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
put(ENABLE_ASSERTIONS, arguments.enableAssertions)
}
}
maybeExecuteHelper(arguments.target ?: "host")
}
override fun createArguments(): K2NativeCompilerArguments {