Expose some methods and properties related to Cocoapods dependencies to access them in Apple gradle plugin
This commit is contained in:
committed by
Florian Kistner
parent
81b09ca09f
commit
e338c5651b
+17
-14
@@ -75,6 +75,9 @@ private fun String.toSetupBuildTaskName(pod: CocoapodsDependency): String = lowe
|
||||
this
|
||||
)
|
||||
|
||||
fun KotlinNativeTarget.toSetupBuildTaskName(pod: CocoapodsDependency) =
|
||||
this.toValidSDK.toSetupBuildTaskName(pod)
|
||||
|
||||
private fun String.toBuildDependenciesTaskName(pod: CocoapodsDependency): String = lowerCamelCaseName(
|
||||
KotlinCocoapodsPlugin.POD_BUILD_TASK_NAME,
|
||||
pod.name.asValidTaskName(),
|
||||
@@ -87,23 +90,24 @@ private val CocoapodsDependency.toPodDownloadTaskName: String
|
||||
name.asValidTaskName()
|
||||
)
|
||||
|
||||
|
||||
private val KotlinNativeTarget.toValidSDK: String
|
||||
get() = when (konanTarget) {
|
||||
IOS_X64 -> "iphonesimulator"
|
||||
IOS_ARM32, IOS_ARM64 -> "iphoneos"
|
||||
WATCHOS_X86, WATCHOS_X64 -> "watchsimulator"
|
||||
WATCHOS_ARM32, WATCHOS_ARM64 -> "watchos"
|
||||
TVOS_X64 -> "appletvsimulator"
|
||||
TVOS_ARM64 -> "appletvos"
|
||||
MACOS_X64 -> "macosx"
|
||||
else -> throw IllegalArgumentException("Bad target ${konanTarget.name}.")
|
||||
}
|
||||
|
||||
open class KotlinCocoapodsPlugin : Plugin<Project> {
|
||||
private fun KotlinMultiplatformExtension.supportedTargets() = targets
|
||||
fun KotlinMultiplatformExtension.supportedTargets() = targets
|
||||
.withType(KotlinNativeTarget::class.java)
|
||||
.matching { it.konanTarget.family.isAppleFamily }
|
||||
|
||||
private val KotlinNativeTarget.toValidSDK: String
|
||||
get() = when (konanTarget) {
|
||||
IOS_X64 -> "iphonesimulator"
|
||||
IOS_ARM32, IOS_ARM64 -> "iphoneos"
|
||||
WATCHOS_X86, WATCHOS_X64 -> "watchsimulator"
|
||||
WATCHOS_ARM32, WATCHOS_ARM64 -> "watchos"
|
||||
TVOS_X64 -> "appletvsimulator"
|
||||
TVOS_ARM64 -> "appletvos"
|
||||
MACOS_X64 -> "macosx"
|
||||
else -> throw IllegalArgumentException("Bad target ${konanTarget.name}.")
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits a string using a whitespace characters as delimiters.
|
||||
* Ignores whitespaces in quotes and drops quotes, e.g. a string
|
||||
@@ -527,7 +531,6 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
|
||||
}
|
||||
|
||||
override fun apply(project: Project): Unit = with(project) {
|
||||
|
||||
pluginManager.withPlugin("kotlin-multiplatform") {
|
||||
val kotlinExtension = project.multiplatformExtension
|
||||
val cocoapodsExtension = CocoapodsExtension(this)
|
||||
|
||||
+5
-4
@@ -444,7 +444,7 @@ open class PodSetupBuildTask : DefaultTask() {
|
||||
lateinit var pod: Provider<CocoapodsDependency>
|
||||
|
||||
@get:OutputFile
|
||||
internal val buildSettingsFile: Provider<File> = project.provider {
|
||||
val buildSettingsFile: Provider<File> = project.provider {
|
||||
project.cocoapodsBuildDirs
|
||||
.buildSettings
|
||||
.resolve(getBuildSettingFileName(pod.get(), sdk.get()))
|
||||
@@ -483,7 +483,8 @@ open class PodBuildTask : DefaultTask() {
|
||||
|
||||
@get:PathSensitive(PathSensitivity.ABSOLUTE)
|
||||
@get:InputFile
|
||||
internal lateinit var buildSettingsFile: Provider<File>
|
||||
lateinit var buildSettingsFile: Provider<File>
|
||||
internal set
|
||||
|
||||
@get:Nested
|
||||
internal lateinit var pod: Provider<CocoapodsDependency>
|
||||
@@ -533,10 +534,10 @@ open class PodBuildTask : DefaultTask() {
|
||||
}
|
||||
|
||||
|
||||
internal data class PodBuildSettingsProperties(
|
||||
data class PodBuildSettingsProperties(
|
||||
internal val buildDir: String,
|
||||
internal val configuration: String,
|
||||
internal val configurationBuildDir: String,
|
||||
val configurationBuildDir: String,
|
||||
internal val podsTargetSrcRoot: String,
|
||||
internal val cflags: String? = null,
|
||||
internal val headerPaths: String? = null,
|
||||
|
||||
Reference in New Issue
Block a user