CocoaPods: Refactor framework name mangling
This commit is contained in:
+2
@@ -37,6 +37,8 @@ internal class CocoapodsBuildDirs(val project: Project) {
|
||||
get() = root.resolve("defs")
|
||||
}
|
||||
|
||||
internal fun String.asValidFrameworkName() = replace('-', '_')
|
||||
|
||||
open class KotlinCocoapodsPlugin: Plugin<Project> {
|
||||
|
||||
private fun KotlinMultiplatformExtension.supportedTargets() = targets
|
||||
|
||||
+3
-2
@@ -9,6 +9,7 @@ import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.tasks.*
|
||||
import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.cocoapods.KotlinCocoapodsPlugin
|
||||
import org.jetbrains.kotlin.gradle.plugin.cocoapods.asValidFrameworkName
|
||||
import org.jetbrains.kotlin.gradle.plugin.cocoapods.cocoapodsBuildDirs
|
||||
import java.io.File
|
||||
|
||||
@@ -33,7 +34,7 @@ open class PodspecTask : DefaultTask() {
|
||||
val versionSuffix = if (pod.version != null) ", '${pod.version}'" else ""
|
||||
"| spec.dependency '${pod.name}'$versionSuffix"
|
||||
}.joinToString(separator = "\n")
|
||||
val specName = project.name.replace('-', '_')
|
||||
val specName = project.name.asValidFrameworkName()
|
||||
|
||||
outputFile.writeText("""
|
||||
|Pod::Spec.new do |spec|
|
||||
@@ -97,7 +98,7 @@ open class DummyFrameworkTask : DefaultTask() {
|
||||
|
||||
@get:Input
|
||||
val frameworkName
|
||||
get() = project.name.replace('-', '_')
|
||||
get() = project.name.asValidFrameworkName()
|
||||
|
||||
private val frameworkDir: File
|
||||
get() = destinationDir.resolve("$frameworkName.framework")
|
||||
|
||||
+9
-3
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
|
||||
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder
|
||||
import org.jetbrains.kotlin.gradle.plugin.cocoapods.asValidFrameworkName
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
|
||||
import org.jetbrains.kotlin.konan.target.CompilerOutputKind.*
|
||||
@@ -202,9 +203,14 @@ abstract class AbstractKotlinNativeCompile : AbstractCompile(), KotlinCompile<Ko
|
||||
|
||||
val prefix = outputKind.prefix(konanTarget)
|
||||
val suffix = outputKind.suffix(konanTarget)
|
||||
var filename = "$prefix$baseName$suffix"
|
||||
if (outputKind in listOf(FRAMEWORK, STATIC, DYNAMIC) || outputKind == PROGRAM && konanTarget == KonanTarget.WASM32) {
|
||||
filename = filename.replace('-', '_')
|
||||
val filename = "$prefix$baseName$suffix".let {
|
||||
when {
|
||||
outputKind == FRAMEWORK ->
|
||||
it.asValidFrameworkName()
|
||||
outputKind in listOf(STATIC, DYNAMIC) || outputKind == PROGRAM && konanTarget == KonanTarget.WASM32 ->
|
||||
it.replace('-', '_')
|
||||
else -> it
|
||||
}
|
||||
}
|
||||
|
||||
destinationDir.resolve(filename)
|
||||
|
||||
Reference in New Issue
Block a user