Skip to content

Support emsdk --embedded mode #10935

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 4 commits into from
Apr 17, 2020
Merged
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
22 changes: 20 additions & 2 deletions tools/shared.py
Original file line number Diff line number Diff line change
@@ -261,10 +261,26 @@ 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 used by `emsdk --embedded` (two levels above, see below)
# 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 puts emcc two levels below emsdk. For exmaple:
# - emsdk/upstream/emscripten/emcc
# - emsdk/emscipten/1.38.31/emcc
# However `emsdk --embedded` stores the config file in the emsdk root.
# Without this check, 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
@@ -289,6 +305,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'