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

Proper Mac M1 support, updated node, npm and yarn #204

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions src/main/kotlin/com/github/gradle/node/util/PlatformHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,30 @@ open class PlatformHelper constructor(private val props: Properties = System.get

open val osArch: String by lazy {
val arch = property("os.arch").toLowerCase()
when {
/*
* 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.
*/
arch == "arm" || arch.startsWith("aarch") -> property("uname")
.mapIf({ it == "armv8l" || it == "aarch64" }) { "arm64" }
arch == "ppc64le" -> "ppc64le"
arch == "s390x" -> "s390x"
arch.contains("64") -> "x64"
else -> "x86"
when (osName) {
"darwin" -> {
/**
* As "uname" in M1 Mac always returns "x86_64" value it's not possible to determine in general way
* (as below) correct architecture. The good way first to check for osName and then decide the arch.
*/
if (arch == "aarch64") {
return@lazy "arm64"
} else {
return@lazy "x86"
}
}
else -> when {
/*
* 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.
*/
arch == "arm" || arch.startsWith("aarch") -> property("uname")
.mapIf({ it == "armv8l" || it == "aarch64" }) { "arm64" }
arch == "ppc64le" -> "ppc64le"
arch == "s390x" -> "s390x"
arch.contains("64") -> "x64"
else -> "x86"
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class NpmInstall_integTest extends AbstractIntegTest {

node {
download = true
version = '15.2.1'
npmVersion = '7.0.1'
version = '17.1.0'
npmVersion = '8.1.0'
}
''')
writeEmptyPackageJson()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class YarnInstall_integTest extends AbstractIntegTest {
node {
download = true
yarnWorkDir = file('build/yarn')
version = '15.2.1'
npmVersion = '7.0.1'
version = '17.1.0'
npmVersion = '8.1.0'
}
''')
writeEmptyPackageJson()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

node {
version = "12.13.0"
version = "17.1.0"
distBaseUrl = "http://nodejs.org/dist/"
download = true
allowInsecureProtocol = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

node {
version = "12.13.0"
version = "17.1.0"
distBaseUrl = "https://nodejs.org/dist/"
download = true
allowInsecureProtocol = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

node {
version = "12.13.0"
version = "17.1.0"
distBaseUrl = null
download = true
workDir = file("build/node")
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/fixtures/node/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

node {
version = "12.13.0"
version = "17.1.0"
download = true
workDir = file("build/node")
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/fixtures/npm/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
def changeInputs = isPropertyEnabled("changeInputs")

node {
npmVersion = "6.12.0"
npmVersion = "8.1.0"
download = true
workDir = file('build/node')
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/fixtures/npx/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

node {
npmVersion = "6.12.0"
npmVersion = "8.1.0"
download = true
workDir = file("build/node")
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/fixtures/yarn/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
def changeInputs = isPropertyEnabled("changeInputs")

node {
yarnVersion = "1.18.0"
yarnVersion = "1.22.17"
download = true
workDir = file("build/node")
}
Expand Down