aboutsummaryrefslogtreecommitdiff
path: root/pw_env_setup
diff options
context:
space:
mode:
authorChad Norvell <chadnorvell@google.com>2022-03-15 20:46:58 -0700
committerCQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-03-17 16:08:34 +0000
commitf1511cdb957ec4d0d09a41ef5bfc039a6e190e5c (patch)
tree032903ad532023a5ded9dc3778abd14446920564 /pw_env_setup
parent001f953aebcd3fff6f61dd350d943b84e5429774 (diff)
downloadpigweed-f1511cdb957ec4d0d09a41ef5bfc039a6e190e5c.tar.gz
pw_env_setup: Support M1 Macs via Rosetta
If we're running on an M1 (arm64) Mac, pretend to be on an amd64 Mac instead. The environment will run transparently via Rosetta. Bug: b/224408077 Change-Id: I003ee41302e88760ec9528875e0c764b4484bd33 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/88340 Commit-Queue: Chad Norvell <chadnorvell@google.com> Reviewed-by: Rob Mohr <mohrr@google.com>
Diffstat (limited to 'pw_env_setup')
-rwxr-xr-xpw_env_setup/get_pw_env_setup.sh5
-rwxr-xr-xpw_env_setup/py/pw_env_setup/cipd_setup/update.py8
-rwxr-xr-xpw_env_setup/py/pw_env_setup/cipd_setup/wrapper.py18
3 files changed, 26 insertions, 5 deletions
diff --git a/pw_env_setup/get_pw_env_setup.sh b/pw_env_setup/get_pw_env_setup.sh
index 0317b2e7a..ff74220bd 100755
--- a/pw_env_setup/get_pw_env_setup.sh
+++ b/pw_env_setup/get_pw_env_setup.sh
@@ -46,6 +46,11 @@ if [ "$ARCH" = "x86_64" ]; then
ARCH="amd64"
fi
+# Support `mac-arm64` through Rosetta until `mac-arm64` binaries are ready
+if [[ "$OS" = "mac" ] && [ "$ARCH" = "arm64" ]]; then
+ ARCH="amd64"
+fi
+
for HASH in $(git --git-dir="$PW_ROOT/.git" --no-pager log --max-count=10 --format=format:%H); do
URL="https://storage.googleapis.com/pigweed-envsetup/$OS-$ARCH"
URL="$URL/$HASH/pw_env_setup"
diff --git a/pw_env_setup/py/pw_env_setup/cipd_setup/update.py b/pw_env_setup/py/pw_env_setup/cipd_setup/update.py
index 27acfbee9..eb2b835b1 100755
--- a/pw_env_setup/py/pw_env_setup/cipd_setup/update.py
+++ b/pw_env_setup/py/pw_env_setup/cipd_setup/update.py
@@ -134,7 +134,13 @@ def platform():
else:
arch = platform_module.machine()
- return '{}-{}'.format(osname, arch).lower()
+ platform_arch = '{}-{}'.format(osname, arch).lower()
+
+ # Support `mac-arm64` through Rosetta until `mac-arm64` binaries are ready
+ if platform_arch == 'mac-arm64':
+ return 'mac-amd64'
+
+ return platform_arch
def all_package_files(env_vars, package_files):
diff --git a/pw_env_setup/py/pw_env_setup/cipd_setup/wrapper.py b/pw_env_setup/py/pw_env_setup/cipd_setup/wrapper.py
index 466f2911e..6ca7db3c9 100755
--- a/pw_env_setup/py/pw_env_setup/cipd_setup/wrapper.py
+++ b/pw_env_setup/py/pw_env_setup/cipd_setup/wrapper.py
@@ -133,6 +133,16 @@ def arch_normalized():
raise Exception('unrecognized arch: {}'.format(machine))
+def platform_arch_normalized():
+ platform_arch = '{}-{}'.format(platform_normalized(), arch_normalized())
+
+ # Support `mac-arm64` through Rosetta until `mac-arm64` binaries are ready
+ if platform_arch == 'mac-arm64':
+ platform_arch = 'mac-amd64'
+
+ return platform_arch
+
+
def user_agent():
"""Generate a user-agent based on the project name and current hash."""
@@ -160,7 +170,7 @@ def actual_hash(path):
def expected_hash():
"""Pulls expected hash from digests file."""
- expected_plat = '{}-{}'.format(platform_normalized(), arch_normalized())
+ expected_plat = platform_arch_normalized()
with open(DIGESTS_FILE, 'r') as ins:
for line in ins:
@@ -223,7 +233,7 @@ brew uninstall python && brew install python
print('=' * 70)
raise
- full_platform = '{}-{}'.format(platform_normalized(), arch_normalized())
+ full_platform = platform_arch_normalized()
if full_platform not in SUPPORTED_PLATFORMS:
raise UnsupportedPlatform(full_platform)
@@ -293,8 +303,8 @@ def bootstrap(client, silent=('PW_ENVSETUP_QUIET' in os.environ)):
os.makedirs(client_dir)
if not silent:
- print('Bootstrapping cipd client for {}-{}'.format(
- platform_normalized(), arch_normalized()))
+ print('Bootstrapping cipd client for {}'.format(
+ platform_arch_normalized()))
tmp_path = client + '.tmp'
with open(tmp_path, 'wb') as tmp: