Support Native binary options in Gradle
Both project properties and per-binary DSL are available.
This commit is contained in:
committed by
Space
parent
9877a7271a
commit
5e789f86ee
+7
@@ -71,6 +71,13 @@ sealed class NativeBinary(
|
|||||||
linkerOpts.addAll(options)
|
linkerOpts.addAll(options)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var binaryOptions: MutableMap<String, String> = mutableMapOf()
|
||||||
|
|
||||||
|
fun binaryOption(name: String, value: String) {
|
||||||
|
// TODO: report if $name is unknown?
|
||||||
|
binaryOptions[name] = value
|
||||||
|
}
|
||||||
|
|
||||||
/** Additional arguments passed to the Kotlin/Native compiler. */
|
/** Additional arguments passed to the Kotlin/Native compiler. */
|
||||||
var freeCompilerArgs: List<String>
|
var freeCompilerArgs: List<String>
|
||||||
get() = linkTask.kotlinOptions.freeCompilerArgs
|
get() = linkTask.kotlinOptions.freeCompilerArgs
|
||||||
|
|||||||
+20
@@ -585,6 +585,19 @@ constructor(
|
|||||||
val linkerOpts: List<String>
|
val linkerOpts: List<String>
|
||||||
@Input get() = binary.linkerOpts
|
@Input get() = binary.linkerOpts
|
||||||
|
|
||||||
|
val binaryOptions: Map<String, String>
|
||||||
|
@Input get() = binary.binaryOptions
|
||||||
|
|
||||||
|
val projectWideBinaryOptions: Map<String, String>
|
||||||
|
@Input get() = project.properties.mapNotNull { (name, value) ->
|
||||||
|
val prefix = KOTLIN_NATIVE_BINARY_OPTION_PREFIX
|
||||||
|
if (name.startsWith(prefix) && value is String) {
|
||||||
|
name.removePrefix(prefix) to value
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}.toMap()
|
||||||
|
|
||||||
val processTests: Boolean
|
val processTests: Boolean
|
||||||
@Input get() = binary is TestExecutable
|
@Input get() = binary is TestExecutable
|
||||||
|
|
||||||
@@ -628,6 +641,9 @@ constructor(
|
|||||||
linkerOpts.forEach {
|
linkerOpts.forEach {
|
||||||
addArg("-linker-option", it)
|
addArg("-linker-option", it)
|
||||||
}
|
}
|
||||||
|
(projectWideBinaryOptions + binaryOptions).forEach { (name, value) ->
|
||||||
|
add("-Xbinary=$name=$value")
|
||||||
|
}
|
||||||
exportLibraries.files.filterKlibsPassedToCompiler().forEach {
|
exportLibraries.files.filterKlibsPassedToCompiler().forEach {
|
||||||
add("-Xexport-library=${it.absolutePath}")
|
add("-Xexport-library=${it.absolutePath}")
|
||||||
}
|
}
|
||||||
@@ -689,6 +705,10 @@ constructor(
|
|||||||
validatedExportedLibraries()
|
validatedExportedLibraries()
|
||||||
super.compile()
|
super.compile()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
const val KOTLIN_NATIVE_BINARY_OPTION_PREFIX = "kotlin.native.binary."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ExternalDependenciesBuilder(
|
private class ExternalDependenciesBuilder(
|
||||||
|
|||||||
Reference in New Issue
Block a user