@@ -46,8 +46,8 @@ def process_funcs((i, funcs, meta, settings_file, compiler, forwarded_file, libr
46
46
tempfiles .try_delete (funcs_file )
47
47
return out
48
48
49
- def emscript (configuration , infile , settings , outfile , libraries = [], compiler_engine = None ,
50
- jcache = None , temp_files = None ):
49
+ def emscript (infile , settings , outfile , libraries = [], compiler_engine = None ,
50
+ jcache = None , temp_files = None , DEBUG = False ):
51
51
"""Runs the emscripten LLVM-to-JS compiler. We parallelize as much as possible
52
52
53
53
Args:
@@ -66,7 +66,7 @@ def emscript(configuration, infile, settings, outfile, libraries=[], compiler_en
66
66
# 2 aka 'funcs': Process functions. We can parallelize this, working on each function independently.
67
67
# 3 aka 'post' : Process globals, generate postamble and finishing touches.
68
68
69
- configuration . debug_log ( 'emscript: ll=>js' )
69
+ if DEBUG : print >> sys . stderr , 'emscript: ll=>js'
70
70
71
71
if jcache : jcache .ensure ()
72
72
@@ -491,7 +491,7 @@ def fix(m):
491
491
492
492
outfile .close ()
493
493
494
- def main (args , compiler_engine , cache , jcache , relooper , temp_files , configuration ):
494
+ def main (args , compiler_engine , cache , jcache , relooper , temp_files , DEBUG ):
495
495
# Prepare settings for serialization to JSON.
496
496
settings = {}
497
497
for setting in args .settings :
@@ -572,10 +572,8 @@ def lookup(value):
572
572
from tools import shared
573
573
shared .Building .ensure_relooper (relooper )
574
574
575
- emscript (configuration , args .infile , settings , args .outfile , libraries ,
576
- compiler_engine = compiler_engine ,
577
- jcache = jcache ,
578
- temp_files = temp_files )
575
+ emscript (args .infile , settings , args .outfile , libraries , compiler_engine = compiler_engine ,
576
+ jcache = jcache , temp_files = temp_files , DEBUG = DEBUG )
579
577
580
578
def _main (environ ):
581
579
parser = optparse .OptionParser (
@@ -599,7 +597,7 @@ def _main(environ):
599
597
help = 'Which JS engine to use to run the compiler; defaults to the one in ~/.emscripten.' )
600
598
parser .add_option ('--relooper' ,
601
599
default = None ,
602
- help = 'Which relooper file to use if RELOOP is enabled' )
600
+ help = 'Which relooper file to use if RELOOP is enabled. ' )
603
601
parser .add_option ('-s' , '--setting' ,
604
602
dest = 'settings' ,
605
603
default = [],
@@ -611,6 +609,9 @@ def _main(environ):
611
609
action = 'store_true' ,
612
610
default = False ,
613
611
help = ('Enable jcache (ccache-like caching of compilation results, for faster incremental builds).' ))
612
+ parser .add_option ('-T' , '--temp-dir' ,
613
+ default = None ,
614
+ help = ('Where to create temporary files.' ))
614
615
parser .add_option ('--suppressUsageWarning' ,
615
616
action = 'store_true' ,
616
617
default = environ .get ('EMSCRIPTEN_SUPPRESS_USAGE_WARNING' ),
@@ -639,12 +640,21 @@ def _main(environ):
639
640
640
641
from tools import shared
641
642
configuration = shared .Configuration (environ = os .environ )
642
- temp_files = configuration .get_temp_files ()
643
+
644
+ if keywords .temp_dir is None :
645
+ temp_files = configuration .get_temp_files ()
646
+ else :
647
+ temp_dir = os .path .abspath (keywords .temp_dir )
648
+ if not os .path .exists (temp_dir ):
649
+ os .makedirs (temp_dir )
650
+ temp_files = tempfiles .TempFiles (temp_dir )
643
651
644
652
if keywords .compiler is None :
645
653
from tools import shared
646
654
keywords .compiler = shared .COMPILER_ENGINE
647
655
656
+ DEBUG = configuration .DEBUG
657
+
648
658
cache = cache_module .Cache ()
649
659
temp_files .run_and_clean (lambda : main (
650
660
keywords ,
@@ -653,7 +663,7 @@ def _main(environ):
653
663
jcache = cache_module .JCache (cache ) if keywords .jcache else None ,
654
664
relooper = relooper ,
655
665
temp_files = temp_files ,
656
- configuration = configuration
666
+ DEBUG = DEBUG
657
667
))
658
668
659
669
if __name__ == '__main__' :
0 commit comments