-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from wttech/os-util
True ARM64 detection including Rosetta emulation
- Loading branch information
Showing
5 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
version=1.1.7 | ||
version=1.1.8 | ||
release.useAutomaticVersion=true | ||
|
||
# Performance tuning | ||
|
20 changes: 20 additions & 0 deletions
20
src/main/kotlin/com/cognifide/gradle/common/build/PropertyGroup.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.cognifide.gradle.common.build | ||
|
||
class PropertyGroup(val parser: PropertyParser, val group: String, val member: String) { | ||
|
||
fun string(prop: String) = parser.string("$group.$member.$prop") ?: parser.string("$group.$DEFAULT.$prop") | ||
|
||
fun strings(prop: String) = parser.list("$group.$member.$prop") ?: parser.list("$group.$DEFAULT.$prop") | ||
|
||
fun int(prop: String) = parser.int("$group.$member.$prop") ?: parser.int("$group.$DEFAULT.$prop") | ||
|
||
fun long(prop: String) = parser.long("$group.$member.$prop") ?: parser.long("$group.$DEFAULT.$prop") | ||
|
||
fun boolean(prop: String) = parser.boolean("$group.$member.$prop") ?: parser.boolean("$group.$DEFAULT.$prop") | ||
|
||
fun file(prop: String) = parser.file("$group.$member.$prop") ?: parser.file("$group.$member.$DEFAULT") | ||
|
||
companion object { | ||
const val DEFAULT = "default" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.cognifide.gradle.common.os | ||
|
||
import org.buildobjects.process.ProcBuilder | ||
import org.gradle.internal.os.OperatingSystem | ||
|
||
object OSUtil { | ||
|
||
fun arch() = System.getProperty("os.arch") | ||
|
||
fun archOfHost() = if (detectRosetta()) "arm64" else arch() | ||
|
||
fun detectRosetta(): Boolean = OperatingSystem.current().isMacOsX && | ||
exec("sysctl", "-n", "sysctl.proc_translated").trim() == "1" | ||
|
||
@Suppress("SpreadOperator") | ||
fun exec(command: String, vararg args: String) = ProcBuilder(command) | ||
.withArgs(*args) | ||
.ignoreExitStatus() | ||
.run().outputString | ||
} |