diff --git a/.gitignore b/.gitignore index a691d821e3..24c0e4318d 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ /build/ol.js /build/ol-all.js /build/src +/build/phantomjs-*-windows +/build/phantomjs-*-windows.zip /examples/*.json /examples/*.combined.js /examples/example-list.js diff --git a/build.cmd b/build.cmd new file mode 100755 index 0000000000..75c1454306 --- /dev/null +++ b/build.cmd @@ -0,0 +1,2 @@ +@echo off +%SystemDrive%\Python27\python.exe build.py %* diff --git a/build.py b/build.py index 8a9795ee90..f8ffbb7eb5 100755 --- a/build.py +++ b/build.py @@ -1,10 +1,10 @@ #!/usr/bin/env python from cStringIO import StringIO -import glob import gzip import json import os +import os.path import re import shutil import sys @@ -13,19 +13,23 @@ from pake import Target, ifind, main, output, rule, target, variables, virtual if sys.platform == 'win32': - variables.GIT = 'C:/Program Files/Git/bin/git.exe' - variables.GJSLINT = 'gjslint' # FIXME - variables.JAVA = 'C:/Program Files/Java/jre7/bin/java.exe' + ProgramFiles = os.environ.get('ProgramFiles', 'C:\\Program Files') + ProgramFiles_X86 = os.environ.get('ProgramFiles(X86)', 'C:\\Program Files') + Python27 = os.environ.get('SystemDrive', 'C:') + '\\Python27' + variables.GIT = os.path.join(ProgramFiles_X86, 'Git', 'bin', 'git.exe') + variables.GJSLINT = os.path.join(Python27, 'Scripts', 'gjslint.exe') + variables.JAVA = os.path.join(ProgramFiles, 'Java', 'jre7', 'bin', 'java.exe') variables.JSDOC = 'jsdoc' # FIXME - variables.PHANTOMJS = 'phantomjs' # FIXME - variables.PYTHON = 'C:/Python27/python.exe' + variables.PYTHON = os.path.join(Python27, 'python.exe') + PHANTOMJS_WINDOWS_ZIP = 'build/phantomjs-1.8.1-windows.zip' + PHANTOMJS = 'build/phantomjs-1.8.1-windows/phantomjs.exe' else: variables.GIT = 'git' variables.GJSLINT = 'gjslint' variables.JAVA = 'java' variables.JSDOC = 'jsdoc' - variables.PHANTOMJS = 'phantomjs' variables.PYTHON = 'python' + PHANTOMJS = 'phantomjs' variables.BRANCH = output('%(GIT)s', 'rev-parse', '--abbrev-ref', 'HEAD').strip() @@ -40,9 +44,14 @@ EXTERNAL_SRC = [ 'build/src/external/src/types.js'] EXAMPLES = [path - for path in glob.glob('examples/*.html') + for path in ifind('examples') + if not path.startswith('examples/standalone/') + if path.endswith('.html') if path != 'examples/example-list.html'] +EXAMPLES_JSON = [example.replace('.html', '.json') + for example in EXAMPLES] + EXAMPLES_SRC = [path for path in ifind('examples') if path.endswith('.js') @@ -193,7 +202,7 @@ def examples_star_combined_js(name, match): @target('serve', PLOVR_JAR, INTERNAL_SRC, 'test/requireall.js', 'examples') def serve(t): - t.run('%(JAVA)s', '-jar', PLOVR_JAR, 'serve', glob.glob('build/*.json'), glob.glob('examples/*.json'), glob.glob('test/*.json')) + t.run('%(JAVA)s', '-jar', PLOVR_JAR, 'serve', 'build/ol.json', 'build/ol-all.json', EXAMPLES_JSON, 'test/test.json') @target('serve-precommit', PLOVR_JAR, INTERNAL_SRC) @@ -326,9 +335,23 @@ def hostexamples(t): t.cp('examples/example-list.js', 'examples/example-list.xml', 'examples/Jugl.js', 'build/gh-pages/%(BRANCH)s/examples/') -@target('test', INTERNAL_SRC, 'test/requireall.js', phony=True) +@target('test', PHANTOMJS, INTERNAL_SRC, 'test/requireall.js', phony=True) def test(t): - t.run('%(PHANTOMJS)s', 'test/phantom-jasmine/run_jasmine_test.coffee', 'test/ol.html') + t.run(PHANTOMJS, 'test/phantom-jasmine/run_jasmine_test.coffee', 'test/ol.html') + + +if sys.platform == 'win32': + @target(PHANTOMJS, PHANTOMJS_WINDOWS_ZIP, clean=False) + def phantom_js(t): + from zipfile import ZipFile + ZipFile(PHANTOMJS_WINDOWS_ZIP).extractall('build') + + @target(PHANTOMJS_WINDOWS_ZIP, clean=False) + def phantomjs_windows_zip(t): + t.download('http://phantomjs.googlecode.com/files/' + os.path.basename(t.name)) + +else: + virtual(PHANTOMJS) @target('fixme', phony=True) diff --git a/pake.py b/pake.py index dec8b71a7a..27b3648580 100644 --- a/pake.py +++ b/pake.py @@ -288,7 +288,10 @@ def ifind(*paths): for path in paths: for dirpath, dirnames, names in os.walk(path): for name in names: - yield os.path.join(dirpath, name) + if sys.platform == 'win32': + yield '/'.join(dirpath.split('\\') + [name]) + else: + yield os.path.join(dirpath, name) def main(argv=sys.argv): diff --git a/readme.md b/readme.md index 62b9f9ed5e..723a41881d 100644 --- a/readme.md +++ b/readme.md @@ -13,12 +13,16 @@ Run build.py: $ ./build.py +Windows users should run `build` instead. + ## Run examples locally Run the [Plovr](http://plovr.com/) web server with: $ ./build.py serve +Windows users should run `build serve` instead. + Then, either open one of the example html files from the `examples` directory directly in your browser, or start a simple webserver, for example: $ python -mSimpleHTTPServer