Skip to content

Commit 8009375

Browse files
committed
Make Swift library evolution configurable and turn it off by default.
1 parent 321e677 commit 8009375

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

SKIE/acceptance-tests

SKIE/common/configuration/declaration/src/commonMain/kotlin/co/touchlab/skie/configuration/SkieConfigurationFlag.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ enum class SkieConfigurationFlag {
77
Feature_CoroutinesInterop,
88
Feature_DefaultArgumentsInExternalLibraries,
99

10+
Build_SwiftLibraryEvolution,
1011
Build_ParallelSwiftCompilation,
1112
Build_ParallelSkieCompilation,
1213
Build_ConcurrentSkieCompilation,

SKIE/compiler/kotlin-plugin/src/kgp_common/kotlin/co/touchlab/skie/phases/swift/CompileSwiftPhase.kt

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class CompileSwiftPhase(
2929
private val moduleDirectory = skieBuildDirectory.swiftCompiler.module
3030

3131
private val isDebug = konanConfig.debug
32+
private val isLibraryEvolutionEnabled = SkieConfigurationFlag.Build_SwiftLibraryEvolution in skieConfiguration.enabledConfigurationFlags
3233

3334
context(SirPhase.Context)
3435
override suspend fun execute() {
@@ -48,6 +49,8 @@ class CompileSwiftPhase(
4849

4950
copySwiftModuleFiles()
5051

52+
copySwiftLibraryEvolutionFiles()
53+
5154
addSwiftSubmoduleToModuleMap()
5255

5356
addSwiftSpecificLinkerArgs()
@@ -97,15 +100,17 @@ class CompileSwiftPhase(
97100
+cacheableKotlinFramework.parentDir.absolutePath
98101
+"-F"
99102
+skieBuildDirectory.swiftCompiler.fakeObjCFrameworks.directory.absolutePath
100-
+"-enable-library-evolution"
101103
+"-verify-emitted-module-interface"
102104
+"-emit-module"
103105
+"-emit-module-path"
104106
+swiftFrameworkHeader.swiftModule
105-
+"-emit-module-interface-path"
106-
+swiftFrameworkHeader.swiftInterface
107-
+"-emit-private-module-interface-path"
108-
+swiftFrameworkHeader.privateSwiftInterface
107+
if (isLibraryEvolutionEnabled) {
108+
+"-enable-library-evolution"
109+
+"-emit-module-interface-path"
110+
+swiftFrameworkHeader.swiftInterface
111+
+"-emit-private-module-interface-path"
112+
+swiftFrameworkHeader.privateSwiftInterface
113+
}
109114
+"-emit-objc-header"
110115
+"-emit-objc-header-path"
111116
+swiftFrameworkHeader.swiftHeader
@@ -168,8 +173,6 @@ class CompileSwiftPhase(
168173
private fun copySwiftModuleFiles() {
169174
val copyFiles = mapOf(
170175
swiftFrameworkHeader.swiftModule to framework.swiftModule(targetTriple),
171-
swiftFrameworkHeader.swiftInterface to framework.swiftInterface(targetTriple),
172-
swiftFrameworkHeader.privateSwiftInterface to framework.privateSwiftInterface(targetTriple),
173176
swiftFrameworkHeader.swiftDoc to framework.swiftDoc(targetTriple),
174177
swiftFrameworkHeader.abiJson to framework.abiJson(targetTriple),
175178
swiftFrameworkHeader.swiftSourceInfo to framework.swiftSourceInfo(targetTriple),
@@ -181,6 +184,16 @@ class CompileSwiftPhase(
181184
}
182185
}
183186

187+
private fun copySwiftLibraryEvolutionFiles() {
188+
if (isLibraryEvolutionEnabled) {
189+
swiftFrameworkHeader.swiftInterface.copyTo(framework.swiftInterface(targetTriple), overwrite = true)
190+
swiftFrameworkHeader.privateSwiftInterface.copyTo(framework.privateSwiftInterface(targetTriple), overwrite = true)
191+
} else {
192+
framework.swiftInterface(targetTriple).delete()
193+
framework.privateSwiftInterface(targetTriple).delete()
194+
}
195+
}
196+
184197
private fun addSwiftSubmoduleToModuleMap() {
185198
framework.modulemapFile.appendText(
186199
"""

SKIE/skie-gradle/plugin-api/src/common/kotlin/co/touchlab/skie/plugin/configuration/SkieBuildConfiguration.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import javax.inject.Inject
88

99
abstract class SkieBuildConfiguration @Inject constructor(objects: ObjectFactory) {
1010

11+
val enableSwiftLibraryEvolution: Property<Boolean> = objects.property(Boolean::class.java).convention(false)
1112
val enableParallelSwiftCompilation: Property<Boolean> = objects.property(Boolean::class.java).convention(true)
1213
val enableConcurrentSkieCompilation: Property<Boolean> = objects.property(Boolean::class.java).convention(true)
1314
val enableParallelSkieCompilation: Property<Boolean> = objects.property(Boolean::class.java).convention(true)
1415

1516
internal fun buildConfigurationFlags(): Set<SkieConfigurationFlag> =
1617
setOfNotNull(
18+
SkieConfigurationFlag.Build_SwiftLibraryEvolution takeIf enableSwiftLibraryEvolution,
1719
SkieConfigurationFlag.Build_ParallelSwiftCompilation takeIf enableParallelSwiftCompilation,
1820
SkieConfigurationFlag.Build_ConcurrentSkieCompilation takeIf enableConcurrentSkieCompilation,
1921
SkieConfigurationFlag.Build_ParallelSkieCompilation takeIf enableParallelSkieCompilation,

0 commit comments

Comments
 (0)