svgui/pyjs/build.py
changeset 1730 64d8f52bc8c8
parent 728 e0424e96e3fd
child 1734 750eeb7230a1
equal deleted inserted replaced
1726:d51af006fa6b 1730:64d8f52bc8c8
   304 
   304 
   305     # First, generate all the code.
   305     # First, generate all the code.
   306     # Second, (dynamic only), post-analyse the places where modules
   306     # Second, (dynamic only), post-analyse the places where modules
   307     # haven't changed
   307     # haven't changed
   308     # Third, write everything out.
   308     # Third, write everything out.
   309     
   309 
   310     for platform in app_platforms:
   310     for platform in app_platforms:
   311 
   311 
   312         mod_code[platform] = {}
   312         mod_code[platform] = {}
   313         mod_libs[platform] = {}
   313         mod_libs[platform] = {}
   314         modules[platform] = []
   314         modules[platform] = []
   335             pd[platform] = name
   335             pd[platform] = name
   336 
   336 
   337         print appcode
   337         print appcode
   338         #mod_code[platform][app_name] = appcode
   338         #mod_code[platform][app_name] = appcode
   339 
   339 
   340         # platform.Module.cache.js 
   340         # platform.Module.cache.js
   341 
   341 
   342         modules_done = ['pyjslib', 'sys', '_pyjs.js']
   342         modules_done = ['pyjslib', 'sys', '_pyjs.js']
   343         #modules_to_do = [app_name] + app_translator.library_modules
   343         #modules_to_do = [app_name] + app_translator.library_modules
   344         modules_to_do = [app_name] + app_translator.library_modules 
   344         modules_to_do = [app_name] + app_translator.library_modules
   345 
   345 
   346         dependencies = {}
   346         dependencies = {}
   347 
   347 
   348         deps = map(pyjs.strip_py, modules_to_do)
   348         deps = map(pyjs.strip_py, modules_to_do)
   349         for d in deps:
   349         for d in deps:
   401             modules_to_do += add_subdeps(dependencies, mod_name)
   401             modules_to_do += add_subdeps(dependencies, mod_name)
   402             #print "modname:", mod_name, deps
   402             #print "modname:", mod_name, deps
   403             deps = uniquify(deps)
   403             deps = uniquify(deps)
   404             #print "modname:", mod_name, deps
   404             #print "modname:", mod_name, deps
   405             dependencies[mod_name] = deps
   405             dependencies[mod_name] = deps
   406             
   406 
   407         # work out the dependency ordering of the modules
   407         # work out the dependency ordering of the modules
   408     
   408 
   409         mod_levels[platform] = make_deps(None, dependencies, modules_done)
   409         mod_levels[platform] = make_deps(None, dependencies, modules_done)
   410 
   410 
   411     # now write everything out
   411     # now write everything out
   412 
   412 
   413     for platform in app_platforms:
   413     for platform in app_platforms:
   471             else:
   471             else:
   472                 mod_cache_html_output.seek(0)
   472                 mod_cache_html_output.seek(0)
   473                 app_libs_ += mod_cache_html_output.read()
   473                 app_libs_ += mod_cache_html_output.read()
   474 
   474 
   475         # write out the dependency ordering of the modules
   475         # write out the dependency ordering of the modules
   476     
   476 
   477         app_modnames = []
   477         app_modnames = []
   478 
   478 
   479         for md in mod_levels[platform]:
   479         for md in mod_levels[platform]:
   480             mnames = map(lambda x: "'%s'" % x, md)
   480             mnames = map(lambda x: "'%s'" % x, md)
   481             mnames = "new pyjslib.List([\n\t\t\t%s])" % ',\n\t\t\t'.join(mnames)
   481             mnames = "new pyjslib.List([\n\t\t\t%s])" % ',\n\t\t\t'.join(mnames)
   510         if cache_buster:
   510         if cache_buster:
   511             digest = md5.new(file_contents).hexdigest()
   511             digest = md5.new(file_contents).hexdigest()
   512             file_name = "%s.%s.%s" % (platform.lower(), app_name, digest)
   512             file_name = "%s.%s.%s" % (platform.lower(), app_name, digest)
   513         else:
   513         else:
   514             file_name = "%s.%s" % (platform.lower(), app_name)
   514             file_name = "%s.%s" % (platform.lower(), app_name)
   515         file_name += ".cache.html" 
   515         file_name += ".cache.html"
   516         out_path = join(output, file_name)
   516         out_path = join(output, file_name)
   517         out_file = open(out_path, 'w')
   517         out_file = open(out_path, 'w')
   518         out_file.write(file_contents)
   518         out_file.write(file_contents)
   519         out_file.close()
   519         out_file.close()
   520         app_files.append((platform.lower(), file_name))
   520         app_files.append((platform.lower(), file_name))
   597     res = []
   597     res = []
   598     for mod in mod_list:
   598     for mod in mod_list:
   599         if has_nodeps(mod, deps):
   599         if has_nodeps(mod, deps):
   600             res.append(mod)
   600             res.append(mod)
   601     return res
   601     return res
   602         
   602 
   603 # this function takes a dictionary of dependent modules and
   603 # this function takes a dictionary of dependent modules and
   604 # creates a list of lists.  the first list will be modules
   604 # creates a list of lists.  the first list will be modules
   605 # that have no dependencies; the second list will be those
   605 # that have no dependencies; the second list will be those
   606 # modules that have the first list as dependencies; the
   606 # modules that have the first list as dependencies; the
   607 # third will be those modules that have the first and second...
   607 # third will be those modules that have the first and second...
   719           options.debug, options.dynamic and 1 or 0, data_dir,
   719           options.debug, options.dynamic and 1 or 0, data_dir,
   720           options.cache_buster, options.optimize)
   720           options.cache_buster, options.optimize)
   721 
   721 
   722 if __name__ == "__main__":
   722 if __name__ == "__main__":
   723     main()
   723     main()
   724