@@ -119,10 +119,12 @@ def exit_with_error(msg):
119
119
CSH = bool (os .getenv ('EMSDK_CSH' ))
120
120
CMD = bool (os .getenv ('EMSDK_CMD' ))
121
121
BASH = bool (os .getenv ('EMSDK_BASH' ))
122
+ FISH = bool (os .getenv ('EMSDK_FISH' ))
123
+
122
124
if WINDOWS and BASH :
123
125
MSYS = True
124
126
125
- if not CSH and not POWERSHELL and not BASH and not CMD :
127
+ if not CSH and not POWERSHELL and not BASH and not CMD and not FISH :
126
128
# Fall back to default of `cmd` on windows and `bash` otherwise
127
129
if WINDOWS and not MSYS :
128
130
CMD = True
@@ -1503,6 +1505,22 @@ def find_emscripten_root(active_tools):
1503
1505
return root
1504
1506
1505
1507
1508
+ # returns a tuple (string,string) of config files paths that need to used
1509
+ # to activate emsdk env depending on $SHELL, defaults to bash.
1510
+ def get_emsdk_shell_env_configs ():
1511
+ default_emsdk_env = sdk_path ('emsdk_env.sh' )
1512
+ default_shell_config_file = '$HOME/.bash_profile'
1513
+ shell = os .getenv ('SHELL' , '' )
1514
+ if 'zsh' in shell :
1515
+ return (default_emsdk_env , '$HOME/.zprofile' )
1516
+ elif 'csh' in shell :
1517
+ return (sdk_path ('emsdk_env.csh' ), '$HOME/.cshrc' )
1518
+ elif 'fish' in shell :
1519
+ return (sdk_path ('emsdk_env.fish' ), '$HOME/.config/fish/config.fish' )
1520
+ else :
1521
+ return (default_emsdk_env , default_shell_config_file )
1522
+
1523
+
1506
1524
def generate_em_config (active_tools , permanently_activate , system ):
1507
1525
cfg = 'import os\n '
1508
1526
cfg += "emsdk_path = os.path.dirname(os.getenv('EM_CONFIG')).replace('\\ \\ ', '/')\n "
@@ -1556,22 +1574,16 @@ def generate_em_config(active_tools, permanently_activate, system):
1556
1574
print ('- Consider running `emsdk activate` with --permanent or --system' )
1557
1575
print (' to have emsdk settings available on startup.' )
1558
1576
else :
1559
- emsdk_env = sdk_path ('emsdk_env.sh' )
1560
1577
print ('Next steps:' )
1561
1578
print ('- To conveniently access emsdk tools from the command line,' )
1562
1579
print (' consider adding the following directories to your PATH:' )
1563
1580
for p in path_add :
1564
1581
print (' ' + p )
1565
1582
print ('- This can be done for the current shell by running:' )
1583
+ emsdk_env , shell_config_file = get_emsdk_shell_env_configs ()
1566
1584
print (' source "%s"' % emsdk_env )
1567
1585
print ('- Configure emsdk in your shell startup scripts by running:' )
1568
- shell = os .getenv ('SHELL' , '' )
1569
- if 'zsh' in shell :
1570
- print (' echo \' source "%s"\' >> $HOME/.zprofile' % emsdk_env )
1571
- elif 'csh' in shell :
1572
- print (' echo \' source "%s"\' >> $HOME/.cshrc' % emsdk_env )
1573
- else :
1574
- print (' echo \' source "%s"\' >> $HOME/.bash_profile' % emsdk_env )
1586
+ print (' echo \' source "%s"\' >> %s' % (emsdk_env , shell_config_file ))
1575
1587
1576
1588
1577
1589
def find_msbuild_dir ():
@@ -2578,6 +2590,8 @@ def unset_env(key):
2578
2590
return 'set %s=\n ' % key
2579
2591
if CSH :
2580
2592
return 'unsetenv %s;\n ' % key
2593
+ if FISH :
2594
+ return 'set -e %s;\n ' % key
2581
2595
if BASH :
2582
2596
return 'unset %s;\n ' % key
2583
2597
assert False
@@ -2599,6 +2613,8 @@ def construct_env_with_vars(env_vars_to_add):
2599
2613
env_string += 'SET ' + key + '=' + value + '\n '
2600
2614
elif CSH :
2601
2615
env_string += 'setenv ' + key + ' "' + value + '";\n '
2616
+ elif FISH :
2617
+ env_string += 'set -gx ' + key + ' "' + value + '";\n '
2602
2618
elif BASH :
2603
2619
env_string += 'export ' + key + '="' + value + '";\n '
2604
2620
else :
@@ -2616,7 +2632,7 @@ def construct_env_with_vars(env_vars_to_add):
2616
2632
# of the SDK but we want to remove that from the current environment
2617
2633
# if no such tool is active.
2618
2634
# Ignore certain keys that are inputs to emsdk itself.
2619
- ignore_keys = set (['EMSDK_POWERSHELL' , 'EMSDK_CSH' , 'EMSDK_CMD' , 'EMSDK_BASH' ,
2635
+ ignore_keys = set (['EMSDK_POWERSHELL' , 'EMSDK_CSH' , 'EMSDK_CMD' , 'EMSDK_BASH' , 'EMSDK_FISH'
2620
2636
'EMSDK_NUM_CORES' , 'EMSDK_NOTTY' , 'EMSDK_KEEP_DOWNLOADS' ])
2621
2637
env_keys_to_add = set (pair [0 ] for pair in env_vars_to_add )
2622
2638
for key in os .environ :
0 commit comments