Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kotlin.native.cocoapods.targets can be a custom list of architectures #3861

Merged
merged 3 commits into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.gradle.plugin.cocoapods.KotlinCocoapodsPlugin.Compan
import org.jetbrains.kotlin.gradle.plugin.cocoapods.KotlinCocoapodsPlugin.Companion.POD_SPEC_TASK_NAME
import org.jetbrains.kotlin.gradle.transformProjectWithPluginsDsl
import org.jetbrains.kotlin.gradle.util.modify
import org.jetbrains.kotlin.gradle.util.runProcess
import org.jetbrains.kotlin.konan.target.HostManager
import org.junit.Assume.assumeTrue
import org.junit.Before
Expand Down Expand Up @@ -739,6 +740,31 @@ class CocoaPodsIT : BaseGradleIT() {
}
}

@Test
fun testCommaSeparatedTargets() {
with(project) {
gradleBuildScript().modify {
// Replace a single target with a pair (iosX64 + iosArm64) to test building a fat framework.
it.replace("iosX64(\"iOS\")", "ios()")
}
hooks.addHook {
// Check that a built universal framework includes both device and simulator architectures.
val framework = fileInWorkingDir("build/cocoapods/framework/cocoapods.framework/cocoapods")
with(runProcess(listOf("file", framework.absolutePath), projectDir)) {
assertTrue(isSuccessful)
assertTrue(output.contains("\\(for architecture x86_64\\):\\s+current ar archive".toRegex()))
assertTrue(output.contains("\\(for architecture arm64\\):\\s+current ar archive".toRegex()))
}
}
// Run the build.
test(
"syncFramework",
"-Pkotlin.native.cocoapods.target=ios_x64,ios_arm64",
"-Pkotlin.native.cocoapods.configuration=DEBUG"
)
}
}

// paths

private fun CompiledProject.url() = externalSources().resolve("url")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ open class KotlinCocoapodsPlugin : Plugin<Project> {
val frameworkPlatforms: List<KonanTarget> = when (requestedTargetName) {
KOTLIN_TARGET_FOR_IOS_DEVICE -> listOf(IOS_ARM64, IOS_ARM32)
KOTLIN_TARGET_FOR_WATCHOS_DEVICE -> listOf(WATCHOS_ARM32, WATCHOS_ARM64)
else -> listOf(HostManager().targetByName(requestedTargetName)) // A requested target doesn't require building a fat framework.
// A request parameter can be comma separated list of targets.
else -> requestedTargetName.split(",").map { HostManager().targetByName(it) }.toList()
}

val frameworkTargets = frameworkPlatforms.flatMap { kotlinExtension.targetsForPlatform(it) }
Expand Down