From 4a716fbf30a91666a7aa1ab5565feac89d60a2fe Mon Sep 17 00:00:00 2001 From: Ilya Matveev Date: Tue, 21 Mar 2017 16:03:57 +0700 Subject: [PATCH] backend: Use konan.dependencies property to set dependencies dir This patch set default dependencies directory to ${konan.home}/ dependencies and allows one to override this setting using konan.dependencies system property. --- .../org/jetbrains/kotlin/native/interop/gen/jvm/main.kt | 8 +++----- backend.native/build.gradle | 2 ++ .../org/jetbrains/kotlin/backend/konan/Distribution.kt | 7 +++---- .../src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy | 5 ++++- .../org/jetbrains/kotlin/NativeInteropPlugin.groovy | 1 + 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt index f9f9755048a..f54a20fb0a8 100644 --- a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt +++ b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt @@ -231,12 +231,10 @@ private fun processLib(konanHome: String, val konanFile = File(konanFileName) val konanProperties = loadProperties(konanFile, mapOf()) - // TODO: We use -Dkonan.home in the absence of fully built 'dist' - // to locate the 'dependencies' directory. - // Eventually we need to pull the necessary content into 'dist'. - // And provide a set of flags to find the components in the absence of 'dist'. + // TODO: We can provide a set of flags to find the components in the absence of 'dist' or 'dist/dependencies'. val llvmHome = konanProperties.getOsSpecific("llvmHome")!! - val dependencies = File("$konanHome/../dependencies/all").canonicalPath + // We can override dependency directory using konan.dependencies system property. + val dependencies = System.getProperty("konan.dependencies", "$konanHome/dependencies") val llvmInstallPath = "$dependencies/$llvmHome" val additionalHeaders = args["-h"].orEmpty() val additionalCompilerOpts = args["-copt"].orEmpty() diff --git a/backend.native/build.gradle b/backend.native/build.gradle index c5d8dff522e..2a987e4c557 100644 --- a/backend.native/build.gradle +++ b/backend.native/build.gradle @@ -194,6 +194,7 @@ targetList.each { target -> classpath = project.configurations.cli_bc jvmArgs "-ea", "-Dkonan.home=${project.parent.file('dist')}", + "-Dkonan.dependencies=${project.parent.file('dependencies/all')}", "-Djava.library.path=${project.buildDir}/nativelibs" args('-output', project(':runtime').file("build/${target}/stdlib.kt.bc"), '-nolink', '-nostdlib', '-ea', @@ -220,6 +221,7 @@ targetList.each { target -> classpath = project.configurations.cli_bc jvmArgs "-ea", "-Dkonan.home=${project.parent.file('dist')}", + "-Dkonan.dependencies=${project.parent.file('dependencies/all')}", "-Djava.library.path=${project.buildDir}/nativelibs" args('-output', project(':runtime').file("build/${target}/start.kt.bc"), '-nolink', '-nostdlib', '-ea', diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Distribution.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Distribution.kt index 455eb396c92..7646206041e 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Distribution.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Distribution.kt @@ -2,9 +2,8 @@ package org.jetbrains.kotlin.backend.konan import org.jetbrains.kotlin.config.CompilerConfiguration import java.io.File -import java.util.Properties -public class Distribution(val config: CompilerConfiguration) { +class Distribution(val config: CompilerConfiguration) { val targetManager = TargetManager(config) val target = @@ -25,8 +24,8 @@ public class Distribution(val config: CompilerConfiguration) { val lib = "$konanHome/lib/$target" - // TODO: Pack all needed things to dist. - val dependencies = "$konanHome/../dependencies/all" + // We can override dependency directory using konan.dependencies system property. + val dependencies = System.getProperty("konan.dependencies", "$konanHome/dependencies") val stdlib = "$lib/stdlib.kt.bc" val start = "$lib/start.kt.bc" diff --git a/buildSrc/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy b/buildSrc/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy index 6f53e936787..7645e717753 100644 --- a/buildSrc/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy +++ b/buildSrc/src/main/groovy/org/jetbrains/kotlin/KonanTest.groovy @@ -12,6 +12,7 @@ abstract class KonanTest extends JavaExec { def backendNative = project.project(":backend.native") def runtimeProject = project.project(":runtime") def dist = project.rootProject.file("dist") + def dependencies = project.findProject(":dependencies").file("all") def runtimeBc = new File("${dist.canonicalPath}/lib/runtime.bc").absolutePath def launcherBc = new File("${dist.canonicalPath}/lib/launcher.bc").absolutePath def startKtBc = new File("${dist.canonicalPath}/lib/start.kt.bc").absolutePath @@ -56,7 +57,9 @@ abstract class KonanTest extends JavaExec { @Override void setJvmArgs(Iterable arguments) { - super.setJvmArgs(arguments + "-Dkonan.home=${dist.canonicalPath}" + + super.setJvmArgs(arguments + + "-Dkonan.home=${dist.canonicalPath}" + + "-Dkonan.dependencies=${dependencies.canonicalPat}", "-Djava.library.path=${dist.canonicalPath}/konan/nativelib") } diff --git a/buildSrc/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy b/buildSrc/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy index 1c1fdf90d37..923ef421a1a 100644 --- a/buildSrc/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy +++ b/buildSrc/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy @@ -168,6 +168,7 @@ class NamedNativeInteropConfig implements Named { new File(project.findProject(":Interop:Runtime").buildDir, "nativelibs") ).asPath systemProperties "konan.home": project.rootProject.file("dist") + systemProperties "konan.dependencies": project.findProject(":dependencies").file("all") environment "LIBCLANG_DISABLE_CRASH_RECOVERY": "1" environment "DYLD_LIBRARY_PATH": "${project.llvmDir}/lib" environment "LD_LIBRARY_PATH": "${project.llvmDir}/lib"