From 7a3dfdf68439d118223f12c21ac067d202f6ad9c Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 29 May 2020 09:59:17 -0700 Subject: [PATCH] Remove support for non-embedded mode embedded mode as been the default since #472 and I included `--no-embedded` as an option during the interim time, but to simply the code and avoid have two modes of operation I think its safe to now remove the non-embedded mode. --- emsdk.py | 75 +++++++++++++++++--------------------------------------- 1 file changed, 22 insertions(+), 53 deletions(-) diff --git a/emsdk.py b/emsdk.py index bfef8c7260..558ed3bbfe 100755 --- a/emsdk.py +++ b/emsdk.py @@ -165,11 +165,6 @@ def emsdk_path(): return to_unix_path(os.path.dirname(os.path.realpath(__file__))) -emscripten_config_directory = os.path.expanduser("~/") -# 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() - EMSDK_SET_ENV = 'emsdk_set_env.ps1' if POWERSHELL \ else 'emsdk_set_env.bat' if (WINDOWS and not MSYS) \ else 'emsdk_set_env.csh' if CSH \ @@ -1409,7 +1404,7 @@ def get_required_path(active_tools): # Returns the absolute path to the file '.emscripten' for the current user on # this system. def dot_emscripten_path(): - return os.path.join(emscripten_config_directory, ".emscripten") + return os.path.join(emsdk_path(), ".emscripten") dot_emscripten = {} @@ -1445,20 +1440,11 @@ def load_dot_emscripten(): def generate_dot_emscripten(active_tools): - global emscripten_config_directory - if emscripten_config_directory == emsdk_path(): - temp_dir = sdk_path('tmp') - mkdir_p(temp_dir) - embedded = True - else: - temp_dir = tempfile.gettempdir().replace('\\', '/') - embedded = False + temp_dir = sdk_path('tmp') + mkdir_p(temp_dir) - cfg = '' - - if embedded: - cfg += 'import os\n' - cfg += "emsdk_path = os.path.dirname(os.environ.get('EM_CONFIG')).replace('\\\\', '/')\n" + cfg = 'import os\n' + cfg += "emsdk_path = os.path.dirname(os.environ.get('EM_CONFIG')).replace('\\\\', '/')\n" # Different tools may provide the same activated configs; the latest to be # activated is the relevant one. @@ -1482,8 +1468,7 @@ def generate_dot_emscripten(active_tools): JS_ENGINES = [NODE_JS] ''' % temp_dir - if embedded: - cfg = cfg.replace("'" + emscripten_config_directory, "emsdk_path + '") + cfg = cfg.replace("'" + emsdk_path(), "emsdk_path + '") if os.path.exists(dot_emscripten_path()): backup_path = dot_emscripten_path() + ".old" @@ -1495,7 +1480,7 @@ def generate_dot_emscripten(active_tools): # Clear old emscripten content. try: - os.remove(os.path.join(emscripten_config_directory, ".emscripten_sanity")) + os.remove(os.path.join(emsdk_path(), ".emscripten_sanity")) except: pass @@ -1757,8 +1742,8 @@ def is_active(self): debug_print(str(self) + ' is not active, because key="' + key + '" does not exist in .emscripten') return False - # If running in embedded mode, all paths are stored dynamically relative - # to the emsdk root, so normalize those first. + # all paths are stored dynamically relative to the emsdk root, so + # normalize those first. dot_emscripten_key = dot_emscripten[key].replace("emsdk_path + '", "'" + emsdk_path()) dot_emscripten_key = dot_emscripten_key.strip("'") if dot_emscripten_key != value: @@ -2666,7 +2651,7 @@ def error_on_missing_tool(name): def main(): - global emscripten_config_directory, BUILD_FOR_TESTING, ENABLE_LLVM_ASSERTIONS, TTY_OUTPUT + global BUILD_FOR_TESTING, ENABLE_LLVM_ASSERTIONS, TTY_OUTPUT if len(sys.argv) <= 1: print("Missing command; Type 'emsdk help' to get a list of commands.") @@ -2751,18 +2736,13 @@ def main(): if WINDOWS: print(''' - emsdk activate [--global] [--[no-]embedded] [--build=type] [--vs2017/--vs2019] + emsdk activate [--global] [--build=type] [--vs2017/--vs2019] - Activates the given tool or SDK in the environment of the current shell. If the --global option is passed, the registration is done globally to all users in the system - environment. In embedded mode (the default) - 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. If a custom compiler version was + environment. If a custom compiler version was used to override the compiler to use, pass the same --vs2017/--vs2019 parameter here to choose which version to activate. @@ -2770,15 +2750,10 @@ def main(): emcmdprompt.bat - Spawns a new command prompt window with the Emscripten environment active.''') else: - print(''' emsdk activate [--[no-]embedded] [--build=type] + print(''' emsdk activate [--build=type] - Activates the given tool or SDK in the - environment of the current shell. In - embedded mode (the default), 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.''') + environment of the current shell.''') print(''' Both commands 'install' and 'activate' accept an optional parameter @@ -2800,8 +2775,12 @@ def extract_bool_arg(name): arg_old = extract_bool_arg('--old') arg_uses = extract_bool_arg('--uses') arg_global = extract_bool_arg('--global') - arg_embedded = extract_bool_arg('--embedded') - arg_embedded = not extract_bool_arg('--no-embedded') + if extract_bool_arg('--embedded'): + print('embedded mode is now the only mode available', file=sys.stderr) + if extract_bool_arg('--no-embedded'): + print('embedded mode is now the only mode available', file=sys.stderr) + return 1 + arg_notty = extract_bool_arg('--notty') if arg_notty: TTY_OUTPUT = False @@ -3032,18 +3011,8 @@ def print_tools(t): if arg_global: print('Registering active Emscripten environment globally for all users.') print('') - if arg_embedded: - # 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 + + print('Writing .emscripten configuration file in ' + emsdk_path()) tools_to_activate = currently_active_tools() args = [x for x in sys.argv[2:] if not x.startswith('--')]