Skip to content
Open
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
9 changes: 8 additions & 1 deletion tools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,20 @@ def set_config_from_tool_location(config_key, tool_binary, f):
exit_with_error('%s is set to empty value in %s', config_key, EM_CONFIG)


def expandvars(value):
if type(value) == list:
return [expandvars(v) for v in value]
return os.path.expandvars(value)


def parse_config_file():
"""Parse the emscripten config file using python's exec.

Also check EM_<KEY> environment variables to override specific config keys.
"""
config = {'__file__': EM_CONFIG}
config_text = utils.read_file(EM_CONFIG)
os.environ['EM_CONFIG_DIR'] = os.path.dirname(EM_CONFIG)
try:
exec(config_text, config)
except Exception as e:
Expand Down Expand Up @@ -132,7 +139,7 @@ def parse_config_file():
exit_with_error(f'environment variable {env_var} must be an absolute path: {env_value}')
globals()[key] = env_value
elif key in config:
globals()[key] = config[key]
globals()[key] = expandvars(config[key])


def read_config():
Expand Down
10 changes: 5 additions & 5 deletions tools/config_template.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# This file will be edited (the {{{ }}} things), and written to `.emscripten`
# when emscripten is first used and no config file is found.

# Note: If you put paths relative to the home directory, do not forget
# os.path.expanduser
# Note: Use can use environment variables in your settings, e.g. use `$HOME`
# for paths relative to the home directory. You can also use `$EM_CONFIG_DIR`
# for the directory where the config file lives.
#
# Any config setting <KEY> in this file can be overridden by setting the
# EM_<KEY> environment variable. For example, settings EM_LLVM_ROOT override
Expand Down Expand Up @@ -34,9 +35,8 @@
#
# JS_ENGINES = [NODE_JS_TEST] # add V8_ENGINE or SPIDERMONKEY_ENGINE if you have them installed too.
#
# import os
# WASMER = os.path.expanduser(os.path.join('~', '.wasmer', 'bin', 'wasmer'))
# WASMTIME = os.path.expanduser(os.path.join('~', 'wasmtime'))
# WASMER = '$HOME/.wasmer/bin/wasmer'
# WASMTIME = '$HOME/wasmtime'
#
# Wasm engines to use in STANDALONE_WASM tests.
#
Expand Down