Skip to content

Re-enable running of closure compiler under java #21093

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

Merged
merged 1 commit into from
Jan 17, 2024
Merged
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
4 changes: 0 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -919,10 +919,6 @@ jobs:
- install-emsdk
# TODO: We can't currently do pip install here since numpy and other packages
# are currently missing arm64 macos binaries.
# TODO: Remove this once emsdk has an arm64 version of node
- run:
name: Install Rosetta
command: /usr/sbin/softwareupdate --install-rosetta --agree-to-license
- run-tests:
title: "crossplatform tests"
test_targets: "--crossplatform-only"
Expand Down
18 changes: 16 additions & 2 deletions tools/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,19 +454,25 @@ def get_closure_compiler():
return cmd


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

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

return True


# Remove this once we require python3.7 and can use std.isascii.
# See: https://docs.python.org/3/library/stdtypes.html#str.isascii
Expand All @@ -482,7 +488,15 @@ def isascii(s):
def get_closure_compiler_and_env(user_args):
env = shared.env_with_node_in_path()
closure_cmd = get_closure_compiler()
check_closure_compiler(closure_cmd, user_args, env)

native_closure_compiler_works = check_closure_compiler(closure_cmd, user_args, env, allowed_to_fail=True)
if not native_closure_compiler_works and not any(a.startswith('--platform') for a in user_args):
# Run with Java Closure compiler as a fallback if the native version does not work.
# This can happen, for example, on arm64 macOS machines that do not have Rosetta installed.
logger.warn('falling back to java version of closure compiler')
user_args.append('--platform=java')
check_closure_compiler(closure_cmd, user_args, env, allowed_to_fail=False)

return closure_cmd, env


Expand Down