Skip to content
Merged
Changes from 3 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
20 changes: 18 additions & 2 deletions tools/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,24 @@ def generate_config(path, first_time=False):
# The search order from the config file is as follows:
# 1. Specified on the command line (--em-config)
# 2. Specified via EM_CONFIG environment variable
# 3. If emscripten-local .emscripten file is found, use that
# 4. Fall back users home directory (~/.emscripten).
# 3. Local .emscripten file, if found
# 4. Local .emscripten file, as written by emsdk --embedded (two levels up), if found.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It says "two levels" here, but without a little graph like in that comment of yours, it's very unclear I think.

likewise, on line 269 it also says "two levels" but doesn't explain.

If I'm being unclear here, I apologize, and feel free to land this - I'll open a followup PR.

# 5. Fall back users home directory (~/.emscripten).

embedded_config = path_from_root('.emscripten')
# For compatibility with `emsdk --embedded` mode also look two levels up. The
# layout of the emsdk is such that emscripten is always two levels above the emsdk
# root and `emsdk --embedded` stores the config file in the emsdk root.
# Without this change when emcc is run from within the emsdk in embedded mode
# and the user forgets to first run `emsdk_env.sh` (which sets EM_CONFIG) emcc
# will not see any config file at all and fall back to creating a new/emtpy
# one.
# We could remove this special case if emsdk were to write its embedded config
# file into the emscripten directory itself.
# See: https://github.com/emscripten-core/emsdk/pull/367
emsdk_root = os.path.dirname(os.path.dirname(__rootpath__))
emsdk_embedded_config = os.path.join(emsdk_root, '.emscripten')

if '--em-config' in sys.argv:
EM_CONFIG = sys.argv[sys.argv.index('--em-config') + 1]
# And now remove it from sys.argv
Expand All @@ -289,6 +303,8 @@ def generate_config(path, first_time=False):
EM_CONFIG = os.environ['EM_CONFIG']
elif os.path.exists(embedded_config):
EM_CONFIG = embedded_config
elif os.path.exists(emsdk_embedded_config):
EM_CONFIG = emsdk_embedded_config
else:
EM_CONFIG = '~/.emscripten'

Expand Down