Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cwebp for macosx support #411

Merged
merged 1 commit into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ object OS {

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

val arch: String = try {
"arch".execute().stdout.trim().lowercase()
val arch: String = System.getProperty("os.arch", "").lowercase()

val uname = try {
"uname -a".execute().stdout.trim().lowercase()
} catch (e: Throwable) {
System.getProperty("os.arch", "").lowercase()
arch
}

val version = object : Comparable<String> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Cwebp internal constructor(val supportAlpha: Boolean) : CompressionTool(Co
true -> CwebpCompressOpaqueFlatImages::class
else -> CwebpCompressFlatImages::class
}

else -> when (supportAlpha) {
true -> CwebpCompressOpaqueImages::class
else -> CwebpCompressImages::class
Expand Down Expand Up @@ -50,27 +51,29 @@ class Cwebp internal constructor(val supportAlpha: Boolean) : CompressionTool(Co

}

private val X64 = setOf("x64", "x86_64", "amd64")

internal val CWEBP = "$PROGRAM${OS.executableSuffix}"

internal val PREBUILT_CWEBP_EXECUTABLE = "bin/" + when {
OS.isLinux() -> "linux/" + when (OS.arch) {
"x64", "x86_64", "amd64" -> "x64"
else -> TODO("Unsupported architecture ${OS.arch}")
OS.isLinux() -> {
"linux/" + if (OS.arch in X64) "x64" else TODO("Unsupported architecture ${OS.arch}")
}
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}")
OS.isMac() -> {
"macosx/" + when {
"arm64" == OS.arch || "arm64" in OS.uname -> "arm64"
OS.arch in X64 -> "x64/" + 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}")
}
else -> TODO("Unsupported architecture ${OS.arch}")
}
OS.isWindows() -> "windows/" + when (OS.arch) {
"x64", "x86_64", "amd64" -> "x64"
else -> TODO("Unsupported architecture ${OS.arch}")
OS.isWindows() -> {
"windows/" + if (OS.arch in X64) "x64" else TODO("Unsupported architecture ${OS.arch}")
}
else -> TODO("Unsupported OS ${OS.name}")
} + "/$CWEBP"
Expand Down