Skip to content

Commit 8770a96

Browse files
authored
Limit usage of JAVA config setting. NFC (#15056)
This config setting is only needed/used under very specific circumstance (i.e. when the native version is not supported).
1 parent 5487ab8 commit 8770a96

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

tools/building.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -710,17 +710,6 @@ def closure_compiler(filename, pretty, advanced=True, extra_closure_args=None):
710710
if extra_closure_args:
711711
user_args += extra_closure_args
712712

713-
# Closure compiler expects JAVA_HOME to be set *and* java.exe to be in the PATH in order
714-
# to enable use the java backend. Without this it will only try the native and JavaScript
715-
# versions of the compiler.
716-
java_bin = os.path.dirname(config.JAVA)
717-
if java_bin:
718-
def add_to_path(dirname):
719-
env['PATH'] = env['PATH'] + os.pathsep + dirname
720-
add_to_path(java_bin)
721-
java_home = os.path.dirname(java_bin)
722-
env.setdefault('JAVA_HOME', java_home)
723-
724713
closure_cmd = get_closure_compiler()
725714

726715
native_closure_compiler_works = check_closure_compiler(closure_cmd, user_args, env, allowed_to_fail=True)
@@ -729,6 +718,18 @@ def add_to_path(dirname):
729718
user_args.append('--platform=java')
730719
check_closure_compiler(closure_cmd, user_args, env, allowed_to_fail=False)
731720

721+
if config.JAVA and '--platform=java' in user_args:
722+
# Closure compiler expects JAVA_HOME to be set *and* java.exe to be in the PATH in order
723+
# to enable use the java backend. Without this it will only try the native and JavaScript
724+
# versions of the compiler.
725+
java_bin = os.path.dirname(config.JAVA)
726+
if java_bin:
727+
def add_to_path(dirname):
728+
env['PATH'] = env['PATH'] + os.pathsep + dirname
729+
add_to_path(java_bin)
730+
java_home = os.path.dirname(java_bin)
731+
env.setdefault('JAVA_HOME', java_home)
732+
732733
# Closure externs file contains known symbols to be extern to the minification, Closure
733734
# should not minify these symbol names.
734735
CLOSURE_EXTERNS = [path_from_root('src/closure-externs/closure-externs.js')]

tools/config.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def root_is_writable():
5656

5757

5858
def normalize_config_settings():
59-
global CACHE, PORTS, JAVA, LLVM_ADD_VERSION, CLANG_ADD_VERSION, CLOSURE_COMPILER
59+
global CACHE, PORTS, LLVM_ADD_VERSION, CLANG_ADD_VERSION, CLOSURE_COMPILER
6060
global NODE_JS, V8_ENGINE, JS_ENGINE, JS_ENGINES, SPIDERMONKEY_ENGINE, WASM_ENGINES
6161

6262
# EM_CONFIG stuff
@@ -91,10 +91,6 @@ def normalize_config_settings():
9191
if not PORTS:
9292
PORTS = os.path.join(CACHE, 'ports')
9393

94-
if JAVA is None:
95-
logger.debug('JAVA not defined in ' + EM_CONFIG + ', using "java"')
96-
JAVA = 'java'
97-
9894
# Tools/paths
9995
if LLVM_ADD_VERSION is None:
10096
LLVM_ADD_VERSION = os.getenv('LLVM_ADD_VERSION')

0 commit comments

Comments
 (0)