Skip to content

Commit

Permalink
Support emsdk --embedded mode
Browse files Browse the repository at this point in the history
This change allows emsdk --embdded mode to work out of the box
without running emsdk_env.sh.

This paves makes it easier to justify using embedded mode by default:
  emscripten-core/emsdk#472

This is part of a larger plan to avoid using the $HOME directory to
store anything at all: #9543
  • Loading branch information
sbc100 committed Apr 16, 2020
1 parent cc017f9 commit 3eb672b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tools/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,12 @@ def generate_config(path, first_time=False):
# 4. Fall back users home directory (~/.emscripten).

embedded_config = path_from_root('.emscripten')
# For compatability with emsdk --embedded mode also look two levels up. This
# could be removed in emsdk was use the emscripten directory itself for the
# embedded config: 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 +295,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

0 comments on commit 3eb672b

Please sign in to comment.