11#!/usr/bin/env python2
2-
3- '''
4- You should normally never use this! Use emcc instead.
2+ """You should normally never use this! Use emcc instead.
53
64This is a small wrapper script around the core JS compiler. This calls that
75compiler with the settings given to it. It can also read data from C/C++
86header files (so that the JS compiler can see the constants in those
97headers, for the libc implementation in JS).
10- '''
8+ """
119
1210from tools .toolchain_profiler import ToolchainProfiler
1311if __name__ == '__main__' :
@@ -61,8 +59,8 @@ def access_quote(prop):
6159 return access_quote
6260
6361
64- def emscript (infile , settings , outfile , libraries = None , compiler_engine = None ,
65- temp_files = None , DEBUG = None ):
62+ def emscript (infile , settings , outfile , libraries , compiler_engine , temp_files ,
63+ DEBUG ):
6664 """Runs the emscripten LLVM-to-JS compiler.
6765
6866 Args:
@@ -72,8 +70,6 @@ def emscript(infile, settings, outfile, libraries=None, compiler_engine=None,
7270 outfile: The file where the output is written.
7371 """
7472
75- if libraries is None : libraries = []
76-
7773 assert settings ['ASM_JS' ], 'fastcomp is asm.js-only (mode 1 or 2)'
7874
7975 success = False
@@ -1738,15 +1734,13 @@ def coerce(self, expression):
17381734]
17391735
17401736
1741- def emscript_wasm_backend (infile , settings , outfile , libraries = None , compiler_engine = None ,
1742- temp_files = None , DEBUG = None ):
1737+ def emscript_wasm_backend (infile , settings , outfile , libraries , compiler_engine ,
1738+ temp_files , DEBUG ):
17431739 # Overview:
17441740 # * Run LLVM backend to emit .s
17451741 # * Run Binaryen's s2wasm to generate WebAssembly.
17461742 # * We may also run some Binaryen passes here.
17471743
1748- if libraries is None : libraries = []
1749-
17501744 if shared .Settings .EXPERIMENTAL_USE_LLD :
17511745 wasm , metadata = build_wasm_lld (temp_files , infile , outfile , settings , DEBUG )
17521746 else :
@@ -2232,11 +2226,6 @@ def asmjs_mangle(name):
22322226 return '_' + '' .join (['_' if not c .isalnum () else c for c in name ])
22332227
22342228
2235- if os .environ .get ('EMCC_FAST_COMPILER' ) == '0' :
2236- logging .critical ('Non-fastcomp compiler is no longer available, please use fastcomp or an older version of emscripten' )
2237- sys .exit (1 )
2238-
2239-
22402229def normalize_line_endings (text ):
22412230 """Normalize to UNIX line endings.
22422231
@@ -2256,7 +2245,7 @@ def main(args, compiler_engine, cache, temp_files, DEBUG):
22562245 settings [name ] = asstr (value )
22572246
22582247 # libraries
2259- libraries = args .libraries [0 ].split (',' ) if len (args .libraries ) > 0 else []
2248+ libraries = args .libraries [0 ].split (',' ) if len (args .libraries ) else []
22602249
22612250 settings .setdefault ('STRUCT_INFO' , shared .path_from_root ('src' , 'struct_info.compiled.json' ))
22622251 struct_info = settings ['STRUCT_INFO' ]
@@ -2272,17 +2261,13 @@ def main(args, compiler_engine, cache, temp_files, DEBUG):
22722261 temp_files = temp_files , DEBUG = DEBUG )
22732262
22742263
2275- def _main (args = None ):
2276- if args is None :
2277- args = sys .argv [1 :]
2278-
2264+ def _main (args ):
22792265 substitute_response_files (args )
22802266
22812267 parser = argparse .ArgumentParser (
22822268 usage = '%(prog)s [-h] [-H HEADERS] [-o OUTFILE] [-c COMPILER_ENGINE] [-s FOO=BAR]* infile' ,
22832269 description = ('You should normally never use this! Use emcc instead. '
2284- 'This is a wrapper around the JS compiler, converting .ll to .js.' ),
2285- epilog = '' )
2270+ 'This is a wrapper around the JS compiler, converting .ll to .js.' ))
22862271 parser .add_argument ('-H' , '--headers' ,
22872272 default = [],
22882273 action = 'append' ,
@@ -2335,7 +2320,9 @@ def _main(args=None):
23352320 ''' )
23362321
23372322 if len (positional ) != 1 :
2338- raise RuntimeError ('Must provide exactly one positional argument. Got ' + str (len (positional )) + ': "' + '", "' .join (positional ) + '"' )
2323+ logging .error ('Must provide exactly one positional argument. Got ' + str (len (positional )) + ': "' + '", "' .join (positional ) + '"' )
2324+ return 1
2325+
23392326 keywords .infile = os .path .abspath (positional [0 ])
23402327 if isinstance (keywords .outfile , (type (u'' ), bytes )):
23412328 keywords .outfile = open (keywords .outfile , 'w' )
@@ -2365,7 +2352,7 @@ def _main(args=None):
23652352 temp_files = temp_files ,
23662353 DEBUG = DEBUG ,
23672354 ))
2355+ return 0
23682356
23692357if __name__ == '__main__' :
2370- _main ()
2371- sys .exit (0 )
2358+ sys .exit (_main (sys .argv [1 :]))
0 commit comments