@@ -1455,17 +1455,13 @@ def generate_dot_emscripten(active_tools):
1455
1455
if embedded :
1456
1456
cfg += 'import os\n '
1457
1457
cfg += "emsdk_path = os.path.dirname(os.environ.get('EM_CONFIG')).replace('\\ \\ ', '/')\n "
1458
- cfg += "CACHE = '%s'\n " % sdk_path ('.emscripten_cache' )
1459
1458
1460
1459
# Different tools may provide the same activated configs; the latest to be
1461
1460
# activated is the relevant one.
1462
1461
activated_config = OrderedDict ()
1463
1462
for tool in active_tools :
1464
- tool_cfg = tool .activated_config ()
1465
- if tool_cfg :
1466
- for specific_cfg in tool_cfg .split (';' ):
1467
- name , value = specific_cfg .split ('=' )
1468
- activated_config [name ] = value
1463
+ for name , value in tool .activated_config ().items ():
1464
+ activated_config [name ] = value
1469
1465
1470
1466
if 'NODE_JS' not in activated_config :
1471
1467
node_fallback = which ('nodejs' )
@@ -1474,7 +1470,7 @@ def generate_dot_emscripten(active_tools):
1474
1470
activated_config ['NODE_JS' ] = "'%s'" % node_fallback
1475
1471
1476
1472
for name , value in activated_config .items ():
1477
- cfg += name + ' = ' + value + '\n '
1473
+ cfg += name + " = '" + value + " '\n "
1478
1474
1479
1475
cfg += '''\
1480
1476
TEMP_DIR = '%s'
@@ -1493,11 +1489,9 @@ def generate_dot_emscripten(active_tools):
1493
1489
with open (dot_emscripten_path (), "w" ) as text_file :
1494
1490
text_file .write (cfg )
1495
1491
1496
- # Clear old cached emscripten content.
1492
+ # Clear old emscripten content.
1497
1493
try :
1498
- remove_tree (os .path .join (emscripten_config_directory , ".emscripten_cache" ))
1499
1494
os .remove (os .path .join (emscripten_config_directory , ".emscripten_sanity" ))
1500
- os .remove (os .path .join (emscripten_config_directory , ".emscripten_cache__last_clear" ))
1501
1495
except :
1502
1496
pass
1503
1497
@@ -1620,10 +1614,14 @@ def installation_dir(self):
1620
1614
# Returns the configuration item that needs to be added to .emscripten to make
1621
1615
# this Tool active for the current user.
1622
1616
def activated_config (self ):
1623
- if hasattr (self , 'activated_cfg' ):
1624
- return to_unix_path (self .expand_vars (self .activated_cfg ))
1625
- else :
1626
- return ''
1617
+ if not hasattr (self , 'activated_cfg' ):
1618
+ return {}
1619
+ config = OrderedDict ()
1620
+ expanded = to_unix_path (self .expand_vars (self .activated_cfg ))
1621
+ for specific_cfg in expanded .split (';' ):
1622
+ name , value = specific_cfg .split ('=' )
1623
+ config [name ] = value .strip ("'" )
1624
+ return config
1627
1625
1628
1626
def activated_environment (self ):
1629
1627
if hasattr (self , 'activated_env' ):
@@ -1727,20 +1725,18 @@ def is_active(self):
1727
1725
return False
1728
1726
1729
1727
activated_cfg = self .activated_config ()
1730
- if activated_cfg == '' :
1728
+ if not activated_cfg :
1731
1729
return len (deps ) > 0
1732
1730
1733
- activated_cfg = activated_cfg .split (';' )
1734
- for cfg in activated_cfg :
1735
- cfg = cfg .strip ()
1736
- key , value = parse_key_value (cfg )
1731
+ for key , value in activated_cfg .items ():
1737
1732
if key not in dot_emscripten :
1738
1733
debug_print (str (self ) + ' is not active, because key="' + key + '" does not exist in .emscripten' )
1739
1734
return False
1740
1735
1741
1736
# If running in embedded mode, all paths are stored dynamically relative
1742
1737
# to the emsdk root, so normalize those first.
1743
1738
dot_emscripten_key = dot_emscripten [key ].replace ("emsdk_path + '" , "'" + emsdk_path ())
1739
+ dot_emscripten_key = dot_emscripten_key .strip ("'" )
1744
1740
if dot_emscripten_key != value :
1745
1741
debug_print (str (self ) + ' is not active, because key="' + key + '" has value "' + dot_emscripten_key + '" but should have value "' + value + '"' )
1746
1742
return False
@@ -2448,31 +2444,6 @@ def run_emcc(tools_to_activate):
2448
2444
return
2449
2445
2450
2446
2451
- def emscripten_cache_directory ():
2452
- return os .path .join (emscripten_config_directory , ".emscripten_cache" )
2453
-
2454
-
2455
- # Copy over any emscripten cache contents that were pregenerated. This avoids
2456
- # the user needing to immediately build libc etc. on first run.
2457
- def copy_pregenerated_cache (tools_to_activate ):
2458
- for tool in tools_to_activate :
2459
- pregenerated_cache = getattr (tool , 'pregenerated_cache' , None )
2460
- if not pregenerated_cache :
2461
- continue
2462
- for cache_dir in pregenerated_cache :
2463
- # Finish the install of an emscripten-releases build.
2464
- install_path = to_native_path (sdk_path (tool .expand_vars (tool .install_path )))
2465
- in_cache = os .path .join (install_path , 'lib' , cache_dir )
2466
- if not os .path .exists (in_cache ):
2467
- continue
2468
- out_cache = os .path .join (emscripten_cache_directory (), cache_dir )
2469
- os .makedirs (out_cache )
2470
- for filename in os .listdir (in_cache ):
2471
- debug_print ('Copying %s to cache: %s' % (filename , out_cache ))
2472
- shutil .copy2 (os .path .join (in_cache , filename ),
2473
- os .path .join (out_cache , filename ))
2474
-
2475
-
2476
2447
# Reconfigure .emscripten to choose the currently activated toolset, set PATH
2477
2448
# and other environment variables.
2478
2449
# Returns the full list of deduced tools that are now active.
@@ -2489,8 +2460,6 @@ def set_active_tools(tools_to_activate, permanently_activate):
2489
2460
# copy the cache contents.
2490
2461
run_emcc (tools_to_activate )
2491
2462
2492
- copy_pregenerated_cache (tools_to_activate )
2493
-
2494
2463
# Construct a .bat script that will be invoked to set env. vars and PATH
2495
2464
if WINDOWS :
2496
2465
env_string = construct_env (tools_to_activate , False )
@@ -2628,15 +2597,14 @@ def construct_env(tools_to_activate, permanent):
2628
2597
em_config_path = os .path .normpath (dot_emscripten_path ())
2629
2598
if to_unix_path (os .environ .get ('EM_CONFIG' , '' )) != to_unix_path (em_config_path ):
2630
2599
env_vars_to_add += [('EM_CONFIG' , em_config_path )]
2631
- if emscripten_config_directory == emsdk_path ():
2632
- # Remove this once emscripten support CACHE in the config file:
2633
- # https://github.com/emscripten-core/emscripten/pull/11091
2634
- em_cache_dir = sdk_path ('.emscripten_cache' )
2635
- if to_unix_path (os .environ .get ('EM_CACHE' , '' )) != to_unix_path (em_cache_dir ):
2636
- env_vars_to_add += [('EM_CACHE' , em_cache_dir )]
2637
- mkdir_p (em_cache_dir )
2638
2600
2639
2601
for tool in tools_to_activate :
2602
+ config = tool .activated_config ()
2603
+ if 'EMSCRIPTEN_ROOT' in config :
2604
+ # For older emscripten versions that don't use this default we export
2605
+ # EM_CACHE.
2606
+ em_cache_dir = os .path .join (config ['EMSCRIPTEN_ROOT' ], 'cache' )
2607
+ env_vars_to_add += [('EM_CACHE' , em_cache_dir )]
2640
2608
envs = tool .activated_environment ()
2641
2609
for env in envs :
2642
2610
key , value = parse_key_value (env )
0 commit comments