Add new option '--embedded' to emsdk activate to bundle all Emscripten configuration, temp, cache and ports directories inside the emsdk root directory.
This commit is contained in:
@@ -133,6 +133,10 @@ On Windows, you can directly install an old SDK version by using one of the arch
|
|||||||
|
|
||||||
You can toggle between different tools and SDK versions by running `emsdk activate <tool/sdk name>`. Activating a tool will set up `~/.emscripten` to point to that particular tool. On Windows, you can pass the option `--global` to the `activate` command to register the environment permanently to the system registry for all users.
|
You can toggle between different tools and SDK versions by running `emsdk activate <tool/sdk name>`. Activating a tool will set up `~/.emscripten` to point to that particular tool. On Windows, you can pass the option `--global` to the `activate` command to register the environment permanently to the system registry for all users.
|
||||||
|
|
||||||
|
##### How do I build multiple projects with different SDK versions in parallel?
|
||||||
|
|
||||||
|
By default, Emscripten locates all configuration files in the home directory of the user. This may be a problem if you need to simultaneously build with multiple Emscripten compiler versions, since the user home directory can only be configured to point to one compiler at a time. This can be overcome by specifying the '--embedded' option as a parameter to 'emsdk activate', which will signal emsdk to generate the compiler configuration files inside the emsdk root directory instead of the user home directory. Use this option also when it is desirable to run emsdk in a fully portable mode that does not touch any files outside the emsdk directory.
|
||||||
|
|
||||||
##### How do I track the latest Emscripten development with the SDK?
|
##### How do I track the latest Emscripten development with the SDK?
|
||||||
|
|
||||||
A common and supported use case of the Emscripten SDK is to enable the workflow where you directly interact with the github repositories. This allows you to obtain new features and latest fixes immediately as they are pushed to the github repository, without having to wait for release to be tagged. You do not need a github account or a fork of Emscripten to do this. To switch to using the latest upstream git development branch `incoming`, run the following:
|
A common and supported use case of the Emscripten SDK is to enable the workflow where you directly interact with the github repositories. This allows you to obtain new features and latest fixes immediately as they are pushed to the github repository, without having to wait for release to be tagged. You do not need a github account or a fork of Emscripten to do this. To switch to using the latest upstream git development branch `incoming`, run the following:
|
||||||
|
|||||||
74
emsdk
74
emsdk
@@ -33,6 +33,8 @@ if platform.mac_ver()[0] != '':
|
|||||||
OSX = True
|
OSX = True
|
||||||
ENVPATH_SEPARATOR = ':'
|
ENVPATH_SEPARATOR = ':'
|
||||||
|
|
||||||
|
emscripten_config_directory = os.path.expanduser("~/")
|
||||||
|
|
||||||
EMSDK_SET_ENV = 'emsdk_set_env.bat' if WINDOWS else 'emsdk_set_env.sh'
|
EMSDK_SET_ENV = 'emsdk_set_env.bat' if WINDOWS else 'emsdk_set_env.sh'
|
||||||
|
|
||||||
CMAKE_GENERATOR = 'Unix Makefiles'
|
CMAKE_GENERATOR = 'Unix Makefiles'
|
||||||
@@ -559,7 +561,7 @@ def get_required_path(active_tools):
|
|||||||
|
|
||||||
# Returns the absolute path to the file '.emscripten' for the current user on this system.
|
# Returns the absolute path to the file '.emscripten' for the current user on this system.
|
||||||
def dot_emscripten_path():
|
def dot_emscripten_path():
|
||||||
return os.path.expanduser("~/.emscripten")
|
return os.path.join(emscripten_config_directory, ".emscripten")
|
||||||
|
|
||||||
dot_emscripten = {}
|
dot_emscripten = {}
|
||||||
|
|
||||||
@@ -592,7 +594,12 @@ def load_dot_emscripten():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def generate_dot_emscripten(active_tools):
|
def generate_dot_emscripten(active_tools):
|
||||||
temp_dir = tempfile.gettempdir().replace('\\', '/')
|
global emscripten_config_directory
|
||||||
|
if emscripten_config_directory == emsdk_path():
|
||||||
|
temp_dir = sdk_path('.tmp')
|
||||||
|
mkdir_p(temp_dir)
|
||||||
|
else:
|
||||||
|
temp_dir = tempfile.gettempdir().replace('\\', '/')
|
||||||
|
|
||||||
cfg = 'import os\n'
|
cfg = 'import os\n'
|
||||||
cfg += '''SPIDERMONKEY_ENGINE = ''
|
cfg += '''SPIDERMONKEY_ENGINE = ''
|
||||||
@@ -615,9 +622,9 @@ JS_ENGINES = [NODE_JS]
|
|||||||
|
|
||||||
# Clear old cached emscripten content.
|
# Clear old cached emscripten content.
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(os.path.expanduser("~/.emscripten_cache"), ignore_errors=True)
|
shutil.rmtree(os.path.join(emscripten_config_directory, ".emscripten_cache"), ignore_errors=True)
|
||||||
os.remove(os.path.expanduser("~/.emscripten_sanity"))
|
os.remove(os.path.join(emscripten_config_directory, ".emscripten_sanity"))
|
||||||
os.remove(os.path.expanduser("~/.emscripten_cache__last_clear"))
|
os.remove(os.path.join(emscripten_config_directory, ".emscripten_cache__last_clear"))
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -1143,6 +1150,7 @@ def adjusted_path(tools_to_activate, log_additions=False):
|
|||||||
return (ENVPATH_SEPARATOR.join(unique_items(existing_path + new_path)), new_emsdk_tools)
|
return (ENVPATH_SEPARATOR.join(unique_items(existing_path + new_path)), new_emsdk_tools)
|
||||||
|
|
||||||
def construct_env_windows(tools_to_activate, permanent):
|
def construct_env_windows(tools_to_activate, permanent):
|
||||||
|
global emscripten_config_directory
|
||||||
env_string = ''
|
env_string = ''
|
||||||
newpath, added_path = adjusted_path(tools_to_activate)
|
newpath, added_path = adjusted_path(tools_to_activate)
|
||||||
|
|
||||||
@@ -1161,6 +1169,15 @@ def construct_env_windows(tools_to_activate, permanent):
|
|||||||
print ''
|
print ''
|
||||||
|
|
||||||
env_vars_to_add = []
|
env_vars_to_add = []
|
||||||
|
em_config_path = os.path.normpath(os.path.join(emscripten_config_directory, '.emscripten'))
|
||||||
|
if not 'EM_CONFIG' in os.environ or to_unix_path(os.environ['EM_CONFIG']) != to_unix_path(em_config_path):
|
||||||
|
env_vars_to_add += [('EM_CONFIG', em_config_path)]
|
||||||
|
if emscripten_config_directory == emsdk_path():
|
||||||
|
em_cache_dir = sdk_path('.emscripten_cache')
|
||||||
|
if not 'EM_CACHE' in os.environ or to_unix_path(os.environ['EM_CACHE']) != to_unix_path(em_cache_dir):
|
||||||
|
env_vars_to_add += [('EM_CACHE', em_cache_dir)]
|
||||||
|
mkdir_p(em_cache_dir)
|
||||||
|
|
||||||
for tool in tools_to_activate:
|
for tool in tools_to_activate:
|
||||||
if hasattr(tool, 'activated_env'):
|
if hasattr(tool, 'activated_env'):
|
||||||
(key, value) = parse_key_value(tool.activated_env)
|
(key, value) = parse_key_value(tool.activated_env)
|
||||||
@@ -1221,6 +1238,7 @@ def silentremove(filename):
|
|||||||
if e.errno != errno.ENOENT: raise
|
if e.errno != errno.ENOENT: raise
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
global emscripten_config_directory
|
||||||
load_dot_emscripten()
|
load_dot_emscripten()
|
||||||
load_sdk_manifest()
|
load_sdk_manifest()
|
||||||
usage_str = "usage: %prog --param1 .. --paramn <projectrootdir>"
|
usage_str = "usage: %prog --param1 .. --paramn <projectrootdir>"
|
||||||
@@ -1250,19 +1268,32 @@ def main():
|
|||||||
|
|
||||||
if WINDOWS:
|
if WINDOWS:
|
||||||
print '''
|
print '''
|
||||||
emsdk activate [--global] <tool/sdk> - Activates the given tool or SDK in
|
emsdk activate [--global] [--embedded] <tool/sdk>
|
||||||
the environment of the current
|
|
||||||
shell. If the --global option is
|
- Activates the given tool or SDK in
|
||||||
passed, the registration is done
|
the environment of the current
|
||||||
globally to all users in the system
|
shell. If the --global option is
|
||||||
environment.
|
passed, the registration is done
|
||||||
|
globally to all users in the system
|
||||||
|
environment. If the --embedded option is
|
||||||
|
passed, all Emcripten configuration files as
|
||||||
|
well as the temp, cache and ports directories
|
||||||
|
are located inside the Emscripten SDK
|
||||||
|
directory rather than the user home directory.
|
||||||
|
|
||||||
emcmdprompt.bat - Spawns a new command prompt window with the
|
emcmdprompt.bat - Spawns a new command prompt window with the
|
||||||
Emscripten environment active.'''
|
Emscripten environment active.'''
|
||||||
else:
|
else:
|
||||||
print '''
|
print '''
|
||||||
emsdk activate <tool/sdk> - Activates the given tool or SDK in the
|
emsdk activate [--embedded] <tool/sdk>
|
||||||
environment of the current shell.'''
|
|
||||||
|
- Activates the given tool or SDK in the
|
||||||
|
environment of the current shell. If the
|
||||||
|
--embedded option is passed, all Emcripten
|
||||||
|
configuration files as well as the temp, cache
|
||||||
|
and ports directories are located inside the
|
||||||
|
Emscripten SDK directory rather than the user
|
||||||
|
home directory.'''
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
cmd = sys.argv[1]
|
cmd = sys.argv[1]
|
||||||
@@ -1320,6 +1351,10 @@ def main():
|
|||||||
|
|
||||||
return 0
|
return 0
|
||||||
elif cmd == 'construct_env':
|
elif cmd == 'construct_env':
|
||||||
|
# If .emscripten exists, we are configuring as embedded inside the emsdk directory.
|
||||||
|
if os.path.exists(os.path.join(emsdk_path(), '.emscripten')):
|
||||||
|
emscripten_config_directory = emsdk_path()
|
||||||
|
|
||||||
silentremove(EMSDK_SET_ENV) # Clean up old temp file up front, in case of failure later before we get to write out the new one.
|
silentremove(EMSDK_SET_ENV) # Clean up old temp file up front, in case of failure later before we get to write out the new one.
|
||||||
tools_to_activate = currently_active_tools()
|
tools_to_activate = currently_active_tools()
|
||||||
tools_to_activate = process_tool_list(tools_to_activate, log_errors=True)
|
tools_to_activate = process_tool_list(tools_to_activate, log_errors=True)
|
||||||
@@ -1336,6 +1371,19 @@ def main():
|
|||||||
if permanently_activate:
|
if permanently_activate:
|
||||||
print 'Registering active Emscripten environment globally for all users.'
|
print 'Registering active Emscripten environment globally for all users.'
|
||||||
print ''
|
print ''
|
||||||
|
embed_activation_to_sdk_dir = '--embedded' in sys.argv
|
||||||
|
if embed_activation_to_sdk_dir:
|
||||||
|
# Activating the emsdk tools locally relative to Emscripten SDK directory.
|
||||||
|
emscripten_config_directory = emsdk_path()
|
||||||
|
print 'Writing .emscripten configuration file to Emscripten SDK directory ' + emscripten_config_directory
|
||||||
|
else:
|
||||||
|
print 'Writing .emscripten configuration file to user home directory ' + emscripten_config_directory
|
||||||
|
# Remove .emscripten from emsdk dir, since its presence is used to detect whether emsdk is activate in embedded mode or not.
|
||||||
|
try:
|
||||||
|
os.remove(os.path.join(emsdk_path(), ".emscripten"))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
sys.argv = filter(lambda x: not x.startswith('--'), sys.argv)
|
sys.argv = filter(lambda x: not x.startswith('--'), sys.argv)
|
||||||
# If called without arguments, activate latest versions of all tools
|
# If called without arguments, activate latest versions of all tools
|
||||||
if len(sys.argv) <= 2:
|
if len(sys.argv) <= 2:
|
||||||
|
|||||||
Reference in New Issue
Block a user