Skip to content

Commit 87a7b63

Browse files
authored
Cleanup default generated config file (emscripten-core#13922)
The old method of reading env vars directly in the config file is no longer needed now that all config var are implicitly overridable via the environment. Support the old default env var names for a while in case folks are using them.
1 parent 5c0b5a2 commit 87a7b63

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

tools/config.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,19 @@ def parse_config_file():
142142
elif key in config:
143143
globals()[key] = config[key]
144144

145+
# Handle legacy environment variables that were previously honored by the
146+
# default config file.
147+
LEGACY_ENV_VARS = {
148+
'LLVM': 'EM_LLVM_ROOT',
149+
'BINARYEN': 'EM_BINARYEN_ROOT',
150+
'NODE': 'EM_NODE_JS',
151+
}
152+
for key, new_key in LEGACY_ENV_VARS.items():
153+
env_value = os.environ.get(key)
154+
if env_value and new_key not in os.environ:
155+
logger.warning(f'warning: honoring legacy environment variable `{key}`. Please switch to using `{new_key}` instead`')
156+
globals()[new_key] = env_value
157+
145158
# Certain keys are mandatory
146159
for key in ('LLVM_ROOT', 'NODE_JS', 'BINARYEN_ROOT'):
147160
if key not in config:

tools/settings_template.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,16 @@
1212
# is not valid, but LLVM='c:\\llvm\\' and LLVM='c:/llvm/'
1313
# are.
1414

15-
import os
16-
1715
# This is used by external projects in order to find emscripten. It is not used
1816
# by emscripten itself.
19-
EMSCRIPTEN_ROOT = os.path.expanduser(os.getenv('EMSCRIPTEN', '{{{ EMSCRIPTEN_ROOT }}}')) # directory
17+
EMSCRIPTEN_ROOT = '{{{ EMSCRIPTEN_ROOT }}}' # directory
2018

21-
LLVM_ROOT = os.path.expanduser(os.getenv('LLVM', '{{{ LLVM_ROOT }}}')) # directory
22-
BINARYEN_ROOT = os.path.expanduser(os.getenv('BINARYEN', '')) # directory
19+
LLVM_ROOT = '{{{ LLVM_ROOT }}}' # directory
20+
BINARYEN_ROOT = '' # directory
2321

2422
# Location of the node binary to use for running the JS parts of the compiler.
2523
# This engine must exist, or nothing can be compiled.
26-
NODE_JS = os.path.expanduser(os.getenv('NODE', '{{{ NODE }}}')) # executable
24+
NODE_JS = '{{{ NODE }}}' # executable
2725

2826
JAVA = 'java' # executable
2927

@@ -33,21 +31,24 @@
3331
#
3432
# Alternative JS engines to use during testing:
3533
#
36-
# SPIDERMONKEY_ENGINE = [os.path.expanduser(os.getenv('SPIDERMONKEY', 'js'))] # executable
37-
# V8_ENGINE = os.path.expanduser(os.getenv('V8', 'd8')) # executable
34+
# SPIDERMONKEY_ENGINE = ['js'] # executable
35+
# V8_ENGINE = 'd8' # executable
3836
#
3937
# All JS engines to use when running the automatic tests. Not all the engines in
4038
# this list must exist (if they don't, they will be skipped in the test runner).
4139
#
4240
# JS_ENGINES = [NODE_JS] # add V8_ENGINE or SPIDERMONKEY_ENGINE if you have them installed too.
4341
#
42+
# import os
4443
# WASMER = os.path.expanduser(os.path.join('~', '.wasmer', 'bin', 'wasmer'))
4544
# WASMTIME = os.path.expanduser(os.path.join('~', 'wasmtime'))
4645
#
4746
# Wasm engines to use in STANDALONE_WASM tests.
4847
#
4948
# WASM_ENGINES = [] # add WASMER or WASMTIME if you have them installed
5049
#
50+
################################################################################
51+
#
5152
# Other options
5253
#
5354
# FROZEN_CACHE = True # never clears the cache, and disallows building to the cache

0 commit comments

Comments
 (0)