Skip to content

Commit

Permalink
#154 Use the x64 Node.js bundle on Mac Silicon systems until the spec…
Browse files Browse the repository at this point in the history
…ific bundle is available.
  • Loading branch information
bsautel committed Mar 19, 2021
1 parent 9087183 commit 4f9855c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/main/kotlin/com/github/gradle/node/util/PlatformHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ open class PlatformHelper constructor(private val props: Properties = System.get
open val osArch: String by lazy {
val arch = property("os.arch").toLowerCase()
when {
//
osName == "darwin" && arch == "aarch64" -> "x64"
/*
* As Java just returns "arm" on all ARM variants, we need a system call to determine the exact arch. Unfortunately some JVMs say aarch32/64, so we need an additional
* conditional. Additionally, the node binaries for 'armv8l' are called 'arm64', so we need to distinguish here.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,23 @@ class PlatformHelperTest extends Specification {
@Unroll
def "verify ARM handling #archProp (#unameProp)"() {
given:
this.props.setProperty("os.name", "Linux")
this.props.setProperty("os.name", osProp)
this.props.setProperty("os.arch", archProp)
this.props.setProperty("uname", unameProp)

expect:
this.helper.getOsName() == "linux"
this.helper.getOsName() == osName
this.helper.getOsArch() == osArch

where:
archProp | unameProp | osArch
'arm' | 'armv7l' | 'armv7l' // Raspberry Pi 3
'arm' | 'armv8l' | 'arm64'
'aarch32' | 'arm' | 'arm'
'aarch64' | 'arm64' | 'arm64'
'aarch64' | 'aarch64' | 'arm64'
osProp | archProp | unameProp | osName | osArch
'Linux' | 'arm' | 'armv7l' | 'linux' | 'armv7l' // Raspberry Pi 3
'Linux' | 'arm' | 'armv8l' | 'linux' | 'arm64'
'Linux' | 'aarch32' | 'arm' | 'linux' | 'arm'
'Linux' | 'aarch64' | 'arm64' | 'linux' | 'arm64'
'Linux' | 'aarch64' | 'aarch64' | 'linux' | 'arm64'
// Apple Silicon, we use the x64 emulation until a Node.js bundle is provided for the platform
'Mac OS X' | 'aarch64' | 'arm64' | 'darwin' | 'x64'
}

def "throw exception if unsupported os"() {
Expand Down

0 comments on commit 4f9855c

Please sign in to comment.