Skip to content

Commit

Permalink
Move FatFrameworkConfiguration back to main plugin to temporarily fix…
Browse files Browse the repository at this point in the history
… configuration cache.
  • Loading branch information
FilipDolnik committed May 9, 2024
1 parent fa596ee commit 1704c2a
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ interface KgpShim {

fun addKmpAttributes(attributeContainer: AttributeContainer, konanTarget: KonanTargetShim)

fun configureSkieForFatFrameworks()
fun initializeDarwinTargets()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package co.touchlab.skie.plugin.util

data class DarwinTarget(
// val konanTarget: KonanTarget,
val konanTargetName: String,
val targetTriple: TargetTriple,
val sdk: String,
) {

constructor(
// konanTarget: KonanTarget,
konanTargetName: String,
targetTripleString: String,
sdk: String,
) : this(
// konanTarget,
konanTargetName,
TargetTriple.fromString(targetTripleString), sdk,
)

companion object {

lateinit var allTargets: Map<String, DarwinTarget>
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package co.touchlab.skie.plugin.util
*
* @see <a href="https://clang.llvm.org/docs/CrossCompilation.html#target-triple">Clang documentation for target triple</a>.
*/
internal data class TargetTriple(
data class TargetTriple(
val architecture: String,
val vendor: String,
val os: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import org.jetbrains.kotlin.konan.target.KonanTarget

internal actual fun getAllSupportedDarwinTargets(): List<DarwinTarget> =
listOf(
DarwinTarget(KonanTarget.IOS_ARM32, "armv7-apple-ios", "iphoneos"),
DarwinTarget(KonanTarget.IOS_ARM64, "arm64-apple-ios", "iphoneos"),
DarwinTarget(KonanTarget.IOS_X64, "x86_64-apple-ios-simulator", "iphonesimulator"),
DarwinTarget(KonanTarget.IOS_SIMULATOR_ARM64, "arm64-apple-ios-simulator", "iphonesimulator"),
DarwinTarget(KonanTarget.WATCHOS_ARM32, "armv7k-apple-watchos", "watchos"),
DarwinTarget(KonanTarget.WATCHOS_ARM64, "arm64_32-apple-watchos", "watchos"),
DarwinTarget(KonanTarget.WATCHOS_DEVICE_ARM64, "arm64-apple-watchos", "watchos"),
DarwinTarget(KonanTarget.WATCHOS_X86, "i386-apple-watchos-simulator", "watchsimulator"),
DarwinTarget(KonanTarget.WATCHOS_X64, "x86_64-apple-watchos-simulator", "watchsimulator"),
DarwinTarget(KonanTarget.WATCHOS_SIMULATOR_ARM64, "arm64-apple-watchos-simulator", "watchsimulator"),
DarwinTarget(KonanTarget.TVOS_ARM64, "arm64-apple-tvos", "appletvos"),
DarwinTarget(KonanTarget.TVOS_X64, "x86_64-apple-tvos-simulator", "appletvsimulator"),
DarwinTarget(KonanTarget.TVOS_SIMULATOR_ARM64, "arm64-apple-tvos-simulator", "appletvsimulator"),
DarwinTarget(KonanTarget.MACOS_X64, "x86_64-apple-macos", "macosx"),
DarwinTarget(KonanTarget.MACOS_ARM64, "arm64-apple-macos", "macosx"),
DarwinTarget(KonanTarget.IOS_ARM32.name, "armv7-apple-ios", "iphoneos"),
DarwinTarget(KonanTarget.IOS_ARM64.name, "arm64-apple-ios", "iphoneos"),
DarwinTarget(KonanTarget.IOS_X64.name, "x86_64-apple-ios-simulator", "iphonesimulator"),
DarwinTarget(KonanTarget.IOS_SIMULATOR_ARM64.name, "arm64-apple-ios-simulator", "iphonesimulator"),
DarwinTarget(KonanTarget.WATCHOS_ARM32.name, "armv7k-apple-watchos", "watchos"),
DarwinTarget(KonanTarget.WATCHOS_ARM64.name, "arm64_32-apple-watchos", "watchos"),
DarwinTarget(KonanTarget.WATCHOS_DEVICE_ARM64.name, "arm64-apple-watchos", "watchos"),
DarwinTarget(KonanTarget.WATCHOS_X86.name, "i386-apple-watchos-simulator", "watchsimulator"),
DarwinTarget(KonanTarget.WATCHOS_X64.name, "x86_64-apple-watchos-simulator", "watchsimulator"),
DarwinTarget(KonanTarget.WATCHOS_SIMULATOR_ARM64.name, "arm64-apple-watchos-simulator", "watchsimulator"),
DarwinTarget(KonanTarget.TVOS_ARM64.name, "arm64-apple-tvos", "appletvos"),
DarwinTarget(KonanTarget.TVOS_X64.name, "x86_64-apple-tvos-simulator", "appletvsimulator"),
DarwinTarget(KonanTarget.TVOS_SIMULATOR_ARM64.name, "arm64-apple-tvos-simulator", "appletvsimulator"),
DarwinTarget(KonanTarget.MACOS_X64.name, "x86_64-apple-macos", "macosx"),
DarwinTarget(KonanTarget.MACOS_ARM64.name, "arm64-apple-macos", "macosx"),
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import org.jetbrains.kotlin.konan.target.KonanTarget

internal actual fun getAllSupportedDarwinTargets(): List<DarwinTarget> =
listOf(
DarwinTarget(KonanTarget.IOS_ARM64, "arm64-apple-ios", "iphoneos"),
DarwinTarget(KonanTarget.IOS_X64, "x86_64-apple-ios-simulator", "iphonesimulator"),
DarwinTarget(KonanTarget.IOS_SIMULATOR_ARM64, "arm64-apple-ios-simulator", "iphonesimulator"),
DarwinTarget(KonanTarget.WATCHOS_ARM32, "armv7k-apple-watchos", "watchos"),
DarwinTarget(KonanTarget.WATCHOS_ARM64, "arm64_32-apple-watchos", "watchos"),
DarwinTarget(KonanTarget.WATCHOS_DEVICE_ARM64, "arm64-apple-watchos", "watchos"),
DarwinTarget(KonanTarget.WATCHOS_X64, "x86_64-apple-watchos-simulator", "watchsimulator"),
DarwinTarget(KonanTarget.WATCHOS_SIMULATOR_ARM64, "arm64-apple-watchos-simulator", "watchsimulator"),
DarwinTarget(KonanTarget.TVOS_ARM64, "arm64-apple-tvos", "appletvos"),
DarwinTarget(KonanTarget.TVOS_X64, "x86_64-apple-tvos-simulator", "appletvsimulator"),
DarwinTarget(KonanTarget.TVOS_SIMULATOR_ARM64, "arm64-apple-tvos-simulator", "appletvsimulator"),
DarwinTarget(KonanTarget.MACOS_X64, "x86_64-apple-macos", "macosx"),
DarwinTarget(KonanTarget.MACOS_ARM64, "arm64-apple-macos", "macosx"),
DarwinTarget(KonanTarget.IOS_ARM64.name, "arm64-apple-ios", "iphoneos"),
DarwinTarget(KonanTarget.IOS_X64.name, "x86_64-apple-ios-simulator", "iphonesimulator"),
DarwinTarget(KonanTarget.IOS_SIMULATOR_ARM64.name, "arm64-apple-ios-simulator", "iphonesimulator"),
DarwinTarget(KonanTarget.WATCHOS_ARM32.name, "armv7k-apple-watchos", "watchos"),
DarwinTarget(KonanTarget.WATCHOS_ARM64.name, "arm64_32-apple-watchos", "watchos"),
DarwinTarget(KonanTarget.WATCHOS_DEVICE_ARM64.name, "arm64-apple-watchos", "watchos"),
DarwinTarget(KonanTarget.WATCHOS_X64.name, "x86_64-apple-watchos-simulator", "watchsimulator"),
DarwinTarget(KonanTarget.WATCHOS_SIMULATOR_ARM64.name, "arm64-apple-watchos-simulator", "watchsimulator"),
DarwinTarget(KonanTarget.TVOS_ARM64.name, "arm64-apple-tvos", "appletvos"),
DarwinTarget(KonanTarget.TVOS_X64.name, "x86_64-apple-tvos-simulator", "appletvsimulator"),
DarwinTarget(KonanTarget.TVOS_SIMULATOR_ARM64.name, "arm64-apple-tvos-simulator", "appletvsimulator"),
DarwinTarget(KonanTarget.MACOS_X64.name, "x86_64-apple-macos", "macosx"),
DarwinTarget(KonanTarget.MACOS_ARM64.name, "arm64-apple-macos", "macosx"),
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package co.touchlab.skie.plugin.shim
import co.touchlab.skie.plugin.ActualSkieArtifactTarget
import co.touchlab.skie.plugin.ActualSkieBinaryTarget
import co.touchlab.skie.plugin.SkieTarget
import co.touchlab.skie.plugin.fatframework.FatFrameworkConfigurator
import co.touchlab.skie.plugin.util.DarwinTarget
import co.touchlab.skie.plugin.util.appleTargets
import co.touchlab.skie.plugin.util.getAllSupportedDarwinTargets
import co.touchlab.skie.plugin.util.kotlinMultiplatformExtension
import co.touchlab.skie.plugin.util.named
import co.touchlab.skie.plugin.util.withType
Expand Down Expand Up @@ -90,7 +91,7 @@ class ActualKgpShim(
}
}

override fun configureSkieForFatFrameworks() {
FatFrameworkConfigurator.configureSkieForFatFrameworks(project)
override fun initializeDarwinTargets() {
DarwinTarget.allTargets = getAllSupportedDarwinTargets().associateBy { it.konanTargetName }
}
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,3 @@
package co.touchlab.skie.plugin.util

import org.jetbrains.kotlin.gradle.tasks.FrameworkDescriptor
import org.jetbrains.kotlin.konan.target.KonanTarget

internal data class DarwinTarget(
val konanTarget: KonanTarget,
val targetTriple: TargetTriple,
val sdk: String,
) {

constructor(
konanTarget: KonanTarget,
targetTripleString: String,
sdk: String,
) : this(konanTarget, TargetTriple.fromString(targetTripleString), sdk)

companion object {

val allTargets: Map<String, DarwinTarget> = getAllSupportedDarwinTargets().associateBy { it.konanTarget.name }
}
}

internal expect fun getAllSupportedDarwinTargets(): List<DarwinTarget>

internal val FrameworkDescriptor.darwinTarget: DarwinTarget
get() = target.darwinTarget

internal val KonanTarget.darwinTarget: DarwinTarget
// We can't use `KotlinTarget` directly as the instance can differ when Gradle Configuration Cache is used
get() = DarwinTarget.allTargets[name] ?: error("Unknown konan target: $this")
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import co.touchlab.skie.plugin.coroutines.configureMinOsVersionIfNeeded
import co.touchlab.skie.plugin.defaultarguments.disableCachingIfNeeded
import co.touchlab.skie.plugin.dependencies.SkieCompilerPluginDependencyProvider
import co.touchlab.skie.plugin.directory.SkieDirectoriesManager
import co.touchlab.skie.plugin.fatframework.FatFrameworkConfigurator
import co.touchlab.skie.plugin.subplugin.SkieSubPluginManager
import co.touchlab.skie.plugin.switflink.SwiftLinkingConfigurator
import co.touchlab.skie.plugin.util.toKotlinCompilerPluginOption
Expand All @@ -27,6 +28,8 @@ abstract class SkieGradlePlugin : Plugin<Project> {

project.afterEvaluate {
project.configureSkieCompilerPlugin()

kgpShim.initializeDarwinTargets()
}
}

Expand All @@ -41,7 +44,7 @@ abstract class SkieGradlePlugin : Plugin<Project> {

warnOnEmptyFrameworks()

kgpShim.configureSkieForFatFrameworks()
FatFrameworkConfigurator.configureSkieForFatFrameworks(project)

kgpShim.initializeSkieTargets()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package co.touchlab.skie.plugin.util

import org.jetbrains.kotlin.gradle.tasks.FrameworkDescriptor
import org.jetbrains.kotlin.konan.target.KonanTarget

internal val FrameworkDescriptor.darwinTarget: DarwinTarget
get() = target.darwinTarget

internal val KonanTarget.darwinTarget: DarwinTarget
// We can't use `KotlinTarget` directly as the instance can differ when Gradle Configuration Cache is used
get() = DarwinTarget.allTargets[name] ?: error("Unknown konan target: $this")

0 comments on commit 1704c2a

Please sign in to comment.