Make build.py call tasks/build-examples.js

This commit is contained in:
Tim Schaub
2015-04-12 15:48:46 -06:00
parent 8ddec98075
commit a85de86ec2
4 changed files with 32 additions and 2079 deletions
+32 -40
View File
@@ -112,23 +112,24 @@ EXECUTABLES = [variables.CLEANCSS, variables.GIT, variables.GJSLINT,
variables.JSDOC, variables.JSHINT, variables.PYTHON,
variables.PHANTOMJS]
EXAMPLES = [path
for path in ifind('examples')
if path.endswith('.html')
if path != 'examples/index.html']
EXAMPLES_SRC_ALL = [path for path in ifind('examples_src')]
EXAMPLES_SRC = [path
for path in ifind('examples')
if path.endswith('.js')
if not path.endswith('.combined.js')
if path != 'examples/Jugl.js'
if path != 'examples/example-list.js']
EXAMPLES_SRC_HTML = [path
for path in EXAMPLES_SRC_ALL
if path.endswith('.html')
if path != 'examples_src/index.html']
EXAMPLES_SRC_JS = [example.replace('.html', '.js')
for example in EXAMPLES_SRC_HTML]
EXAMPLES_DEST_ALL = [path.replace('examples_src', 'examples')
for path in EXAMPLES_SRC_ALL]
EXAMPLES_JSON = ['build/' + example.replace('.html', '.json')
for example in EXAMPLES]
for example in EXAMPLES_SRC_HTML]
EXAMPLES_COMBINED = ['build/' + example.replace('.html', '.combined.js')
for example in EXAMPLES]
for example in EXAMPLES_SRC_HTML]
GLSL_SRC = [path
for path in ifind('src')
@@ -261,17 +262,15 @@ virtual('build-examples', 'examples', 'build/examples/all.combined.js',
EXAMPLES_COMBINED)
virtual('examples', 'examples/example-list.xml', EXAMPLES_JSON)
virtual('examples', EXAMPLES_DEST_ALL)
@target('examples/example-list.xml', 'examples/example-list.js')
def examples_examples_list_xml(t):
t.touch() # already generated by bin/exampleparser.py
@target('examples/example-list.js', 'bin/exampleparser.py', EXAMPLES)
def examples_examples_list_js(t):
t.run('%(PYTHON)s', 'bin/exampleparser.py', 'examples', 'examples')
@rule(r'\Aexamples/(?P<filepath>.*)\Z')
def examples_dest(name, match):
def action(t):
t.run('node', 'tasks/build-examples.js')
dependencies = ['examples_src/%(filepath)s' % match.groupdict()]
return Target(name, action=action, dependencies=dependencies)
@target('build/examples/all.combined.js', 'build/examples/all.js',
@@ -282,7 +281,7 @@ def build_examples_all_combined_js(t):
report_sizes(t)
@target('build/examples/all.js', EXAMPLES_SRC)
@target('build/examples/all.js', EXAMPLES_SRC_JS)
def build_examples_all_js(t):
t.output('%(PYTHON)s', 'bin/combine-examples.py', t.dependencies)
@@ -405,7 +404,7 @@ def examples_star_combined_js(name, match):
return Target(name, action=action, dependencies=dependencies)
@target('serve', 'examples', 'build/test_requires.js', 'build/test_rendering_requires.js',
@target('serve', 'build/test_requires.js', 'build/test_rendering_requires.js',
NPM_INSTALL)
def serve(t):
t.run('node', 'tasks/serve.js')
@@ -415,7 +414,7 @@ virtual('lint', 'build/lint-timestamp', 'build/check-requires-timestamp',
'build/check-whitespace-timestamp', 'jshint')
@target('build/lint-timestamp', SRC, EXAMPLES_SRC, SPEC, SPEC_RENDERING,
@target('build/lint-timestamp', SRC, EXAMPLES_SRC_JS, SPEC, SPEC_RENDERING,
precious=True)
def build_lint_src_timestamp(t):
t.run('%(GJSLINT)s',
@@ -427,7 +426,7 @@ def build_lint_src_timestamp(t):
virtual('jshint', 'build/jshint-timestamp')
@target('build/jshint-timestamp', SRC, EXAMPLES_SRC, SPEC, SPEC_RENDERING,
@target('build/jshint-timestamp', SRC, EXAMPLES_SRC_JS, SPEC, SPEC_RENDERING,
TASKS, NPM_INSTALL, precious=True)
def build_jshint_timestamp(t):
t.run(variables.JSHINT, '--verbose', t.newer(t.dependencies))
@@ -457,7 +456,7 @@ def _strip_comments(lines):
yield lineno, line
@target('build/check-requires-timestamp', SRC, EXAMPLES_SRC, SHADER_SRC,
@target('build/check-requires-timestamp', SRC, EXAMPLES_SRC_JS, SHADER_SRC,
SPEC, SPEC_RENDERING)
def build_check_requires_timestamp(t):
unused_count = 0
@@ -598,7 +597,7 @@ def build_check_requires_timestamp(t):
t.touch()
@target('build/check-whitespace-timestamp', SRC, EXAMPLES_SRC,
@target('build/check-whitespace-timestamp', SRC, EXAMPLES_SRC_JS,
SPEC, SPEC_RENDERING, JSDOC_SRC, precious=True)
def build_check_whitespace_timestamp(t):
CR_RE = re.compile(r'\r')
@@ -691,23 +690,16 @@ def host_examples(t):
closure_lib_path = output('node', '-e',
'process.stdout.write(require("closure-util").getLibraryPath())')
t.rm_rf(examples_dir)
t.makedirs(examples_dir)
t.cp_r('examples', examples_dir)
for example in EXAMPLES_SRC_JS:
split_example_file(example, examples_dir % vars(variables))
t.cp('bin/loader_hosted_examples.js', examples_dir + '/loader.js')
t.rm_rf(build_dir)
t.makedirs(build_dir)
t.rm_rf(css_dir)
t.makedirs(css_dir)
t.cp(EXAMPLES, examples_dir)
for example in [path.replace('.html', '.js') for path in EXAMPLES]:
split_example_file(example, examples_dir % vars(variables))
for example in [path.replace('.html', '.css') for path in EXAMPLES]:
if os.path.isfile(example):
t.cp(example, examples_dir)
t.cp_r('examples/data', examples_dir + '/data')
t.cp('bin/loader_hosted_examples.js', examples_dir + '/loader.js')
t.cp('build/ol.js', 'build/ol-debug.js', build_dir)
t.cp('build/ol.css', css_dir)
t.cp('examples/index.html', 'examples/example-list.js',
'examples/example-list.xml', 'examples/Jugl.js', examples_dir)
t.rm_rf('build/hosted/%(BRANCH)s/closure-library')
t.cp_r(closure_lib_path, 'build/hosted/%(BRANCH)s/closure-library')
t.rm_rf('build/hosted/%(BRANCH)s/ol')
@@ -726,8 +718,8 @@ def host_examples(t):
@target('check-examples', 'host-examples', phony=True)
def check_examples(t):
examples = ['build/hosted/%(BRANCH)s/' + e
for e in EXAMPLES
examples = ['build/hosted/%(BRANCH)s/' + e.replace('examples_src', 'examples')
for e in EXAMPLES_SRC_HTML
if not open(e.replace('.html', '.js'), 'rU').readline().startswith('// NOCOMPILE')]
all_examples = [e + '?mode=advanced' for e in examples]
# Run the examples checks in a pool of threads