Unify compiler and cinterop flags names (#2915)

This commit is contained in:
LepilkinaElena
2019-04-30 12:48:50 +03:00
committed by GitHub
parent 474fc4eb04
commit dbc10781af
8 changed files with 34 additions and 26 deletions
+2 -2
View File
@@ -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
```
</div>
@@ -86,7 +86,7 @@ in the sysroot search paths, headers may be needed):
<div class="sample" markdown="1" theme="idea" mode="shell">
```bash
cinterop -def png.def -compilerOpts -I/usr/local/include -o png
cinterop -def png.def -compiler-option -I/usr/local/include -o png
```
</div>
@@ -62,17 +62,23 @@ fun getCInteropArguments(): List<OptionDescriptor> {
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())
@@ -41,7 +41,7 @@ fun interop(flavor: String, args: Array<String>, additionalArgs: Map<String, Any
}
// Options, whose values are space-separated and can be escaped.
val escapedOptions = setOf("-compilerOpts", "-linkerOpts")
val escapedOptions = setOf("-compilerOpts", "-linkerOpts", "-compiler-options", "-linker-options")
private fun String.asArgList(key: String) =
if (escapedOptions.contains(key))
@@ -177,14 +177,15 @@ private fun processCLib(args: Array<String>, additionalArgs: Map<String, Any> =
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<Boolean>("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
+1 -1
View File
@@ -36,7 +36,7 @@ For example, using the simple `libgit2.def` native library definition file provi
<div class="sample" markdown="1" theme="idea" mode="shell">
```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
```
</div>
@@ -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
+5 -5
View File
@@ -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 {
@@ -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 {
@@ -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<String>().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 })