-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a crash caused by SKIE generating invalid modulemap if no Swift c…
…ode generated was generated.
- Loading branch information
1 parent
a601413
commit 8584e39
Showing
5 changed files
with
67 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...c/commonMain/kotlin/co/touchlab/skie/phases/swift/CopySwiftOutputFilesToFrameworkPhase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package co.touchlab.skie.phases.swift | ||
|
||
import co.touchlab.skie.configuration.SkieConfigurationFlag | ||
import co.touchlab.skie.phases.SirPhase | ||
|
||
class CopySwiftOutputFilesToFrameworkPhase( | ||
context: SirPhase.Context, | ||
) : SirPhase { | ||
|
||
private val framework = context.framework | ||
private val swiftFrameworkHeader = context.skieBuildDirectory.swiftCompiler.moduleHeader(framework.moduleName) | ||
private val targetTriple = context.swiftCompilerConfiguration.targetTriple | ||
|
||
context(SirPhase.Context) | ||
override suspend fun execute() { | ||
if (sirProvider.compilableFiles.isNotEmpty()) { | ||
copySwiftModuleFiles() | ||
copySwiftLibraryEvolutionFiles() | ||
} else { | ||
deleteSwiftModuleFiles() | ||
deleteSwiftLibraryEvolutionFiles() | ||
} | ||
} | ||
|
||
private fun copySwiftModuleFiles() { | ||
val copyFiles = mapOf( | ||
swiftFrameworkHeader.swiftModule to framework.swiftModule(targetTriple), | ||
swiftFrameworkHeader.swiftDoc to framework.swiftDoc(targetTriple), | ||
swiftFrameworkHeader.abiJson to framework.abiJson(targetTriple), | ||
swiftFrameworkHeader.swiftSourceInfo to framework.swiftSourceInfo(targetTriple), | ||
swiftFrameworkHeader.swiftHeader to framework.swiftHeader, | ||
) | ||
|
||
copyFiles.forEach { (source, target) -> | ||
source.copyTo(target, overwrite = true) | ||
} | ||
} | ||
|
||
private fun deleteSwiftModuleFiles() { | ||
framework.swiftModuleParent.deleteRecursively() | ||
framework.swiftHeader.delete() | ||
} | ||
|
||
context(SirPhase.Context) | ||
private fun copySwiftLibraryEvolutionFiles() { | ||
if (SkieConfigurationFlag.Build_SwiftLibraryEvolution.isEnabled) { | ||
swiftFrameworkHeader.swiftInterface.copyTo(framework.swiftInterface(targetTriple), overwrite = true) | ||
swiftFrameworkHeader.privateSwiftInterface.copyTo(framework.privateSwiftInterface(targetTriple), overwrite = true) | ||
} else { | ||
deleteSwiftLibraryEvolutionFiles() | ||
} | ||
} | ||
|
||
private fun deleteSwiftLibraryEvolutionFiles() { | ||
framework.swiftInterface(targetTriple).delete() | ||
framework.privateSwiftInterface(targetTriple).delete() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters