Skip to content

Commit 9ce8b35

Browse files
committed
Re-enable running of closure compiler under java
This is a partial revert of #20919. It turns out that we were still depending on falling back to the java version of closure compiler in some cases. Specifically, on macOS arm64 when Rosetta is not installed, we were falling back to the Java version since google-closure-compiler doesn't ship arm64 binaries. I imagine the same will be true of linux-arm64.
1 parent 12e5069 commit 9ce8b35

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

.circleci/config.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -919,10 +919,6 @@ jobs:
919919
- install-emsdk
920920
# TODO: We can't currently do pip install here since numpy and other packages
921921
# are currently missing arm64 macos binaries.
922-
# TODO: Remove this once emsdk has an arm64 version of node
923-
- run:
924-
name: Install Rosetta
925-
command: /usr/sbin/softwareupdate --install-rosetta --agree-to-license
926922
- run-tests:
927923
title: "crossplatform tests"
928924
test_targets: "--crossplatform-only"

tools/building.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,19 +454,25 @@ def get_closure_compiler():
454454
return cmd
455455

456456

457-
def check_closure_compiler(cmd, args, env):
457+
def check_closure_compiler(cmd, args, env, allowed_to_fail):
458458
cmd = cmd + args + ['--version']
459459
try:
460460
output = run_process(cmd, stdout=PIPE, env=env).stdout
461461
except Exception as e:
462+
if allowed_to_fail:
463+
return False
462464
if isinstance(e, subprocess.CalledProcessError):
463465
sys.stderr.write(e.stdout)
464466
sys.stderr.write(str(e) + '\n')
465467
exit_with_error('closure compiler (%s) did not execute properly!' % shared.shlex_join(cmd))
466468

467469
if 'Version:' not in output:
470+
if allowed_to_fail:
471+
return False
468472
exit_with_error('unrecognized closure compiler --version output (%s):\n%s' % (shared.shlex_join(cmd), output))
469473

474+
return True
475+
470476

471477
# Remove this once we require python3.7 and can use std.isascii.
472478
# See: https://docs.python.org/3/library/stdtypes.html#str.isascii
@@ -482,7 +488,15 @@ def isascii(s):
482488
def get_closure_compiler_and_env(user_args):
483489
env = shared.env_with_node_in_path()
484490
closure_cmd = get_closure_compiler()
485-
check_closure_compiler(closure_cmd, user_args, env)
491+
492+
native_closure_compiler_works = check_closure_compiler(closure_cmd, user_args, env, allowed_to_fail=True)
493+
if not native_closure_compiler_works and not any(a.startswith('--platform') for a in user_args):
494+
# Run with Java Closure compiler as a fallback if the native version does not work.
495+
# This can happen, for example, on arm64 macOS machines that do not have Rosetta installed.
496+
diagnostics.warning('closure', 'falling back to java version of closure compiler')
497+
user_args.append('--platform=java')
498+
check_closure_compiler(closure_cmd, user_args, env, allowed_to_fail=False)
499+
486500
return closure_cmd, env
487501

488502

0 commit comments

Comments
 (0)