svgui/pyjs/build.py
changeset 1744 69dfdb26f600
parent 1742 92932cd370a4
child 1746 45d6f5fba016
equal deleted inserted replaced
1743:c3c3d1318130 1744:69dfdb26f600
   260 
   260 
   261     for platform, file_prefix in app_files:
   261     for platform, file_prefix in app_files:
   262         print >> script_selectors, select_tmpl % (platform, file_prefix)
   262         print >> script_selectors, select_tmpl % (platform, file_prefix)
   263 
   263 
   264     print >>home_nocache_html_output, home_nocache_html_template % dict(
   264     print >>home_nocache_html_output, home_nocache_html_template % dict(
   265         app_name = app_name,
   265         app_name=app_name,
   266         script_selectors = script_selectors.getvalue(),
   266         script_selectors=script_selectors.getvalue(),
   267     )
   267     )
   268 
   268 
   269     home_nocache_html_output.close()
   269     home_nocache_html_output.close()
   270 
   270 
   271     print "Done. You can run your app by opening '%(html_output_filename)s' in a browser" % locals()
   271     print "Done. You can run your app by opening '%(html_output_filename)s' in a browser" % locals()
   456                 mod_cache_html_output = open(join(output, mod_cache_name), "w")
   456                 mod_cache_html_output = open(join(output, mod_cache_name), "w")
   457             else:
   457             else:
   458                 mod_cache_html_output = StringIO()
   458                 mod_cache_html_output = StringIO()
   459 
   459 
   460             print >>mod_cache_html_output, mod_cache_html_template % dict(
   460             print >>mod_cache_html_output, mod_cache_html_template % dict(
   461                 mod_name = mod_name,
   461                 mod_name=mod_name,
   462                 app_name = app_name,
   462                 app_name=app_name,
   463                 modnames = modnames,
   463                 modnames=modnames,
   464                 overrides = overnames,
   464                 overrides=overnames,
   465                 mod_libs = mod_libs[platform][mod_name],
   465                 mod_libs=mod_libs[platform][mod_name],
   466                 dynamic = dynamic,
   466                 dynamic=dynamic,
   467                 mod_code = mod_code_,
   467                 mod_code=mod_code_,
   468             )
   468             )
   469 
   469 
   470             if dynamic:
   470             if dynamic:
   471                 mod_cache_html_output.close()
   471                 mod_cache_html_output.close()
   472             else:
   472             else:
   495 
   495 
   496         # now write app.allcache including dependency-ordered list of
   496         # now write app.allcache including dependency-ordered list of
   497         # library modules
   497         # library modules
   498 
   498 
   499         file_contents = all_cache_html_template % dict(
   499         file_contents = all_cache_html_template % dict(
   500             app_name = app_name,
   500             app_name=app_name,
   501             early_app_libs = early_app_libs_,
   501             early_app_libs=early_app_libs_,
   502             app_libs = app_libs_,
   502             app_libs=app_libs_,
   503             app_code = app_code_,
   503             app_code=app_code_,
   504             app_body = app_body,
   504             app_body=app_body,
   505             overrides = overnames,
   505             overrides=overnames,
   506             platform = platform.lower(),
   506             platform=platform.lower(),
   507             dynamic = dynamic,
   507             dynamic=dynamic,
   508             app_modnames = app_modnames,
   508             app_modnames=app_modnames,
   509             app_headers = app_headers
   509             app_headers=app_headers
   510         )
   510         )
   511         if cache_buster:
   511         if cache_buster:
   512             digest = md5.new(file_contents).hexdigest()
   512             digest = md5.new(file_contents).hexdigest()
   513             file_name = "%s.%s.%s" % (platform.lower(), app_name, digest)
   513             file_name = "%s.%s.%s" % (platform.lower(), app_name, digest)
   514         else:
   514         else:
   670 
   670 
   671 
   671 
   672 def main():
   672 def main():
   673     global app_platforms
   673     global app_platforms
   674 
   674 
   675     parser = OptionParser(usage = usage, version = version)
   675     parser = OptionParser(usage=usage, version=version)
   676     parser.add_option("-o", "--output", dest="output",
   676     parser.add_option("-o", "--output", dest="output",
   677         help="directory to which the webapp should be written")
   677         help="directory to which the webapp should be written")
   678     parser.add_option("-j", "--include-js", dest="js_includes", action="append",
   678     parser.add_option("-j", "--include-js", dest="js_includes", action="append",
   679         help="javascripts to load into the same frame as the rest of the script")
   679         help="javascripts to load into the same frame as the rest of the script")
   680     parser.add_option("-I", "--library_dir", dest="library_dirs",
   680     parser.add_option("-I", "--library_dir", dest="library_dirs",
   693                       )
   693                       )
   694     parser.add_option("-c", "--cache_buster", action="store_true",
   694     parser.add_option("-c", "--cache_buster", action="store_true",
   695                   dest="cache_buster",
   695                   dest="cache_buster",
   696         help="Enable browser cache-busting (MD5 hash added to output filenames)")
   696         help="Enable browser cache-busting (MD5 hash added to output filenames)")
   697 
   697 
   698     parser.set_defaults(output = "output", js_includes=[], library_dirs=[],
   698     parser.set_defaults(output="output", js_includes=[], library_dirs=[],
   699                         platforms=(','.join(app_platforms)),
   699                         platforms=(','.join(app_platforms)),
   700                         data_dir=os.path.join(sys.prefix, "share/pyjamas"),
   700                         data_dir=os.path.join(sys.prefix, "share/pyjamas"),
   701                         dynamic=False,
   701                         dynamic=False,
   702                         cache_buster=False,
   702                         cache_buster=False,
   703                         debug=False)
   703                         debug=False)