Support -Xstatic-framework in DSL
In Kotlin/Native 1.3.30 EAP1 an ability to build a static ObjC framework has been added. This patch adds support for this feature in the kotlin-multiplatform plugin.
This commit is contained in:
+2
-1
@@ -990,12 +990,13 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
// Check manual disabling bitcode embedding and custom command line args.
|
||||
// Check manual disabling bitcode embedding, custom command line args and building a static framework.
|
||||
build("linkCustomReleaseFrameworkIos") {
|
||||
assertSuccessful()
|
||||
checkFrameworkCompilationCommandLine {
|
||||
assertTrue(it.contains("-linker-options -L."))
|
||||
assertTrue(it.contains("-Xtime"))
|
||||
assertTrue(it.contains("-Xstatic-framework"))
|
||||
assertFalse(it.contains("-Xembed-bitcode-marker"))
|
||||
assertFalse(it.contains("-Xembed-bitcode"))
|
||||
}
|
||||
|
||||
+1
@@ -73,6 +73,7 @@ kotlin {
|
||||
embedBitcode = 'DISABLE'
|
||||
linkerOpts = ['-L.']
|
||||
freeCompilerArgs = ["-Xtime"]
|
||||
isStatic = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -65,6 +65,7 @@ kotlin {
|
||||
embedBitcode("disable")
|
||||
linkerOpts = mutableListOf("-L.")
|
||||
freeCompilerArgs = mutableListOf("-Xtime")
|
||||
isStatic = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -102,8 +102,7 @@ open class KotlinCocoapodsPlugin: Plugin<Project> {
|
||||
private fun createDefaultFrameworks(kotlinExtension: KotlinMultiplatformExtension) {
|
||||
kotlinExtension.supportedTargets().all { target ->
|
||||
target.binaries.framework {
|
||||
// TODO: Add in the framework DSL.
|
||||
this.freeCompilerArgs.add("-Xstatic-framework")
|
||||
isStatic = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -234,6 +234,11 @@ class Framework(
|
||||
*/
|
||||
fun embedBitcode(mode: String) = embedBitcode(BitcodeEmbeddingMode.valueOf(mode.toUpperCase()))
|
||||
|
||||
/**
|
||||
* Specifies if the framework is linked as a static library (false by default).
|
||||
*/
|
||||
var isStatic = false
|
||||
|
||||
enum class BitcodeEmbeddingMode {
|
||||
/** Don't embed LLVM IR bitcode. */
|
||||
DISABLE,
|
||||
|
||||
+5
@@ -370,6 +370,10 @@ open class KotlinNativeLink : AbstractKotlinNativeCompile() {
|
||||
}
|
||||
}
|
||||
|
||||
@get:Input
|
||||
val isStaticFramework: Boolean
|
||||
get() = binary.let { it is Framework && it.isStatic }
|
||||
|
||||
@get:Input
|
||||
val embedBitcode: Framework.BitcodeEmbeddingMode
|
||||
get() = (binary as? Framework)?.embedBitcode ?: Framework.BitcodeEmbeddingMode.DISABLE
|
||||
@@ -392,6 +396,7 @@ open class KotlinNativeLink : AbstractKotlinNativeCompile() {
|
||||
exportLibraries.files.filterExternalKlibs(project).forEach {
|
||||
add("-Xexport-library=${it.absolutePath}")
|
||||
}
|
||||
addKey("-Xstatic-framework", isStaticFramework)
|
||||
addAll(freeCompilerArgs)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user