From d00d3daf863ef72c155b61457dbf4154b329912f Mon Sep 17 00:00:00 2001 From: Svyatoslav Scherbina Date: Thu, 13 Oct 2016 16:47:32 +0300 Subject: [PATCH] Interop: support passing linker as arg to stub generator --- .../org/jetbrains/kotlin/native/interop/gen/jvm/main.kt | 2 +- .../org/jetbrains/kotlin/NativeInteropPlugin.groovy | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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 280be77d483..c4625721558 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 @@ -110,7 +110,7 @@ private fun processLib(ktGenRoot: String, val compilerOpts = config.getSpaceSeparated("compilerOpts") + additionalCompilerOpts val compiler = config.getProperty("compiler") ?: "clang" val linkerOpts = config.getSpaceSeparated("linkerOpts").toTypedArray() + additionalLinkerOpts - val linker = config.getProperty("linker") ?: "clang" + val linker = args["-linker"]?.singleOrNull() ?: config.getProperty("linker") ?: "clang" val excludedFunctions = config.getSpaceSeparated("excludedFunctions").toSet() val fqParts = args["-pkg"]?.singleOrNull()?.let { diff --git a/buildSrc/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy b/buildSrc/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy index 1465a7964e7..07fc7507828 100644 --- a/buildSrc/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy +++ b/buildSrc/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy @@ -26,6 +26,7 @@ class NamedNativeInteropConfig extends AbstractFileCollection implements Named { private List compilerOpts = [] private FileCollection headers; + private String linker private List linkerOpts = [] private FileCollection linkFiles; private List linkTasks = [] @@ -48,6 +49,10 @@ class NamedNativeInteropConfig extends AbstractFileCollection implements Named { headers = headers + files } + void linker(String value) { + linker = value + } + void linkerOpts(String... values) { linkerOpts.addAll(values) } @@ -161,6 +166,10 @@ class NamedNativeInteropConfig extends AbstractFileCollection implements Named { args "-pkg:" + pkg } + if (linker != null) { + args "-linker:" + linker + } + args compilerOpts.collect { "-copt:$it" } args linkerOpts.collect { "-lopt:$it" }