Skip to content

Commit ac3f280

Browse files
committed
If uname returns x86_64 on Mac, use x64 binary #214
Even if we were launched by aarch64 Java, see #204 for discussion.
1 parent 460e68d commit ac3f280

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/main/kotlin/com/github/gradle/node/util/PlatformHelper.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ open class PlatformHelper {
2424
*/
2525
arch == "arm" || arch.startsWith("aarch") -> property("uname")
2626
.mapIf({ it == "armv8l" || it == "aarch64" }) { "arm64" }
27+
.mapIf({ it == "x86_64" }) {"x64"}
2728
arch == "ppc64le" -> "ppc64le"
2829
arch == "s390x" -> "s390x"
2930
arch.contains("64") -> "x64"

src/test/groovy/com/github/gradle/node/util/PlatformHelperTest.groovy

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,25 @@ class PlatformHelperTest extends Specification {
5858
'ppc64le' | 'ppc64le' | 'ppc64le'
5959
}
6060

61+
@Unroll
62+
def "verify ARM handling Mac OS #archProp (#unameProp)"() {
63+
given:
64+
this.props.setProperty("os.name", "Mac OS X")
65+
this.props.setProperty("os.arch", archProp)
66+
this.props.setProperty("uname", unameProp)
67+
68+
expect:
69+
this.helper.getOsName() == "darwin"
70+
this.helper.getOsArch() == osArch
71+
72+
where:
73+
archProp | unameProp | osArch
74+
'aarch32' | 'arm' | 'arm'
75+
'aarch64' | 'arm64' | 'arm64'
76+
'aarch64' | 'aarch64' | 'arm64'
77+
'aarch64' | 'x86_64' | 'x64' // This shouldn't really happen but according to PR #204 it does
78+
}
79+
6180
def "throw exception if unsupported os"() {
6281
given:
6382
this.props.setProperty("os.name", 'Nonsense')

0 commit comments

Comments
 (0)