diff options
author | gspencer@google.com <gspencer@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-03 23:45:00 +0000 |
---|---|---|
committer | gspencer@google.com <gspencer@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-03 23:45:00 +0000 |
commit | 91331289a995eef199a0f3d715f306b3b92a1e6b (patch) | |
tree | e75abcc0be29691df13fc87b56e53e2b2c1fbe26 /o3d/documentation | |
parent | 04d4d5433e517210c77fcd0bccaba76a0de57e66 (diff) | |
download | chromium_src-91331289a995eef199a0f3d715f306b3b92a1e6b.zip chromium_src-91331289a995eef199a0f3d715f306b3b92a1e6b.tar.gz chromium_src-91331289a995eef199a0f3d715f306b3b92a1e6b.tar.bz2 |
This adds splitting of samples for the interactive sampler,
and docs building to the GYP build.
Review URL: http://codereview.chromium.org/159825
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22348 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/documentation')
-rw-r--r-- | o3d/documentation/build.scons | 3 | ||||
-rwxr-xr-x | o3d/documentation/build_docs.py | 89 | ||||
-rw-r--r-- | o3d/documentation/get_docs_files.py | 114 |
3 files changed, 169 insertions, 37 deletions
diff --git a/o3d/documentation/build.scons b/o3d/documentation/build.scons index 7bc998a..953490a 100644 --- a/o3d/documentation/build.scons +++ b/o3d/documentation/build.scons @@ -51,7 +51,8 @@ LOCAL_IDL_SOURCES = [IDL_DIR + i for i in O3D_IDL_SOURCES] JS_DIR = '$SCONSTRUCT_DIR/samples/o3djs/' LOCAL_JS_SOURCES = [JS_DIR + i for i in O3D_JS_SOURCES] -DOCSGEN_ARGS = ['$JSDOC_DIR/build_docs.py $JAVA_EXE'] +DOCSGEN_ARGS = ['$JSDOC_DIR/build_docs.py $JAVA_EXE ' + '$THIRD_PARTY $TARGET_ROOT/obj'] env["BUILDERS"]["JSDocs"] = Builder(action=env.Python(DOCSGEN_ARGS)) diff --git a/o3d/documentation/build_docs.py b/o3d/documentation/build_docs.py index c309996..3c96852 100755 --- a/o3d/documentation/build_docs.py +++ b/o3d/documentation/build_docs.py @@ -44,6 +44,8 @@ import re _java_exe = ''
+_output_dir = ''
+_third_party_dir = ''
_script_path = os.path.dirname(os.path.realpath(__file__))
_js_copyright = """
/*
@@ -81,9 +83,9 @@ _js_copyright = """ GlobalsDict = { }
-def MakePath(file_path):
- """Makes a path absolute given a path relativel to this script."""
- return os.path.join(_script_path, file_path)
+def MakePath(*file_paths):
+ """Makes a path absolute given a path relative to this script."""
+ return os.path.join(_script_path, *file_paths)
def UpdateGlobals(dict):
@@ -160,11 +162,10 @@ def AppendBasePath(folder, filenames): def RunNixysa(idl_files, generate, output_dir, nixysa_options):
"""Executes Nixysa."""
- python_exe = 'python'
Execute([
- python_exe,
- MakePath('../third_party/nixysa/codegen.py'),
- '--binding-module=o3d:%s' % MakePath('../plugin/o3d_binding.py'),
+ sys.executable,
+ MakePath(_third_party_dir, 'nixysa', 'codegen.py'),
+ '--binding-module=o3d:%s' % MakePath('..', 'plugin', 'o3d_binding.py'),
'--generate=' + generate,
'--force',
'--output-dir=' + output_dir] +
@@ -175,7 +176,7 @@ def RunNixysa(idl_files, generate, output_dir, nixysa_options): def RunJSDocToolkit(js_files, ezt_output_dir, html_output_dir, prefix, mode,
baseURL, topURL, exports_file):
"""Executes the JSDocToolkit."""
- list_filename = MakePath('../scons-out/docs/obj/doclist.conf')
+ list_filename = MakePath(_output_dir, 'doclist.conf')
f = open(list_filename, 'w')
f.write('{\nD:{\n')
f.write('prefix: "%s",\n' % prefix)
@@ -192,21 +193,24 @@ def RunJSDocToolkit(js_files, ezt_output_dir, html_output_dir, prefix, mode, f.write(']\n}\n')
f.close()
+ files_dir = MakePath(_third_party_dir, 'jsdoctoolkit', 'files')
Execute([
_java_exe,
- '-Djsdoc.dir=%s' % MakePath('../third_party/jsdoctoolkit/files'),
+ '-Djsdoc.dir=%s' % files_dir,
'-jar',
- MakePath('../third_party/jsdoctoolkit/files/jsrun.jar'),
- MakePath('../third_party/jsdoctoolkit/files/app/run.js'),
+ MakePath(files_dir, 'jsrun.jar'),
+ MakePath(files_dir, 'app', 'run.js'),
'-v',
- '-t=%s' % MakePath('./jsdoc-toolkit-templates//'),
+ '-t=%s' % MakePath('jsdoc-toolkit-templates'),
'-d=' + ezt_output_dir,
'-c=' + list_filename])
def DeleteOldDocs(docs_js_outpath):
- shutil.rmtree(docs_js_outpath);
-
+ try:
+ shutil.rmtree(docs_js_outpath);
+ except:
+ pass
def BuildJavaScriptForDocsFromIDLs(idl_files, output_dir):
RunNixysa(idl_files, 'jsheader', output_dir, ['--properties-equal-undefined'])
@@ -226,7 +230,7 @@ def BuildO3DDocsFromJavaScript(js_files, ezt_output_dir, html_output_dir): def BuildO3DJSDocs(js_files, ezt_output_dir, html_output_dir, exports_file):
RunJSDocToolkit(js_files, ezt_output_dir, html_output_dir, 'js_0_1_', 'o3djs',
- 'jsdocs/', '../', exports_file)
+ 'jsdocs', '..', exports_file)
def BuildO3DExternsFile(js_files_dir, extra_externs_file, externs_file):
@@ -261,7 +265,7 @@ def BuildCompiledO3DJS(o3djs_files, Execute([
_java_exe,
'-jar',
- MakePath('../../o3d-internal/jscomp/JSCompiler_deploy.jar'),
+ MakePath('..', '..', 'o3d-internal', 'jscomp', 'JSCompiler_deploy.jar'),
'--property_renaming', 'OFF',
'--variable_renaming', 'LOCAL',
'--strict',
@@ -294,35 +298,48 @@ def CopyStaticFiles(o3d_docs_ezt_outpath, o3d_docs_html_outpath): 'tab_r.gif',
'tab_b.gif']
for file in files:
- shutil.copyfile(MakePath('jsdoc-toolkit-templates/static/' + file),
+ shutil.copyfile(MakePath('jsdoc-toolkit-templates', 'static', file),
MakePath(os.path.join(o3d_docs_ezt_outpath, file)))
- shutil.copyfile(MakePath('jsdoc-toolkit-templates/static/' + file),
+ shutil.copyfile(MakePath('jsdoc-toolkit-templates', 'static', file),
MakePath(os.path.join(o3d_docs_html_outpath, file)))
-def main():
+def main(argv):
"""Builds the O3D API docs and externs and the o3djs docs."""
global _java_exe
- _java_exe = sys.argv[1]
+ _java_exe = argv[0]
+ global _third_party_dir
+ _third_party_dir = argv[1]
+
+ # Fix up the python path of subprocesses by setting PYTHONPATH.
+ pythonpath = os.pathsep.join([MakePath(_third_party_dir, 'gflags', 'python'),
+ MakePath(_third_party_dir, 'ply')])
+
+ orig_pythonpath = os.environ.get('PYTHONPATH')
+ if orig_pythonpath:
+ pythonpath = os.pathsep.join([pythonpath, orig_pythonpath])
+
+ os.environ['PYTHONPATH'] = pythonpath
- js_list_filename = MakePath('../samples/o3djs/js_list.scons')
- idl_list_filename = MakePath('../plugin/idl_list.scons')
+ js_list_filename = MakePath('..', 'samples', 'o3djs', 'js_list.scons')
+ idl_list_filename = MakePath('..', 'plugin', 'idl_list.scons')
js_list_basepath = os.path.dirname(js_list_filename)
idl_list_basepath = os.path.dirname(idl_list_filename)
- outpath = '../scons-out/docs/obj/'
- docs_outpath = '../scons-out/docs/obj/documentation/'
- docs_js_outpath = MakePath(docs_outpath + 'apijs')
- externs_js_outpath = MakePath(outpath + '/externs')
- o3d_docs_ezt_outpath = MakePath(docs_outpath + 'reference')
- o3d_docs_html_outpath = MakePath(docs_outpath + 'local_html')
- o3djs_docs_ezt_outpath = MakePath(docs_outpath + 'reference/jsdocs')
- o3djs_docs_html_outpath = MakePath(docs_outpath + 'local_html/jsdocs')
- o3d_externs_path = MakePath(outpath + 'o3d-externs.js')
- o3djs_exports_path = MakePath(outpath + 'o3d-exports.js')
- compiled_o3djs_outpath = MakePath(docs_outpath + 'base.js')
- externs_path = MakePath('externs/externs.js')
- o3d_extra_externs_path = MakePath('externs/o3d-extra-externs.js')
+ global _output_dir
+ _output_dir = argv[2]
+ docs_outpath = os.path.join(_output_dir, 'documentation')
+ docs_js_outpath = MakePath(docs_outpath, 'apijs')
+ externs_js_outpath = MakePath(_output_dir, 'externs')
+ o3d_docs_ezt_outpath = MakePath(docs_outpath, 'reference')
+ o3d_docs_html_outpath = MakePath(docs_outpath, 'local_html')
+ o3djs_docs_ezt_outpath = MakePath(docs_outpath, 'reference', 'jsdocs')
+ o3djs_docs_html_outpath = MakePath(docs_outpath, 'local_html', 'jsdocs')
+ o3d_externs_path = MakePath(_output_dir, 'o3d-externs.js')
+ o3djs_exports_path = MakePath(_output_dir, 'o3d-exports.js')
+ compiled_o3djs_outpath = MakePath(docs_outpath, 'base.js')
+ externs_path = MakePath('externs', 'externs.js')
+ o3d_extra_externs_path = MakePath('externs', 'o3d-extra-externs.js')
Import(js_list_filename)
Import(idl_list_filename)
@@ -358,4 +375,4 @@ def main(): if __name__ == '__main__':
- main()
+ main(sys.argv[1:])
diff --git a/o3d/documentation/get_docs_files.py b/o3d/documentation/get_docs_files.py new file mode 100644 index 0000000..f4bc31d --- /dev/null +++ b/o3d/documentation/get_docs_files.py @@ -0,0 +1,114 @@ +#!/usr/bin/env python
+# Copyright (c) 2009 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Helper script to generate file lists for documentation.gyp."""
+
+import os
+import sys
+import types
+
+
+GlobalsDict = { }
+
+
+def UpdateGlobals(dict):
+ """Copies pairs from dict into GlobalDict."""
+ for i, v in dict.items():
+ GlobalsDict.__setitem__(i, v)
+
+
+def AppendBasePath(folder, filenames):
+ """Appends a base path to a ist of files"""
+ return [os.path.join(folder, filename) for filename in filenames]
+
+
+def GetCallingNamespaces():
+ """Return the locals and globals for the function that called
+ into this module in the current call stack."""
+ try: 1/0
+ except ZeroDivisionError:
+ # Don't start iterating with the current stack-frame to
+ # prevent creating reference cycles (f_back is safe).
+ frame = sys.exc_info()[2].tb_frame.f_back
+
+ # Find the first frame that *isn't* from this file
+ while frame.f_globals.get("__name__") == __name__:
+ frame = frame.f_back
+
+ return frame.f_locals, frame.f_globals
+
+
+def ComputeExports(exports):
+ """Compute a dictionary of exports given one of the parameters
+ to the Export() function or the exports argument to SConscript()."""
+
+ loc, glob = GetCallingNamespaces()
+
+ retval = {}
+ try:
+ for export in exports:
+ if isinstance(export, types.DictType):
+ retval.update(export)
+ else:
+ try:
+ retval[export] = loc[export]
+ except KeyError:
+ retval[export] = glob[export]
+ except KeyError, x:
+ raise Error, "Export of non-existent variable '%s'"%x
+
+ return retval
+
+
+def Export(*vars):
+ """Copies the named variables to GlobalDict."""
+ for var in vars:
+ UpdateGlobals(ComputeExports(vars))
+
+
+def Import(filename):
+ """Imports a python file in a scope with 'Export' defined."""
+ scope = {'__builtins__': globals()['__builtins__'],
+ 'Export': Export}
+ file = open(filename, 'r')
+ exec file in scope
+ file.close()
+
+
+def GetIdlFiles():
+ idl_list_filename = os.path.join('..', 'plugin', 'idl_list.scons')
+ idl_list_basepath = os.path.dirname(idl_list_filename)
+ Import(idl_list_filename)
+ idl_files = AppendBasePath(idl_list_basepath, GlobalsDict['O3D_IDL_SOURCES'])
+ return idl_files
+
+
+def GetJsFiles():
+ js_list_filename = os.path.join('..', 'samples', 'o3djs', 'js_list.scons')
+ js_list_basepath = os.path.dirname(js_list_filename)
+ Import(js_list_filename)
+ o3djs_files = AppendBasePath(js_list_basepath, GlobalsDict['O3D_JS_SOURCES'])
+ return o3djs_files
+
+
+# Read in the scons files (which are just really simple python files),
+# and scrape out the file lists.
+# TODO(gspencer): Once we no longer use the scons build, rework this
+# so that the lists are just python lists so we can just do a simple
+# eval instead of having to emulate scons import.
+def main(argv):
+ files = []
+ if argv[0] == '--js':
+ files = GetJsFiles()
+ if argv[0] == '--idl':
+ files = GetIdlFiles()
+ files.sort()
+ for file in files:
+ # gyp wants paths with slashes, not backslashes.
+ print file.replace("\\", "/")
+
+
+if __name__ == "__main__":
+ main(sys.argv[1:])
|