| OLD | NEW | 
|    1 #!/usr/bin/python2.4 |    1 #!/usr/bin/python2.4 | 
|    2 # Copyright 2009, Google Inc. |    2 # Copyright 2009, Google Inc. | 
|    3 # All rights reserved. |    3 # All rights reserved. | 
|    4 # |    4 # | 
|    5 # Redistribution and use in source and binary forms, with or without |    5 # Redistribution and use in source and binary forms, with or without | 
|    6 # modification, are permitted provided that the following conditions are |    6 # modification, are permitted provided that the following conditions are | 
|    7 # met: |    7 # met: | 
|    8 # |    8 # | 
|    9 #     * Redistributions of source code must retain the above copyright |    9 #     * Redistributions of source code must retain the above copyright | 
|   10 # notice, this list of conditions and the following disclaimer. |   10 # notice, this list of conditions and the following disclaimer. | 
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   89   return os.path.join(_script_path, *file_paths) |   89   return os.path.join(_script_path, *file_paths) | 
|   90  |   90  | 
|   91  |   91  | 
|   92 def MakeCommandName(name): |   92 def MakeCommandName(name): | 
|   93   """adds '.exe' if on Windows""" |   93   """adds '.exe' if on Windows""" | 
|   94   if os.name == 'nt': |   94   if os.name == 'nt': | 
|   95     return name + '.exe' |   95     return name + '.exe' | 
|   96   return name |   96   return name | 
|   97  |   97  | 
|   98  |   98  | 
|   99 def UpdateGlobals(dict): |  | 
|  100   """Copies pairs from dict into GlobalDict.""" |  | 
|  101   for i, v in dict.items(): |  | 
|  102     GlobalsDict.__setitem__(i, v) |  | 
|  103  |  | 
|  104  |  | 
|  105 def GetCallingNamespaces(): |  | 
|  106   """Return the locals and globals for the function that called |  | 
|  107   into this module in the current call stack.""" |  | 
|  108   try: 1/0 |  | 
|  109   except ZeroDivisionError: |  | 
|  110     # Don't start iterating with the current stack-frame to |  | 
|  111     # prevent creating reference cycles (f_back is safe). |  | 
|  112     frame = sys.exc_info()[2].tb_frame.f_back |  | 
|  113  |  | 
|  114   # Find the first frame that *isn't* from this file |  | 
|  115   while frame.f_globals.get("__name__") == __name__: |  | 
|  116     frame = frame.f_back |  | 
|  117  |  | 
|  118   return frame.f_locals, frame.f_globals |  | 
|  119  |  | 
|  120  |  | 
|  121 def ComputeExports(exports): |  | 
|  122   """Compute a dictionary of exports given one of the parameters |  | 
|  123   to the Export() function or the exports argument to SConscript().""" |  | 
|  124  |  | 
|  125   loc, glob = GetCallingNamespaces() |  | 
|  126  |  | 
|  127   retval = {} |  | 
|  128   try: |  | 
|  129     for export in exports: |  | 
|  130       if isinstance(export, types.DictType): |  | 
|  131         retval.update(export) |  | 
|  132       else: |  | 
|  133         try: |  | 
|  134           retval[export] = loc[export] |  | 
|  135         except KeyError: |  | 
|  136           retval[export] = glob[export] |  | 
|  137   except KeyError, x: |  | 
|  138     raise Error, "Export of non-existent variable '%s'"%x |  | 
|  139  |  | 
|  140   return retval |  | 
|  141  |  | 
|  142  |  | 
|  143 def Export(*vars): |  | 
|  144   """Copies the named variables to GlobalDict.""" |  | 
|  145   for var in vars: |  | 
|  146     UpdateGlobals(ComputeExports(vars)) |  | 
|  147  |  | 
|  148  |  | 
|  149 def Import(filename): |  | 
|  150   """Imports a python file in a scope with 'Export' defined.""" |  | 
|  151   scope = {'__builtins__': globals()['__builtins__'], |  | 
|  152            'Export': Export} |  | 
|  153   file = open(filename, 'r') |  | 
|  154   exec file in scope |  | 
|  155   file.close() |  | 
|  156  |  | 
|  157  |  | 
|  158 def Execute(args): |   99 def Execute(args): | 
|  159   """Executes an external program.""" |  100   """Executes an external program.""" | 
|  160   # Comment the next line in for debugging. |  101   # Comment the next line in for debugging. | 
|  161   # print "Execute: ", ' '.join(args) |  102   # print "Execute: ", ' '.join(args) | 
|  162   if subprocess.call(args) > 0: |  103   if subprocess.call(args) > 0: | 
|  163     raise RuntimeError('FAILED: ' + ' '.join(args)) |  104     raise RuntimeError('FAILED: ' + ' '.join(args)) | 
|  164  |  105  | 
|  165  |  106  | 
|  166 def AppendBasePath(folder, filenames): |  107 def AppendBasePath(folder, filenames): | 
|  167   """Appends a base path to a ist of files""" |  108   """Appends a base path to a ist of files""" | 
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  359   o3d_docs_ezt_outpath = MakePath(docs_outpath, 'reference') |  300   o3d_docs_ezt_outpath = MakePath(docs_outpath, 'reference') | 
|  360   o3d_docs_html_outpath = MakePath(docs_outpath, 'local_html') |  301   o3d_docs_html_outpath = MakePath(docs_outpath, 'local_html') | 
|  361   o3djs_docs_ezt_outpath = MakePath(docs_outpath, 'reference', 'jsdocs') |  302   o3djs_docs_ezt_outpath = MakePath(docs_outpath, 'reference', 'jsdocs') | 
|  362   o3djs_docs_html_outpath = MakePath(docs_outpath, 'local_html', 'jsdocs') |  303   o3djs_docs_html_outpath = MakePath(docs_outpath, 'local_html', 'jsdocs') | 
|  363   o3d_externs_path = MakePath(_output_dir, 'o3d-externs.js') |  304   o3d_externs_path = MakePath(_output_dir, 'o3d-externs.js') | 
|  364   o3djs_exports_path = MakePath(_output_dir, 'o3d-exports.js') |  305   o3djs_exports_path = MakePath(_output_dir, 'o3d-exports.js') | 
|  365   compiled_o3djs_outpath = MakePath(docs_outpath, 'base.js') |  306   compiled_o3djs_outpath = MakePath(docs_outpath, 'base.js') | 
|  366   externs_path = MakePath('externs', 'externs.js') |  307   externs_path = MakePath('externs', 'externs.js') | 
|  367   o3d_extra_externs_path = MakePath('externs', 'o3d-extra-externs.js') |  308   o3d_extra_externs_path = MakePath('externs', 'o3d-extra-externs.js') | 
|  368  |  309  | 
|  369   Import(js_list_filename) |  310   js_list = eval(open(js_list_filename, "r").read()) | 
|  370   Import(idl_list_filename) |  311   idl_list = eval(open(idl_list_filename, "r").read()) | 
|  371  |  312  | 
|  372   idl_files = AppendBasePath(idl_list_basepath, GlobalsDict['O3D_IDL_SOURCES']) |  313   idl_files = AppendBasePath(idl_list_basepath, idl_list) | 
|  373   o3djs_files = AppendBasePath(js_list_basepath, GlobalsDict['O3D_JS_SOURCES']) |  314   o3djs_files = AppendBasePath(js_list_basepath, js_list) | 
|  374  |  315  | 
|  375   # we need to put base.js first? |  316   # we need to put base.js first? | 
|  376   o3djs_files = ( |  317   o3djs_files = ( | 
|  377       filter(lambda x: x.endswith('base.js'), o3djs_files) + |  318       filter(lambda x: x.endswith('base.js'), o3djs_files) + | 
|  378       filter(lambda x: not x.endswith('base.js'), o3djs_files)) |  319       filter(lambda x: not x.endswith('base.js'), o3djs_files)) | 
|  379  |  320  | 
|  380   docs_js_files = [os.path.join( |  321   docs_js_files = [os.path.join( | 
|  381                        docs_js_outpath, |  322                        docs_js_outpath, | 
|  382                        os.path.splitext(os.path.basename(f))[0] + '.js') |  323                        os.path.splitext(os.path.basename(f))[0] + '.js') | 
|  383                    for f in GlobalsDict['O3D_IDL_SOURCES']] |  324                    for f in idl_list] | 
|  384  |  325  | 
|  385   DeleteOldDocs(MakePath(docs_outpath)) |  326   DeleteOldDocs(MakePath(docs_outpath)) | 
|  386   BuildJavaScriptForDocsFromIDLs(idl_files, docs_js_outpath) |  327   BuildJavaScriptForDocsFromIDLs(idl_files, docs_js_outpath) | 
|  387   BuildO3DDocsFromJavaScript([o3d_extra_externs_path] + docs_js_files, |  328   BuildO3DDocsFromJavaScript([o3d_extra_externs_path] + docs_js_files, | 
|  388                              o3d_docs_ezt_outpath, o3d_docs_html_outpath) |  329                              o3d_docs_ezt_outpath, o3d_docs_html_outpath) | 
|  389   BuildO3DClassHierarchy(o3d_docs_html_outpath) |  330   BuildO3DClassHierarchy(o3d_docs_html_outpath) | 
|  390   BuildJavaScriptForExternsFromIDLs(idl_files, externs_js_outpath) |  331   BuildJavaScriptForExternsFromIDLs(idl_files, externs_js_outpath) | 
|  391   BuildO3DExternsFile(externs_js_outpath, |  332   BuildO3DExternsFile(externs_js_outpath, | 
|  392                       o3d_extra_externs_path, |  333                       o3d_extra_externs_path, | 
|  393                       o3d_externs_path) |  334                       o3d_externs_path) | 
|  394   BuildO3DJSDocs(o3djs_files + [o3d_externs_path], o3djs_docs_ezt_outpath, |  335   BuildO3DJSDocs(o3djs_files + [o3d_externs_path], o3djs_docs_ezt_outpath, | 
|  395                  o3djs_docs_html_outpath, o3djs_exports_path) |  336                  o3djs_docs_html_outpath, o3djs_exports_path) | 
|  396   CopyStaticFiles(o3d_docs_ezt_outpath, o3d_docs_html_outpath) |  337   CopyStaticFiles(o3d_docs_ezt_outpath, o3d_docs_html_outpath) | 
|  397   BuildCompiledO3DJS(o3djs_files + [o3djs_exports_path], |  338   BuildCompiledO3DJS(o3djs_files + [o3djs_exports_path], | 
|  398                      externs_path, |  339                      externs_path, | 
|  399                      o3d_externs_path, |  340                      o3d_externs_path, | 
|  400                      compiled_o3djs_outpath) |  341                      compiled_o3djs_outpath) | 
|  401  |  342  | 
|  402  |  343  | 
|  403 if __name__ == '__main__': |  344 if __name__ == '__main__': | 
|  404   main(sys.argv[1:]) |  345   main(sys.argv[1:]) | 
| OLD | NEW |