From de6fa0e72f1a82b22b15959e8e2c13972ceb8a3a Mon Sep 17 00:00:00 2001 From: LepilkinaElena Date: Thu, 28 Feb 2019 17:23:28 +0300 Subject: [PATCH] Remove -shims. Warning for -linkerOpts for native flavor (#2730) --- GRADLE_PLUGIN.md | 2 +- .../kotlin/native/interop/gen/jvm/CommandLine.kt | 1 - .../kotlin/native/interop/gen/jvm/StubGenerator.kt | 1 - .../org/jetbrains/kotlin/native/interop/gen/jvm/main.kt | 7 +++++-- .../org/jetbrains/kotlin/NativeInteropPlugin.groovy | 4 ---- tools/kliopt/org/jetbrains/kliopt/KliOpt.kt | 9 +++++++++ .../gradle/plugin/test/IncrementalSpecification.groovy | 2 +- 7 files changed, 16 insertions(+), 10 deletions(-) diff --git a/GRADLE_PLUGIN.md b/GRADLE_PLUGIN.md index 7cd988f3e42..96f31d4a380 100644 --- a/GRADLE_PLUGIN.md +++ b/GRADLE_PLUGIN.md @@ -445,7 +445,7 @@ components.main { includeDirs "include/directory" "another/directory" // Pass additional command line options to the cinterop tool. - extraOpts '-shims', 'true' + extraOpts '-verbose' // Additional configuration for Linux. target('linux') { diff --git a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/CommandLine.kt b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/CommandLine.kt index c984e80692e..1499b126217 100644 --- a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/CommandLine.kt +++ b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/CommandLine.kt @@ -63,7 +63,6 @@ fun getCInteropArguments(): List { "additional compiler options", isMultiple = true, delimiter = " "), OptionDescriptor(ArgType.String(), "linkerOpts", "lopt", "additional linker options", isMultiple = true, delimiter = " "), - OptionDescriptor(ArgType.Boolean(), "shims", description = "wrap bindings by a tracing layer", defaultValue = "false"), OptionDescriptor(ArgType.String(), "linker", description = "use specified linker") ) return (options + getCommonInteropArguments()) diff --git a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/StubGenerator.kt b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/StubGenerator.kt index dc9279f294e..cbc40fc6d92 100644 --- a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/StubGenerator.kt +++ b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/StubGenerator.kt @@ -30,7 +30,6 @@ class StubGenerator( val nativeIndex: NativeIndex, val configuration: InteropConfiguration, val libName: String, - val dumpShims: Boolean, val verbose: Boolean = false, val platform: KotlinPlatform = KotlinPlatform.JVM, val imports: Imports 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 0cfb86b3b4b..4aa94b7e902 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 @@ -177,8 +177,11 @@ private fun processCLib(args: Array, additionalArgs: Map = val def = DefFile(defFile, tool.substitutions) + if (flavorName == "native" && argParser.getOrigin("linkerOpts") == ArgParser.ValueOrigin.SET_BY_USER) { + warn("-linkerOpts/-lopt option is not supported by cinterop. Please add linker options to .def file or binary compilation instead.") + } + val additionalLinkerOpts = argParser.getValuesAsArray("linkerOpts") - val generateShims = argParser.get("shims")!! val verbose = argParser.get("verbose")!! val language = selectNativeLanguage(def.config) @@ -228,7 +231,7 @@ private fun processCLib(args: Array, additionalArgs: Map = val nativeIndex = buildNativeIndex(library, verbose) - val gen = StubGenerator(nativeIndex, configuration, libName, generateShims, verbose, flavor, imports) + val gen = StubGenerator(nativeIndex, configuration, libName, verbose, flavor, imports) outKtFile.parentFile.mkdirs() diff --git a/buildSrc/plugins/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy b/buildSrc/plugins/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy index 3458621ea19..11b49d466d3 100644 --- a/buildSrc/plugins/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy +++ b/buildSrc/plugins/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy @@ -254,10 +254,6 @@ class NamedNativeInteropConfig implements Named { args '-header', it } - if (project.hasProperty('shims') && project.ext.shims) { - args '-shims' - } - } } } diff --git a/tools/kliopt/org/jetbrains/kliopt/KliOpt.kt b/tools/kliopt/org/jetbrains/kliopt/KliOpt.kt index 8ef0e2c1039..ca5a464cac1 100644 --- a/tools/kliopt/org/jetbrains/kliopt/KliOpt.kt +++ b/tools/kliopt/org/jetbrains/kliopt/KliOpt.kt @@ -128,6 +128,9 @@ class ArgParser(optionsList: List, argsList: List + private lateinit var valuesOrigin: MutableMap + + enum class ValueOrigin { SET_BY_USER, SET_DEFAULT_VALUE, UNSET } inner class ParsedArg(val descriptor: Descriptor, val values: List) { init { @@ -166,6 +169,9 @@ class ArgParser(optionsList: List, argsList: List, arg: String, processedValues: Map>): Boolean { // Find uninitialized arguments. val nullArgs = argDescriptors.keys.filter { processedValues.getValue(it).isEmpty() } @@ -203,6 +209,7 @@ class ArgParser(optionsList: List, argsList: List() }.toMap().toMutableMap() parsedValues = descriptorsKeys.map { it to null }.toMap().toMutableMap() + valuesOrigin = descriptorsKeys.map { it to ValueOrigin.UNSET }.toMap().toMutableMap() while (index < args.size) { val arg = args[index] if (arg.startsWith('-')) { @@ -246,6 +253,7 @@ class ArgParser(optionsList: List, argsList: List, argsList: List