From 545447834ff87ba1d070521a26c6149862d1f22a Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Tue, 8 Jun 2021 10:56:16 -0700 Subject: [PATCH] fix(builtin): add two missing locations where Mac M1 support needs to be declared Fixes #2733 --- internal/common/os_name.bzl | 38 +++++++++++++++++------------ internal/node/node_repositories.bzl | 1 + 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/internal/common/os_name.bzl b/internal/common/os_name.bzl index 586d98b397..6e2245164e 100644 --- a/internal/common/os_name.bzl +++ b/internal/common/os_name.bzl @@ -16,8 +16,9 @@ """ OS_ARCH_NAMES = [ - ("darwin", "amd64"), ("windows", "amd64"), + ("darwin", "amd64"), + ("darwin", "arm64"), ("linux", "amd64"), ("linux", "arm64"), ("linux", "s390x"), @@ -35,28 +36,33 @@ def os_name(rctx): A string describing the os for a repository rule """ os_name = rctx.os.name.lower() - if os_name.startswith("mac os"): + if os_name.find("windows") != -1: return OS_NAMES[0] - elif os_name.find("windows") != -1: - return OS_NAMES[1] + + # This is not ideal, but bazel doesn't directly expose arch. + arch = rctx.execute(["uname", "-m"]).stdout.strip() + if os_name.startswith("mac os"): + if arch == "x86_64": + return OS_NAMES[1] + elif arch == "arm64": + return OS_NAMES[2] elif os_name.startswith("linux"): - # This is not ideal, but bazel doesn't directly expose arch. - arch = rctx.execute(["uname", "-m"]).stdout.strip() - if arch == "aarch64": + if arch == "x86_64": return OS_NAMES[3] - elif arch == "s390x": + elif arch == "aarch64": return OS_NAMES[4] - else: - return OS_NAMES[2] - else: - fail("Unsupported operating system: " + os_name) + elif arch == "s390x": + return OS_NAMES[5] -def is_darwin_os(rctx): - return os_name(rctx) == OS_NAMES[0] + fail("Unsupported operating system: " + os_name) def is_windows_os(rctx): - return os_name(rctx) == OS_NAMES[1] + return os_name(rctx) == OS_NAMES[0] + +def is_darwin_os(rctx): + name = os_name(rctx) + return name == OS_NAMES[1] or name == OS_NAMES[2] def is_linux_os(rctx): name = os_name(rctx) - return name == OS_NAMES[2] or name == OS_NAMES[3] or name == OS_NAMES[4] + return name == OS_NAMES[3] or name == OS_NAMES[4] or name == OS_NAMES[5] diff --git a/internal/node/node_repositories.bzl b/internal/node/node_repositories.bzl index f0910883c8..6679f72e88 100644 --- a/internal/node/node_repositories.bzl +++ b/internal/node/node_repositories.bzl @@ -235,6 +235,7 @@ If this list is empty, we won't download yarn at all. BUILT_IN_NODE_PLATFORMS = [ "darwin_amd64", + "darwin_arm64", "linux_amd64", "linux_arm64", "windows_amd64",