diff options
Diffstat (limited to 'emscripten.py')
-rwxr-xr-x | emscripten.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/emscripten.py b/emscripten.py index 5674c33a..800ca8d7 100755 --- a/emscripten.py +++ b/emscripten.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python ''' You should normally never use this! Use emcc instead. @@ -35,7 +35,7 @@ def path_from_root(*pathelems): temp_files = shared.TempFiles() -def emscript(infile, settings, outfile): +def emscript(infile, settings, outfile, libraries=[]): """Runs the emscripten LLVM-to-JS compiler. Args: @@ -49,7 +49,7 @@ def emscript(infile, settings, outfile): s.write(settings) s.close() compiler = path_from_root('src', 'compiler.js') - shared.run_js(compiler, shared.COMPILER_ENGINE, [settings_file, infile], stdout=outfile, cwd=path_from_root('src')) + shared.run_js(compiler, shared.COMPILER_ENGINE, [settings_file, infile] + libraries, stdout=outfile, cwd=path_from_root('src')) outfile.close() @@ -123,12 +123,15 @@ def main(args): #print >> sys.stderr, 'new defs:', str(defines).replace(',', ',\n '), '\n\n' settings.setdefault('C_DEFINES', {}).update(defines) + # libraries + libraries = args.libraries[0].split(',') if len(args.libraries) > 0 else [] + # Compile the assembly to Javascript. - emscript(args.infile, json.dumps(settings), args.outfile) + emscript(args.infile, json.dumps(settings), args.outfile, libraries) if __name__ == '__main__': parser = optparse.OptionParser( - usage='usage: %prog [-h] [-O] [-m] [-H HEADERS] [-o OUTFILE] [-s FOO=BAR]* infile', + usage='usage: %prog [-h] [-H HEADERS] [-o OUTFILE] [-s FOO=BAR]* infile', description=('You should normally never use this! Use emcc instead. ' 'This is a wrapper around the JS compiler, converting .ll to .js.'), epilog='') @@ -136,6 +139,10 @@ if __name__ == '__main__': default=[], action='append', help='System headers (comma separated) whose #defines should be exposed to the compiled code.') + parser.add_option('-L', '--libraries', + default=[], + action='append', + help='Library files (comma separated) to use in addition to those in emscripten src/library_*.') parser.add_option('-o', '--outfile', default=sys.stdout, help='Where to write the output; defaults to stdout.') |