diff --git a/booster-kotlinx/src/main/kotlin/com/didiglobal/booster/kotlinx/OS.kt b/booster-kotlinx/src/main/kotlin/com/didiglobal/booster/kotlinx/OS.kt index 7a2c7bd71..bbcd6b27a 100644 --- a/booster-kotlinx/src/main/kotlin/com/didiglobal/booster/kotlinx/OS.kt +++ b/booster-kotlinx/src/main/kotlin/com/didiglobal/booster/kotlinx/OS.kt @@ -4,7 +4,11 @@ object OS { val name: String = System.getProperty("os.name", "").lowercase() - val arch: String = System.getProperty("os.arch", "").lowercase() + val arch: String = try { + "arch".execute().stdout.trim().lowercase() + } catch (e: Throwable) { + System.getProperty("os.arch", "").lowercase() + } val version = object : Comparable { @@ -62,8 +66,6 @@ object OS { fun isMac() = name.startsWith("mac") - fun isArm64Chip() = arch.startsWith("aarch64") - fun isWindows() = name.startsWith("windows") } diff --git a/booster-task-compression-cwebp/src/main/kotlin/com/didiglobal/booster/task/compression/cwebp/Cwebp.kt b/booster-task-compression-cwebp/src/main/kotlin/com/didiglobal/booster/task/compression/cwebp/Cwebp.kt index 40db9a806..ba56ed1b7 100644 --- a/booster-task-compression-cwebp/src/main/kotlin/com/didiglobal/booster/task/compression/cwebp/Cwebp.kt +++ b/booster-task-compression-cwebp/src/main/kotlin/com/didiglobal/booster/task/compression/cwebp/Cwebp.kt @@ -57,13 +57,16 @@ internal val PREBUILT_CWEBP_EXECUTABLE = "bin/" + when { "x64", "x86_64", "amd64" -> "x64" else -> TODO("Unsupported architecture ${OS.arch}") } - OS.isMac() -> "macosx/" + when { - OS.isArm64Chip() -> "arm64" - OS.version >= "10.15" -> "10.15" - OS.version >= "10.14" -> "10.14" - OS.version >= "10.13" -> "10.13" - OS.version >= "10.12" -> "10.12" - else -> TODO("Unsupported system version ${OS.version}") + OS.isMac() -> "macosx/" + when (OS.arch) { + "arm64" -> "arm64" + "x86_64" -> "x86_64/" + when { + OS.version >= "10.15" -> "10.15" + OS.version >= "10.14" -> "10.14" + OS.version >= "10.13" -> "10.13" + OS.version >= "10.12" -> "10.12" + else -> TODO("Unsupported system version ${OS.version}") + } + else -> TODO("Unsupported architecture ${OS.arch}") } OS.isWindows() -> "windows/" + when (OS.arch) { "x64", "x86_64", "amd64" -> "x64" diff --git a/booster-task-compression-cwebp/src/main/resources/bin/macosx/10.12/cwebp b/booster-task-compression-cwebp/src/main/resources/bin/macosx/x86_64/10.12/cwebp similarity index 100% rename from booster-task-compression-cwebp/src/main/resources/bin/macosx/10.12/cwebp rename to booster-task-compression-cwebp/src/main/resources/bin/macosx/x86_64/10.12/cwebp diff --git a/booster-task-compression-cwebp/src/main/resources/bin/macosx/10.13/cwebp b/booster-task-compression-cwebp/src/main/resources/bin/macosx/x86_64/10.13/cwebp similarity index 100% rename from booster-task-compression-cwebp/src/main/resources/bin/macosx/10.13/cwebp rename to booster-task-compression-cwebp/src/main/resources/bin/macosx/x86_64/10.13/cwebp diff --git a/booster-task-compression-cwebp/src/main/resources/bin/macosx/10.14/cwebp b/booster-task-compression-cwebp/src/main/resources/bin/macosx/x86_64/10.14/cwebp similarity index 100% rename from booster-task-compression-cwebp/src/main/resources/bin/macosx/10.14/cwebp rename to booster-task-compression-cwebp/src/main/resources/bin/macosx/x86_64/10.14/cwebp diff --git a/booster-task-compression-cwebp/src/main/resources/bin/macosx/10.15/cwebp b/booster-task-compression-cwebp/src/main/resources/bin/macosx/x86_64/10.15/cwebp similarity index 100% rename from booster-task-compression-cwebp/src/main/resources/bin/macosx/10.15/cwebp rename to booster-task-compression-cwebp/src/main/resources/bin/macosx/x86_64/10.15/cwebp