From dbc10781af2896d159879188dbc9832e865074f0 Mon Sep 17 00:00:00 2001 From: LepilkinaElena Date: Tue, 30 Apr 2019 12:48:50 +0300 Subject: [PATCH] Unify compiler and cinterop flags names (#2915) --- INTEROP.md | 4 ++-- .../kotlin/native/interop/gen/jvm/CommandLine.kt | 14 ++++++++++---- .../kotlin/native/interop/gen/jvm/main.kt | 14 ++++++++------ LIBRARIES.md | 2 +- .../jetbrains/kotlin/NativeInteropPlugin.groovy | 4 ++-- performance/videoplayer/build.gradle | 10 +++++----- .../plugin/experimental/tasks/CInteropTask.kt | 6 +++--- .../gradle/plugin/konan/tasks/KonanInteropTask.kt | 6 +++--- 8 files changed, 34 insertions(+), 26 deletions(-) diff --git a/INTEROP.md b/INTEROP.md index 45c88ccc328..344f234c552 100644 --- a/INTEROP.md +++ b/INTEROP.md @@ -37,7 +37,7 @@ Install libgit2 and prepare stubs for the git library: cd samples/gitchurn ../../dist/bin/cinterop -def src/main/c_interop/libgit2.def \ - -compilerOpts -I/usr/local/include -o libgit2 + -compiler-option -I/usr/local/include -o libgit2 ``` @@ -86,7 +86,7 @@ in the sysroot search paths, headers may be needed):
```bash -cinterop -def png.def -compilerOpts -I/usr/local/include -o png +cinterop -def png.def -compiler-option -I/usr/local/include -o png ```
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 47d80935083..731b47413f0 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 @@ -62,17 +62,23 @@ fun getCInteropArguments(): List { OptionDescriptor(ArgType.String(), "compilerOpts", description = "additional compiler options (allows to add several options separated by spaces)", isMultiple = true, delimiter = " "), + OptionDescriptor(ArgType.String(), "compiler-options", + description = "additional compiler options (allows to add several options separated by spaces)", + isMultiple = true, delimiter = " "), OptionDescriptor(ArgType.String(), "linkerOpts", description = "additional linker options (allows to add several options separated by spaces)", isMultiple = true, delimiter = " "), - OptionDescriptor(ArgType.String(), "compilerOpt", + OptionDescriptor(ArgType.String(), "linker-options", + description = "additional linker options (allows to add several options separated by spaces)", + isMultiple = true, delimiter = " "), + OptionDescriptor(ArgType.String(), "compiler-option", description = "additional compiler option", isMultiple = true), - OptionDescriptor(ArgType.String(), "linkerOpt", + OptionDescriptor(ArgType.String(), "linker-option", description = "additional linker option", isMultiple = true), OptionDescriptor(ArgType.String(), "copt", description = "additional compiler options (allows to add several options separated by spaces)", - isMultiple = true, delimiter = " ", deprecatedWarning = "Option -copt is deprecated. Please use -compilerOpts."), + isMultiple = true, delimiter = " ", deprecatedWarning = "Option -copt is deprecated. Please use -compiler-options."), OptionDescriptor(ArgType.String(), "lopt", description = "additional linker options (allows to add several options separated by spaces)", - isMultiple = true, delimiter = " ", deprecatedWarning = "Option -lopt is deprecated. Please use -linkerOpts."), + isMultiple = true, delimiter = " ", deprecatedWarning = "Option -lopt is deprecated. Please use -linker-options."), 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/main.kt b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt index 6205935db8b..27d838b694c 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 @@ -41,7 +41,7 @@ fun interop(flavor: String, args: Array, additionalArgs: Map, additionalArgs: Map = val def = DefFile(defFile, tool.substitutions) val isLinkerOptsSetByUser = (argParser.getOrigin("linkerOpts") == ArgParser.ValueOrigin.SET_BY_USER) || - (argParser.getOrigin("linkerOpt") == ArgParser.ValueOrigin.SET_BY_USER) || + (argParser.getOrigin("linker-option") == ArgParser.ValueOrigin.SET_BY_USER) || + (argParser.getOrigin("linker-options") == ArgParser.ValueOrigin.SET_BY_USER) || (argParser.getOrigin("lopt") == ArgParser.ValueOrigin.SET_BY_USER) if (flavorName == "native" && isLinkerOptsSetByUser) { - warn("-linkerOpt(s)/-lopt option is not supported by cinterop. Please add linker options to .def file or binary compilation instead.") + warn("-linker-option(s)/-linkerOpts/-lopt option is not supported by cinterop. Please add linker options to .def file or binary compilation instead.") } - val additionalLinkerOpts = argParser.getValuesAsArray("linkerOpts") + argParser.getValuesAsArray("linkerOpt") + - argParser.getValuesAsArray("lopt") + val additionalLinkerOpts = argParser.getValuesAsArray("linkerOpts") + argParser.getValuesAsArray("linker-option") + + argParser.getValuesAsArray("linker-options") + argParser.getValuesAsArray("lopt") val verbose = argParser.get("verbose")!! val language = selectNativeLanguage(def.config) @@ -305,7 +306,8 @@ internal fun buildNativeLibrary( imports: ImportsImpl ): NativeLibrary { val additionalHeaders = arguments.getValuesAsArray("header") + arguments.getValuesAsArray("h") - val additionalCompilerOpts = arguments.getValuesAsArray("compilerOpts") + arguments.getValuesAsArray("compilerOpt") + + val additionalCompilerOpts = arguments.getValuesAsArray("compilerOpts") + + arguments.getValuesAsArray("compiler-options") + arguments.getValuesAsArray("compiler-option") + arguments.getValuesAsArray("copt") val headerFiles = def.config.headers + additionalHeaders diff --git a/LIBRARIES.md b/LIBRARIES.md index 52801062f8e..68ca0b42dc0 100644 --- a/LIBRARIES.md +++ b/LIBRARIES.md @@ -36,7 +36,7 @@ For example, using the simple `libgit2.def` native library definition file provi
```bash -$ cinterop -def samples/gitchurn/src/nativeInterop/cinterop/libgit2.def -compilerOpts -I/usr/local/include -o libgit2 +$ cinterop -def samples/gitchurn/src/nativeInterop/cinterop/libgit2.def -compiler-option -I/usr/local/include -o libgit2 ```
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 834ddff17bb..98c609e30ca 100644 --- a/buildSrc/plugins/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy +++ b/buildSrc/plugins/src/main/groovy/org/jetbrains/kotlin/NativeInteropPlugin.groovy @@ -247,8 +247,8 @@ class NamedNativeInteropConfig implements Named { environment['PATH'] = project.files(project.hostPlatform.clang.clangPaths).asPath + File.pathSeparator + environment['PATH'] - args compilerOpts.collectMany { ['-compilerOpt', it] } - args linkerOpts.collectMany { ['-linkerOpt', it] } + args compilerOpts.collectMany { ['-compiler-option', it] } + args linkerOpts.collectMany { ['-linker-option', it] } headers.each { args '-header', it diff --git a/performance/videoplayer/build.gradle b/performance/videoplayer/build.gradle index bcb0a751848..beb32cc1bac 100644 --- a/performance/videoplayer/build.gradle +++ b/performance/videoplayer/build.gradle @@ -21,17 +21,17 @@ if (MPPTools.isMacos()) { '-headerFilterAdditionalSearchPrefix', '/usr/include/x86_64-linux-gnu', '-headerFilterAdditionalSearchPrefix', '/usr/include/ffmpeg'] } else if (MPPTools.isWindows()) { - includeDirsFfmpeg += ['-compilerOpt', "-I${MPPTools.mingwPath()}/include"] + includeDirsFfmpeg += ['-compiler-option', "-I${MPPTools.mingwPath()}/include"] } def includeDirsSdl = [] if (MPPTools.isMacos()) { - includeDirsSdl += ['-compilerOpt', '-I/opt/local/include/SDL2', - '-compilerOpt', '-I/usr/local/include/SDL2'] + includeDirsSdl += ['-compiler-option', '-I/opt/local/include/SDL2', + '-compiler-option', '-I/usr/local/include/SDL2'] } else if (MPPTools.isLinux()) { - includeDirsSdl += ['-compilerOpt', '-I/usr/include/SDL2'] + includeDirsSdl += ['-compiler-option', '-I/usr/include/SDL2'] } else if (MPPTools.isWindows()) { - includeDirsSdl += ['-compilerOpt', "-I${MPPTools.mingwPath()}/include/SDL2"] + includeDirsSdl += ['-compiler-option', "-I${MPPTools.mingwPath()}/include/SDL2"] } project.ext { diff --git a/tools/kotlin-native-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/experimental/tasks/CInteropTask.kt b/tools/kotlin-native-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/experimental/tasks/CInteropTask.kt index 1c5e86fc0df..6c48b548259 100644 --- a/tools/kotlin-native-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/experimental/tasks/CInteropTask.kt +++ b/tools/kotlin-native-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/experimental/tasks/CInteropTask.kt @@ -98,14 +98,14 @@ open class CInteropTask @Inject constructor(val settings: CInteropSettingsImpl): addFileArgs("-header", headers) compilerOpts.forEach { - addArg("-compilerOpt", it) + addArg("-compiler-option", it) } linkerOpts.forEach { - addArg("-linkerOpt", it) + addArg("-linker-option", it) } - addArgs("-compilerOpt", allHeadersDirs.map { "-I${it.absolutePath}" }) + addArgs("-compiler-option", allHeadersDirs.map { "-I${it.absolutePath}" }) addArgs("-headerFilterAdditionalSearchPrefix", headerFilterDirs.map { it.absolutePath }) libraries.files.filter { diff --git a/tools/kotlin-native-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/konan/tasks/KonanInteropTask.kt b/tools/kotlin-native-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/konan/tasks/KonanInteropTask.kt index 28fb6215527..39281476f91 100644 --- a/tools/kotlin-native-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/konan/tasks/KonanInteropTask.kt +++ b/tools/kotlin-native-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/konan/tasks/KonanInteropTask.kt @@ -85,7 +85,7 @@ open class KonanInteropTask @Inject constructor(val workerExecutor: WorkerExecut addFileArgs("-header", headers) compilerOpts.forEach { - addArg("-copt", it) + addArg("-compiler-option", it) } val linkerOpts = mutableListOf().apply { addAll(linkerOpts) } @@ -93,10 +93,10 @@ open class KonanInteropTask @Inject constructor(val workerExecutor: WorkerExecut linkerOpts.addAll(it.files.map { it.canonicalPath }) } linkerOpts.forEach { - addArg("-linkerOpt", it) + addArg("-linker-option", it) } - addArgs("-compilerOpt", includeDirs.allHeadersDirs.map { "-I${it.absolutePath}" }) + addArgs("-compiler-option", includeDirs.allHeadersDirs.map { "-I${it.absolutePath}" }) addArgs("-headerFilterAdditionalSearchPrefix", includeDirs.headerFilterDirs.map { it.absolutePath }) addArgs("-repo", libraries.repos.map { it.canonicalPath })