Skip to content

Commit

Permalink
Apple M1 chipset support for cwebp
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsonlee committed Apr 11, 2023
1 parent 92ca526 commit d2c83f0
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {

Expand Down Expand Up @@ -62,8 +66,6 @@ object OS {

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

fun isArm64Chip() = arch.startsWith("aarch64")

fun isWindows() = name.startsWith("windows")

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit d2c83f0

Please sign in to comment.