[K/N][perf] Adopt benchmarks plugins and tools to support both macosX64 and macosArm64
This commit is contained in:
@@ -33,6 +33,9 @@ internal val Project.kotlin: KotlinMultiplatformExtension
|
||||
internal val NamedDomainObjectCollection<KotlinTargetPreset<*>>.macosX64: KotlinTargetPreset<*>
|
||||
get() = getByName(::macosX64.name)
|
||||
|
||||
internal val NamedDomainObjectCollection<KotlinTargetPreset<*>>.macosArm64: KotlinTargetPreset<*>
|
||||
get() = getByName(::macosArm64.name)
|
||||
|
||||
internal val NamedDomainObjectCollection<KotlinTargetPreset<*>>.linuxX64: KotlinTargetPreset<*>
|
||||
get() = getByName(::linuxX64.name)
|
||||
|
||||
|
||||
@@ -44,14 +44,17 @@ val kotlinNativeDataPath by lazy {
|
||||
@JvmOverloads
|
||||
fun defaultHostPreset(
|
||||
subproject: Project,
|
||||
whitelist: List<KotlinTargetPreset<*>> = listOf(subproject.kotlin.presets.macosX64, subproject.kotlin.presets.linuxX64, subproject.kotlin.presets.mingwX64)
|
||||
whitelist: List<KotlinTargetPreset<*>> = listOf(subproject.kotlin.presets.macosX64, subproject.kotlin.presets.macosArm64,
|
||||
subproject.kotlin.presets.linuxX64, subproject.kotlin.presets.mingwX64)
|
||||
): KotlinTargetPreset<*> {
|
||||
|
||||
if (whitelist.isEmpty())
|
||||
throw Exception("Preset whitelist must not be empty in Kotlin/Native ${subproject.displayName}.")
|
||||
|
||||
val presetCandidate = when {
|
||||
PlatformInfo.isMac() -> subproject.kotlin.presets.macosX64
|
||||
PlatformInfo.isMac() -> if (PlatformInfo.hostName.endsWith("x64"))
|
||||
subproject.kotlin.presets.macosX64
|
||||
else subproject.kotlin.presets.macosArm64
|
||||
PlatformInfo.isLinux() -> subproject.kotlin.presets.linuxX64
|
||||
PlatformInfo.isWindows() -> subproject.kotlin.presets.mingwX64
|
||||
else -> null
|
||||
|
||||
@@ -12,6 +12,10 @@ object PlatformInfo {
|
||||
@JvmStatic
|
||||
fun isLinux() = HostManager.hostIsLinux
|
||||
|
||||
@JvmStatic
|
||||
val hostName: String
|
||||
get() = HostManager.hostName
|
||||
|
||||
@JvmStatic
|
||||
fun isAppleTarget(project: Project): Boolean {
|
||||
val target = getTarget(project)
|
||||
|
||||
+4
-1
@@ -64,7 +64,10 @@ open class SwiftBenchmarkingPlugin : BenchmarkingPlugin() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun Project.determinePreset(): AbstractKotlinNativeTargetPreset<*> = kotlin.presets.macosX64 as AbstractKotlinNativeTargetPreset<*>
|
||||
override fun Project.determinePreset(): AbstractKotlinNativeTargetPreset<*> =
|
||||
defaultHostPreset(this).also { preset ->
|
||||
logger.quiet("$project has been configured for ${preset.name} platform.")
|
||||
} as AbstractKotlinNativeTargetPreset<*>
|
||||
|
||||
override fun KotlinNativeTarget.configureNativeOutput(project: Project) {
|
||||
binaries.framework(nativeFrameworkName, listOf(project.benchmark.buildType)) {
|
||||
|
||||
@@ -140,7 +140,11 @@ private static String getAnalyzerTargetName() {
|
||||
String target = System.getProperty("os.name")
|
||||
if (target == 'Linux') return 'linux'
|
||||
if (target.startsWith('Windows')) return 'windows'
|
||||
if (target.startsWith('Mac')) return 'macos'
|
||||
if (target.startsWith('Mac'))
|
||||
if (System.getProperty("os.arch") == "aarch64")
|
||||
return 'macosArm64'
|
||||
else
|
||||
return 'macosX64'
|
||||
return 'unknown'
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ def getHostName() {
|
||||
if (target == 'Linux') return 'linux'
|
||||
if (target.startsWith('Windows')) return 'windows'
|
||||
if (target.startsWith('Mac'))
|
||||
if (System.getProperty("os.name") == "aarch64")
|
||||
if (System.getProperty("os.arch") == "aarch64")
|
||||
return 'macosArm64'
|
||||
else
|
||||
return 'macosX64'
|
||||
|
||||
Reference in New Issue
Block a user