Skip to content

Commit d2c83f0

Browse files
committed
Apple M1 chipset support for cwebp
1 parent 92ca526 commit d2c83f0

File tree

6 files changed

+15
-10
lines changed
  • booster-kotlinx/src/main/kotlin/com/didiglobal/booster/kotlinx
  • booster-task-compression-cwebp/src/main

6 files changed

+15
-10
lines changed

booster-kotlinx/src/main/kotlin/com/didiglobal/booster/kotlinx/OS.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ object OS {
44

55
val name: String = System.getProperty("os.name", "").lowercase()
66

7-
val arch: String = System.getProperty("os.arch", "").lowercase()
7+
val arch: String = try {
8+
"arch".execute().stdout.trim().lowercase()
9+
} catch (e: Throwable) {
10+
System.getProperty("os.arch", "").lowercase()
11+
}
812

913
val version = object : Comparable<String> {
1014

@@ -62,8 +66,6 @@ object OS {
6266

6367
fun isMac() = name.startsWith("mac")
6468

65-
fun isArm64Chip() = arch.startsWith("aarch64")
66-
6769
fun isWindows() = name.startsWith("windows")
6870

6971
}

booster-task-compression-cwebp/src/main/kotlin/com/didiglobal/booster/task/compression/cwebp/Cwebp.kt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,16 @@ internal val PREBUILT_CWEBP_EXECUTABLE = "bin/" + when {
5757
"x64", "x86_64", "amd64" -> "x64"
5858
else -> TODO("Unsupported architecture ${OS.arch}")
5959
}
60-
OS.isMac() -> "macosx/" + when {
61-
OS.isArm64Chip() -> "arm64"
62-
OS.version >= "10.15" -> "10.15"
63-
OS.version >= "10.14" -> "10.14"
64-
OS.version >= "10.13" -> "10.13"
65-
OS.version >= "10.12" -> "10.12"
66-
else -> TODO("Unsupported system version ${OS.version}")
60+
OS.isMac() -> "macosx/" + when (OS.arch) {
61+
"arm64" -> "arm64"
62+
"x86_64" -> "x86_64/" + when {
63+
OS.version >= "10.15" -> "10.15"
64+
OS.version >= "10.14" -> "10.14"
65+
OS.version >= "10.13" -> "10.13"
66+
OS.version >= "10.12" -> "10.12"
67+
else -> TODO("Unsupported system version ${OS.version}")
68+
}
69+
else -> TODO("Unsupported architecture ${OS.arch}")
6770
}
6871
OS.isWindows() -> "windows/" + when (OS.arch) {
6972
"x64", "x86_64", "amd64" -> "x64"

booster-task-compression-cwebp/src/main/resources/bin/macosx/10.12/cwebp renamed to booster-task-compression-cwebp/src/main/resources/bin/macosx/x86_64/10.12/cwebp

File renamed without changes.

booster-task-compression-cwebp/src/main/resources/bin/macosx/10.13/cwebp renamed to booster-task-compression-cwebp/src/main/resources/bin/macosx/x86_64/10.13/cwebp

File renamed without changes.

booster-task-compression-cwebp/src/main/resources/bin/macosx/10.14/cwebp renamed to booster-task-compression-cwebp/src/main/resources/bin/macosx/x86_64/10.14/cwebp

File renamed without changes.

booster-task-compression-cwebp/src/main/resources/bin/macosx/10.15/cwebp renamed to booster-task-compression-cwebp/src/main/resources/bin/macosx/x86_64/10.15/cwebp

File renamed without changes.

0 commit comments

Comments
 (0)