2020import subprocess
2121import sys
2222import sysconfig
23- import tempfile
2423import zipfile
2524
2625if sys .version_info >= (3 ,):
@@ -164,11 +163,6 @@ def emsdk_path():
164163 return to_unix_path (os .path .dirname (os .path .realpath (__file__ )))
165164
166165
167- emscripten_config_directory = os .path .expanduser ("~/" )
168- # If .emscripten exists, we are configuring as embedded inside the emsdk directory.
169- if os .path .exists (os .path .join (emsdk_path (), '.emscripten' )):
170- emscripten_config_directory = emsdk_path ()
171-
172166EMSDK_SET_ENV = ""
173167if POWERSHELL :
174168 EMSDK_SET_ENV = os .path .join (emsdk_path (), 'emsdk_set_env.ps1' )
@@ -1409,7 +1403,7 @@ def get_required_path(active_tools):
14091403# Returns the absolute path to the file '.emscripten' for the current user on
14101404# this system.
14111405def dot_emscripten_path ():
1412- return os .path .join (emscripten_config_directory , ".emscripten" )
1406+ return os .path .join (emsdk_path () , ".emscripten" )
14131407
14141408
14151409dot_emscripten = {}
@@ -1445,20 +1439,11 @@ def load_dot_emscripten():
14451439
14461440
14471441def generate_dot_emscripten (active_tools ):
1448- global emscripten_config_directory
1449- if emscripten_config_directory == emsdk_path ():
1450- temp_dir = sdk_path ('tmp' )
1451- mkdir_p (temp_dir )
1452- embedded = True
1453- else :
1454- temp_dir = tempfile .gettempdir ().replace ('\\ ' , '/' )
1455- embedded = False
1442+ temp_dir = sdk_path ('tmp' )
1443+ mkdir_p (temp_dir )
14561444
1457- cfg = ''
1458-
1459- if embedded :
1460- cfg += 'import os\n '
1461- cfg += "emsdk_path = os.path.dirname(os.environ.get('EM_CONFIG')).replace('\\ \\ ', '/')\n "
1445+ cfg = 'import os\n '
1446+ cfg += "emsdk_path = os.path.dirname(os.environ.get('EM_CONFIG')).replace('\\ \\ ', '/')\n "
14621447
14631448 # Different tools may provide the same activated configs; the latest to be
14641449 # activated is the relevant one.
@@ -1482,8 +1467,7 @@ def generate_dot_emscripten(active_tools):
14821467JS_ENGINES = [NODE_JS]
14831468''' % temp_dir
14841469
1485- if embedded :
1486- cfg = cfg .replace ("'" + emscripten_config_directory , "emsdk_path + '" )
1470+ cfg = cfg .replace ("'" + emsdk_path (), "emsdk_path + '" )
14871471
14881472 if os .path .exists (dot_emscripten_path ()):
14891473 backup_path = dot_emscripten_path () + ".old"
@@ -1495,7 +1479,7 @@ def generate_dot_emscripten(active_tools):
14951479
14961480 # Clear old emscripten content.
14971481 try :
1498- os .remove (os .path .join (emscripten_config_directory , ".emscripten_sanity" ))
1482+ os .remove (os .path .join (emsdk_path () , ".emscripten_sanity" ))
14991483 except :
15001484 pass
15011485
@@ -1758,8 +1742,8 @@ def is_active(self):
17581742 debug_print (str (self ) + ' is not active, because key="' + key + '" does not exist in .emscripten' )
17591743 return False
17601744
1761- # If running in embedded mode, all paths are stored dynamically relative
1762- # to the emsdk root, so normalize those first.
1745+ # all paths are stored dynamically relative to the emsdk root, so
1746+ # normalize those first.
17631747 dot_emscripten_key = dot_emscripten [key ].replace ("emsdk_path + '" , "'" + emsdk_path ())
17641748 dot_emscripten_key = dot_emscripten_key .strip ("'" )
17651749 if dot_emscripten_key != value :
@@ -2683,7 +2667,7 @@ def error_on_missing_tool(name):
26832667
26842668
26852669def main ():
2686- global emscripten_config_directory , BUILD_FOR_TESTING , ENABLE_LLVM_ASSERTIONS , TTY_OUTPUT
2670+ global BUILD_FOR_TESTING , ENABLE_LLVM_ASSERTIONS , TTY_OUTPUT
26872671
26882672 if len (sys .argv ) <= 1 :
26892673 print ("Missing command; Type 'emsdk help' to get a list of commands." )
@@ -2768,34 +2752,24 @@ def main():
27682752
27692753 if WINDOWS :
27702754 print ('''
2771- emsdk activate [--global] [--[no-]embedded] [-- build=type] [--vs2017/--vs2019] <tool/sdk>
2755+ emsdk activate [--global] [--build=type] [--vs2017/--vs2019] <tool/sdk>
27722756
27732757 - Activates the given tool or SDK in the
27742758 environment of the current shell. If the
27752759 --global option is passed, the registration
27762760 is done globally to all users in the system
2777- environment. In embedded mode (the default)
2778- all Emcripten configuration files as well as
2779- the temp, cache and ports directories
2780- are located inside the Emscripten SDK
2781- directory rather than the user home
2782- directory. If a custom compiler version was
2761+ environment. If a custom compiler version was
27832762 used to override the compiler to use, pass
27842763 the same --vs2017/--vs2019 parameter
27852764 here to choose which version to activate.
27862765
27872766 emcmdprompt.bat - Spawns a new command prompt window with the
27882767 Emscripten environment active.''' )
27892768 else :
2790- print (''' emsdk activate [--[no-]embedded] [-- build=type] <tool/sdk>
2769+ print (''' emsdk activate [--build=type] <tool/sdk>
27912770
27922771 - Activates the given tool or SDK in the
2793- environment of the current shell. In
2794- embedded mode (the default), all Emcripten
2795- configuration files as well as the temp, cache
2796- and ports directories are located inside the
2797- Emscripten SDK directory rather than the user
2798- home directory.''' )
2772+ environment of the current shell.''' )
27992773
28002774 print ('''
28012775 Both commands 'install' and 'activate' accept an optional parameter
@@ -2817,8 +2791,12 @@ def extract_bool_arg(name):
28172791 arg_old = extract_bool_arg ('--old' )
28182792 arg_uses = extract_bool_arg ('--uses' )
28192793 arg_global = extract_bool_arg ('--global' )
2820- arg_embedded = extract_bool_arg ('--embedded' )
2821- arg_embedded = not extract_bool_arg ('--no-embedded' )
2794+ if extract_bool_arg ('--embedded' ):
2795+ print ('embedded mode is now the only mode available' , file = sys .stderr )
2796+ if extract_bool_arg ('--no-embedded' ):
2797+ print ('embedded mode is now the only mode available' , file = sys .stderr )
2798+ return 1
2799+
28222800 arg_notty = extract_bool_arg ('--notty' )
28232801 if arg_notty :
28242802 TTY_OUTPUT = False
@@ -3047,18 +3025,8 @@ def print_tools(t):
30473025 if arg_global :
30483026 print ('Registering active Emscripten environment globally for all users.' )
30493027 print ('' )
3050- if arg_embedded :
3051- # Activating the emsdk tools locally relative to Emscripten SDK directory.
3052- emscripten_config_directory = emsdk_path ()
3053- print ('Writing .emscripten configuration file to Emscripten SDK directory ' + emscripten_config_directory )
3054- else :
3055- print ('Writing .emscripten configuration file to user home directory ' + emscripten_config_directory )
3056- # Remove .emscripten from emsdk dir, since its presence is used to detect
3057- # whether emsdk is activate in embedded mode or not.
3058- try :
3059- os .remove (os .path .join (emsdk_path (), ".emscripten" ))
3060- except :
3061- pass
3028+
3029+ print ('Writing .emscripten configuration file in ' + emsdk_path ())
30623030
30633031 tools_to_activate = currently_active_tools ()
30643032 args = [x for x in sys .argv [2 :] if not x .startswith ('--' )]
0 commit comments