Remove support for non-embedded mode (#510)

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.
This commit is contained in:
Sam Clegg 2020-07-20 13:39:21 -07:00 коммит произвёл GitHub
Родитель dec8a63594
Коммит 3e9f04d467
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 22 добавлений и 54 удалений

Просмотреть файл

@ -20,7 +20,6 @@ import stat
import subprocess import subprocess
import sys import sys
import sysconfig import sysconfig
import tempfile
import zipfile import zipfile
if sys.version_info >= (3,): if sys.version_info >= (3,):
@ -164,11 +163,6 @@ def emsdk_path():
return to_unix_path(os.path.dirname(os.path.realpath(__file__))) 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 = ""
if POWERSHELL: if POWERSHELL:
EMSDK_SET_ENV = os.path.join(emsdk_path(), 'emsdk_set_env.ps1') EMSDK_SET_ENV = os.path.join(emsdk_path(), 'emsdk_set_env.ps1')
@ -1409,7 +1403,7 @@ def get_required_path(active_tools):
# Returns the absolute path to the file '.emscripten' for the current user on # Returns the absolute path to the file '.emscripten' for the current user on
# this system. # this system.
def dot_emscripten_path(): def dot_emscripten_path():
return os.path.join(emscripten_config_directory, ".emscripten") return os.path.join(emsdk_path(), ".emscripten")
dot_emscripten = {} dot_emscripten = {}
@ -1445,20 +1439,11 @@ def load_dot_emscripten():
def generate_dot_emscripten(active_tools): def generate_dot_emscripten(active_tools):
global emscripten_config_directory temp_dir = sdk_path('tmp')
if emscripten_config_directory == emsdk_path(): mkdir_p(temp_dir)
temp_dir = sdk_path('tmp')
mkdir_p(temp_dir)
embedded = True
else:
temp_dir = tempfile.gettempdir().replace('\\', '/')
embedded = False
cfg = '' cfg = 'import os\n'
cfg += "emsdk_path = os.path.dirname(os.environ.get('EM_CONFIG')).replace('\\\\', '/')\n"
if embedded:
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 # Different tools may provide the same activated configs; the latest to be
# activated is the relevant one. # activated is the relevant one.
@ -1482,8 +1467,7 @@ COMPILER_ENGINE = NODE_JS
JS_ENGINES = [NODE_JS] JS_ENGINES = [NODE_JS]
''' % temp_dir ''' % temp_dir
if embedded: cfg = cfg.replace("'" + emsdk_path(), "emsdk_path + '")
cfg = cfg.replace("'" + emscripten_config_directory, "emsdk_path + '")
if os.path.exists(dot_emscripten_path()): if os.path.exists(dot_emscripten_path()):
backup_path = dot_emscripten_path() + ".old" backup_path = dot_emscripten_path() + ".old"
@ -1495,7 +1479,7 @@ JS_ENGINES = [NODE_JS]
# Clear old emscripten content. # Clear old emscripten content.
try: try:
os.remove(os.path.join(emscripten_config_directory, ".emscripten_sanity")) os.remove(os.path.join(emsdk_path(), ".emscripten_sanity"))
except: except:
pass pass
@ -1758,8 +1742,8 @@ class Tool(object):
debug_print(str(self) + ' is not active, because key="' + key + '" does not exist in .emscripten') debug_print(str(self) + ' is not active, because key="' + key + '" does not exist in .emscripten')
return False return False
# If running in embedded mode, all paths are stored dynamically relative # all paths are stored dynamically relative to the emsdk root, so
# to the emsdk root, so normalize those first. # normalize those first.
dot_emscripten_key = dot_emscripten[key].replace("emsdk_path + '", "'" + emsdk_path()) dot_emscripten_key = dot_emscripten[key].replace("emsdk_path + '", "'" + emsdk_path())
dot_emscripten_key = dot_emscripten_key.strip("'") dot_emscripten_key = dot_emscripten_key.strip("'")
if dot_emscripten_key != value: if dot_emscripten_key != value:
@ -2683,7 +2667,7 @@ def error_on_missing_tool(name):
def main(): 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: if len(sys.argv) <= 1:
print("Missing command; Type 'emsdk help' to get a list of commands.") print("Missing command; Type 'emsdk help' to get a list of commands.")
@ -2768,18 +2752,13 @@ def main():
if WINDOWS: if WINDOWS:
print(''' print('''
emsdk activate [--global] [--[no-]embedded] [--build=type] [--vs2017/--vs2019] <tool/sdk> emsdk activate [--global] [--build=type] [--vs2017/--vs2019] <tool/sdk>
- Activates the given tool or SDK in the - Activates the given tool or SDK in the
environment of the current shell. If the environment of the current shell. If the
--global option is passed, the registration --global option is passed, the registration
is done globally to all users in the system is done globally to all users in the system
environment. In embedded mode (the default) environment. If a custom compiler version was
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
used to override the compiler to use, pass used to override the compiler to use, pass
the same --vs2017/--vs2019 parameter the same --vs2017/--vs2019 parameter
here to choose which version to activate. here to choose which version to activate.
@ -2787,15 +2766,10 @@ def main():
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(''' emsdk activate [--[no-]embedded] [--build=type] <tool/sdk> print(''' emsdk activate [--build=type] <tool/sdk>
- Activates the given tool or SDK in the - Activates the given tool or SDK in the
environment of the current shell. In environment of the current shell.''')
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.''')
print(''' print('''
Both commands 'install' and 'activate' accept an optional parameter Both commands 'install' and 'activate' accept an optional parameter
@ -2817,8 +2791,12 @@ def main():
arg_old = extract_bool_arg('--old') arg_old = extract_bool_arg('--old')
arg_uses = extract_bool_arg('--uses') arg_uses = extract_bool_arg('--uses')
arg_global = extract_bool_arg('--global') arg_global = extract_bool_arg('--global')
arg_embedded = extract_bool_arg('--embedded') if extract_bool_arg('--embedded'):
arg_embedded = not extract_bool_arg('--no-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') arg_notty = extract_bool_arg('--notty')
if arg_notty: if arg_notty:
TTY_OUTPUT = False TTY_OUTPUT = False
@ -3047,18 +3025,8 @@ def main():
if arg_global: if arg_global:
print('Registering active Emscripten environment globally for all users.') print('Registering active Emscripten environment globally for all users.')
print('') print('')
if arg_embedded:
# Activating the emsdk tools locally relative to Emscripten SDK directory. print('Writing .emscripten configuration file in ' + emsdk_path())
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
tools_to_activate = currently_active_tools() tools_to_activate = currently_active_tools()
args = [x for x in sys.argv[2:] if not x.startswith('--')] args = [x for x in sys.argv[2:] if not x.startswith('--')]