def main(): usage = """ usage: %prog [ options ] [ -c command | module_name | script | - ] [ -- arguments ] """ parser = OptionParser(usage = usage) translator.add_compile_options(parser) parser.add_option( "--dynamic", dest="unlinked_modules", action="append", help="regular expression for modules that will not be linked" "and thus loaded dynamically" ) parser.add_option( "-c", dest="command", help="Python command to run") # override the default because we want print parser.set_defaults(print_statements=True) add_linker_options(parser) options, args = parser.parse_args() IS_REPL = False if len(args) == 0 or args[0] == '-': IS_REPL = True modules = ['main'] else: modules = args for d in options.library_dirs: pyjs.path.append(os.path.abspath(d)) #print "paths:", pyjs.path translator_arguments = translator.get_compile_options(options) linker = PyV8Linker(modules, output=options.output, platforms=[PLATFORM], path=pyjs.path, compiler=compiler, translator_arguments=translator_arguments) linker() fp = open(linker.out_file_mod, 'r') txt = fp.read() fp.close() #PyV8.debugger.enabled = True # create a context with an explicit global g = Global() ctxt = PyV8.JSContext(g) g.__context__ = ctxt # enter the context ctxt.enter() try: x = ctxt.eval(txt) except Exception, e: raise
def main(): usage = """ usage: %prog [ options ] [ -c command | module_name | script | - ] [ -- arguments ] """ parser = OptionParser(usage=usage) translator.add_compile_options(parser) parser.add_option( "--dynamic", dest="unlinked_modules", action="append", help="regular expression for modules that will not be linked" "and thus loaded dynamically") parser.add_option("-c", dest="command", help="Python command to run") # override the default because we want print parser.set_defaults(print_statements=True) add_linker_options(parser) options, args = parser.parse_args() IS_REPL = False if len(args) == 0 or args[0] == '-': IS_REPL = True modules = ['main'] else: modules = args for d in options.library_dirs: pyjs.path.append(os.path.abspath(d)) #print "paths:", pyjs.path translator_arguments = translator.get_compile_options(options) linker = PyV8Linker(modules, output=options.output, platforms=[PLATFORM], path=pyjs.path, compiler=compiler, translator_arguments=translator_arguments) linker() fp = open(linker.out_file_mod, 'r') txt = fp.read() fp.close() #PyV8.debugger.enabled = True # create a context with an explicit global g = Global() ctxt = PyV8.JSContext(g) g.__context__ = ctxt # enter the context ctxt.enter() try: x = ctxt.eval(txt) except Exception, e: raise
def build(top_module, pyjs, options, app_platforms, runtime_options, args): print "Building :", top_module print "PYJSPATH :", '\n '.join(['['] + [p for p in pyjs.path]) + '\n]' translator_arguments= translator.get_compile_options(options) l = BrowserLinker(args, output=options.output, platforms=app_platforms, path=pyjs.path, js_libs=options.js_includes, unlinked_modules=options.unlinked_modules, keep_lib_files=options.keep_lib_files, compile_inplace=options.compile_inplace, translator_arguments=translator_arguments, multi_file=options.multi_file, cache_buster=options.cache_buster, bootstrap_file=options.bootstrap_file, apploader_file=options.apploader_file, public_folder=options.public_folder, runtime_options=runtime_options, list_imports=options.list_imports, ) l() if not options.list_imports: print "Built to :", os.path.abspath(options.output) return print "Dependencies" for f, deps in l.dependencies.items(): print "%s\n%s" % (f, '\n'.join(map(lambda x: "\t%s" % x, deps))) print print "Visited Modules" for plat, deps in l.visited_modules.items(): print "%s\n%s" % (plat, '\n'.join(map(lambda x: "\t%s" % x, deps))) print
def main(): usage = """ usage: %prog [ options ] [ -c command | module_name | script | - ] [ -- arguments ] """ parser = OptionParser(usage = usage) translator.add_compile_options(parser) parser.add_option( "-c", dest="command", help="Python command to run") args = sys.argv[1:] app_args = [] if '--' in args: idx = args.index('--') app_args = args[idx+1:] args = args[0:idx] # override the default because we want print parser.set_defaults(print_statements=True) add_linker_options(parser) options, args = parser.parse_args(args) IS_REPL = False if len(args) == 0 or args[0] == '-': IS_REPL = True modules = ['main'] else: modules = args app_args[0:0] = [modules[0]] _modules = [] for mod in modules: if mod.startswith('.') or mod.startswith('/') or mod.endswith('.py'): pyjs.path[0:0] = [os.path.dirname(os.path.abspath(mod))] _modules.append(os.path.basename(mod).split('.')[0]) else: _modules.append(mod) modules = _modules pyjs.path[0:0] = [join(pyjs.pyjspth, 'stdlib')] pyjs.path.append(join(pyjs.pyjspth, 'pyjs', 'src')) for d in options.library_dirs: pyjs.path.append(os.path.abspath(d)) #print "paths:", pyjs.path translator_arguments = translator.get_compile_options(options) linker = PyV8Linker(modules, output=options.output, platforms=[PLATFORM], path=pyjs.path, compiler=translator.compiler, translator_arguments=translator_arguments) linker() fp = open(linker.out_file_mod, 'r') txt = fp.read() fp.close() #PyV8.debugger.enabled = True # create a context with an explicit global g = Global(app_args, pyjs.path) ctxt = PyV8.JSContext(g) g.__context__ = ctxt # enter the context ctxt.enter() try: x = ctxt.eval(txt) except Exception, e: print JSRuntimeError(ctxt, e).full()