9696else :
9797 ENVPATH_SEPARATOR = ':'
9898
99-
10099ARCH = 'unknown'
101100# platform.machine() may return AMD64 on windows, so standardize the case.
102101machine = platform .machine ().lower ()
@@ -170,18 +169,7 @@ def emsdk_path():
170169if os .path .exists (os .path .join (emsdk_path (), '.emscripten' )):
171170 emscripten_config_directory = emsdk_path ()
172171
173-
174- def get_set_env_script_name ():
175- if POWERSHELL :
176- return 'emsdk_set_env.ps1'
177- if WINDOWS and not MSYS :
178- return 'emsdk_set_env.bat'
179- if CSH :
180- return 'emsdk_set_env.csh'
181- return 'emsdk_set_env.sh'
182-
183-
184- EMSDK_SET_ENV = os .path .join (emsdk_path (), get_set_env_script_name ())
172+ EMSDK_SET_ENV = os .path .join (emsdk_path (), 'emsdk_set_env.bat' )
185173
186174ARCHIVE_SUFFIXES = ('zip' , '.tar' , '.gz' , '.xz' , '.tbz2' , '.bz2' )
187175
@@ -2479,6 +2467,11 @@ def copy_pregenerated_cache(tools_to_activate):
24792467 os .path .join (out_cache , filename ))
24802468
24812469
2470+ def write_set_env_bat (env_string ):
2471+ assert (WINDOWS )
2472+ open (EMSDK_SET_ENV , 'w' ).write (env_string )
2473+
2474+
24822475# Reconfigure .emscripten to choose the currently activated toolset, set PATH
24832476# and other environment variables.
24842477# Returns the full list of deduced tools that are now active.
@@ -2503,7 +2496,7 @@ def set_active_tools(tools_to_activate, permanently_activate):
25032496 # required.
25042497 if WINDOWS :
25052498 env_string = construct_env (tools_to_activate )
2506- open ( EMSDK_SET_ENV , 'w' ). write (env_string )
2499+ write_set_env_bat (env_string )
25072500
25082501 # Apply environment variables to global all users section.
25092502 if WINDOWS and permanently_activate :
@@ -2599,6 +2592,10 @@ def adjusted_path(tools_to_activate, log_additions=False, system_path_only=False
25992592 return (separator .join (whole_path ), new_emsdk_tools )
26002593
26012594
2595+ def log_stderr (msg ):
2596+ sys .stderr .write (str (msg ) + '\n ' )
2597+
2598+
26022599def construct_env (tools_to_activate ):
26032600 env_string = ''
26042601 newpath , added_path = adjusted_path (tools_to_activate )
@@ -2610,17 +2607,17 @@ def construct_env(tools_to_activate):
26102607 elif CMD :
26112608 env_string += 'SET PATH=' + newpath + '\n '
26122609 elif CSH :
2613- env_string += 'setenv PATH "' + newpath + '"\n '
2610+ env_string += 'setenv PATH "' + newpath + '"; \n '
26142611 elif BASH :
2615- env_string += 'export PATH="' + newpath + '"\n '
2612+ env_string += 'export PATH="' + newpath + '"; \n '
26162613 else :
26172614 assert False
26182615
26192616 if added_path :
2620- print ('Adding directories to PATH:' )
2617+ log_stderr ('Adding directories to PATH:' )
26212618 for item in added_path :
2622- print ('PATH += ' + item )
2623- print ('' )
2619+ log_stderr ('PATH += ' + item )
2620+ log_stderr ('' )
26242621
26252622 # A core variable EMSDK points to the root of Emscripten SDK directory.
26262623 env_vars = [('EMSDK' , to_unix_path (emsdk_path ()))]
@@ -2649,19 +2646,19 @@ def construct_env(tools_to_activate):
26492646 env_vars_to_add .append ((key , value ))
26502647
26512648 if env_vars_to_add :
2652- print ('Setting environment variables:' )
2649+ log_stderr ('Setting environment variables:' )
26532650 for key , value in env_vars_to_add :
26542651 if POWERSHELL :
26552652 env_string += '$env:' + key + '="' + value + '"\n '
26562653 elif CMD :
26572654 env_string += 'SET ' + key + '=' + value + '\n '
26582655 elif CSH :
2659- env_string += 'setenv ' + key + ' "' + value + '"\n '
2656+ env_string += 'setenv ' + key + ' "' + value + '"; \n '
26602657 elif BASH :
2661- env_string += 'export ' + key + '="' + value + '"\n '
2658+ env_string += 'export ' + key + '="' + value + '"; \n '
26622659 else :
26632660 assert False
2664- print (key + ' = ' + value )
2661+ log_stderr (key + ' = ' + value )
26652662 return env_string
26662663
26672664
@@ -3023,19 +3020,20 @@ def print_tools(t):
30233020 elif cmd == 'construct_env' :
30243021 # Clean up old temp file up front, in case of failure later before we get
30253022 # to write out the new one.
3026- silentremove (EMSDK_SET_ENV )
30273023 tools_to_activate = currently_active_tools ()
30283024 tools_to_activate = process_tool_list (tools_to_activate , log_errors = True )
30293025 env_string = construct_env (tools_to_activate )
3030- open (EMSDK_SET_ENV , 'w' ).write (env_string )
3031- if UNIX :
3032- os .chmod (EMSDK_SET_ENV , 0o755 )
3026+ if WINDOWS and not BASH :
3027+ write_set_env_bat (env_string )
3028+ else :
3029+ sys .stdout .write (env_string )
30333030 return 0
30343031 elif cmd == 'update' :
30353032 update_emsdk ()
3036- # Clean up litter after old emsdk update which may have left this temp file
3037- # around.
3038- silentremove (sdk_path (EMSDK_SET_ENV ))
3033+ if WINDOWS :
3034+ # Clean up litter after old emsdk update which may have left this temp
3035+ # file around.
3036+ silentremove (sdk_path (EMSDK_SET_ENV ))
30393037 return 0
30403038 elif cmd == 'update-tags' :
30413039 fetch_emscripten_tags ()
0 commit comments