Skip to content

Commit

Permalink
fix(builtin): add two missing locations where Mac M1 support needs to…
Browse files Browse the repository at this point in the history
… be declared

Fixes bazel-contrib#2733
  • Loading branch information
alexeagle committed Jun 8, 2021
1 parent 51676ef commit 5454478
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
38 changes: 22 additions & 16 deletions internal/common/os_name.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
"""

OS_ARCH_NAMES = [
("darwin", "amd64"),
("windows", "amd64"),
("darwin", "amd64"),
("darwin", "arm64"),
("linux", "amd64"),
("linux", "arm64"),
("linux", "s390x"),
Expand All @@ -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]
1 change: 1 addition & 0 deletions internal/node/node_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 5454478

Please sign in to comment.