From 28a23a11b53aa3ab95d7846908424c3ea13b5dd2 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Thu, 17 Jul 2014 21:05:43 -0600 Subject: [PATCH 1/4] Remove ol-simple.js build We've proven that we can, but that doesn't mean we should be building with `SIMPLE_OPTIMIZATIONS`. --- CONTRIBUTING.md | 3 -- bin/loader_hosted_examples.js | 6 ++-- build.py | 12 ++----- buildcfg/ol-simple.json | 65 ----------------------------------- 4 files changed, 5 insertions(+), 81 deletions(-) delete mode 100644 buildcfg/ol-simple.json diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d813ba7ea5..710afd82d2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -122,9 +122,6 @@ executing the `host-examples` build target: After running `host-examples` you can now open the examples index page in the browser, for example: . (This assumes that the `hosted` directory is a web directory, served by Apache for example.) -To make an example use `ol-simple.js` or `ol-whitespace.js` instead of `ol.js` -append `?mode=simple` or `?mode=whitespace` to the example URL. - Append `?mode=debug` or `?mode=raw` to make the example work in full debug mode. In full debug mode the OpenLayers and Closure Library scripts are loaded individually by the Closure Library's `base.js` script (which the example page loads and diff --git a/bin/loader_hosted_examples.js b/bin/loader_hosted_examples.js index d5dda87429..dfe727299f 100644 --- a/bin/loader_hosted_examples.js +++ b/bin/loader_hosted_examples.js @@ -5,9 +5,9 @@ * This loader is used for the hosted examples. It is used in place of the * development loader (examples/loader.js). * - * ol.js, ol-simple.js, ol-whitespace.js, and ol-deps.js are built - * by OL3's build.py script. They are located in the ../build/ directory, - * relatively to this script. + * The ol.js, ol-whitespace.js, and ol-deps.js scripts are built by OL3's + * build.py script. They are located in the ../build/ directory, relative to + * this script. * * The script must be named loader.js. * diff --git a/build.py b/build.py index 3aa65c1593..ffd90829b9 100755 --- a/build.py +++ b/build.py @@ -127,8 +127,7 @@ virtual('ci', 'lint', 'jshint', 'build', 'build-all', 'test', 'build/examples/all.combined.js', 'check-examples', 'apidoc') -virtual('build', 'build/ol.css', 'build/ol.js', - 'build/ol-simple.js', 'build/ol-whitespace.js') +virtual('build', 'build/ol.css', 'build/ol.js', 'build/ol-whitespace.js') virtual('check', 'lint', 'jshint', 'build/ol-all.js', 'test') @@ -148,12 +147,6 @@ def build_ol_new_js(t): report_sizes(t) -@target('build/ol-simple.js', SRC, SHADER_SRC, 'buildcfg/ol-simple.json') -def build_ol_simple_js(t): - t.run('node', 'tasks/build.js', 'buildcfg/ol-simple.json', 'build/ol-simple.js') - report_sizes(t) - - @target('build/ol-whitespace.js', SRC, SHADER_SRC, 'buildcfg/ol-whitespace.json') def build_ol_whitespace_js(t): t.run('node', 'tasks/build.js', 'buildcfg/ol-whitespace.json', 'build/ol-whitespace.js') @@ -609,8 +602,7 @@ def host_examples(t): split_example_file(example, examples_dir % vars(variables)) 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-simple.js', 'build/ol-whitespace.js', - build_dir) + t.cp('build/ol.js', 'build/ol-whitespace.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', diff --git a/buildcfg/ol-simple.json b/buildcfg/ol-simple.json deleted file mode 100644 index 0ceab0554c..0000000000 --- a/buildcfg/ol-simple.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "exports": ["*"], - "compile": { - "externs": [ - "externs/bingmaps.js", - "externs/closure-compiler.js", - "externs/geojson.js", - "externs/oli.js", - "externs/olx.js", - "externs/proj4js.js", - "externs/tilejson.js", - "externs/topojson.js", - "externs/vbarray.js" - ], - "define": [ - "goog.dom.ASSUME_STANDARDS_MODE=true", - "goog.DEBUG=false" - ], - "jscomp_error": [ - "accessControls", - "ambiguousFunctionDecl", - "checkEventfulObjectDisposal", - "checkRegExp", - "checkStructDictInheritance", - "checkTypes", - "checkVars", - "const", - "constantProperty", - "deprecated", - "duplicateMessage", - "es3", - "externsValidation", - "fileoverviewTags", - "globalThis", - "internetExplorerChecks", - "invalidCasts", - "misplacedTypeAnnotation", - "missingGetCssName", - "missingProperties", - "missingProvide", - "missingRequire", - "missingReturn", - "newCheckTypes", - "nonStandardJsDocs", - "suspiciousCode", - "strictModuleDepCheck", - "typeInvalidation", - "undefinedNames", - "undefinedVars", - "unknownDefines", - "uselessCode", - "visibility" - ], - "extra_annotation_name": [ - "api", "observable" - ], - "jscomp_off": [ - "es5Strict" - ], - "compilation_level": "SIMPLE", - "output_wrapper": "%output%", - "use_types_for_optimization": false, - "manage_closure_dependencies": true - } -} From 4dc601f30da17a39b35f91768d9f938b2e31075d Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Thu, 17 Jul 2014 21:22:46 -0600 Subject: [PATCH 2/4] Generate a ol-debug.js script useful for debugging Instead of running everything through the Compiler just to remove whitespace, we provide a build that is a simple concatenation of all scripts in dependency order. This build (ol-debug.js) should never be used in production (the same applies to the old ol-whitespace.js build). Instead, the intention is that it be used to aid in debugging during development. --- bin/loader_hosted_examples.js | 2 +- build.py | 10 +++--- buildcfg/ol-debug.json | 3 ++ buildcfg/ol-whitespace.json | 65 ----------------------------------- 4 files changed, 9 insertions(+), 71 deletions(-) create mode 100644 buildcfg/ol-debug.json delete mode 100644 buildcfg/ol-whitespace.json diff --git a/bin/loader_hosted_examples.js b/bin/loader_hosted_examples.js index dfe727299f..96be6e81f4 100644 --- a/bin/loader_hosted_examples.js +++ b/bin/loader_hosted_examples.js @@ -5,7 +5,7 @@ * This loader is used for the hosted examples. It is used in place of the * development loader (examples/loader.js). * - * The ol.js, ol-whitespace.js, and ol-deps.js scripts are built by OL3's + * The ol.js, ol-debug.js, and ol-deps.js scripts are built by OL3's * build.py script. They are located in the ../build/ directory, relative to * this script. * diff --git a/build.py b/build.py index ffd90829b9..4c67b14c3b 100755 --- a/build.py +++ b/build.py @@ -127,7 +127,7 @@ virtual('ci', 'lint', 'jshint', 'build', 'build-all', 'test', 'build/examples/all.combined.js', 'check-examples', 'apidoc') -virtual('build', 'build/ol.css', 'build/ol.js', 'build/ol-whitespace.js') +virtual('build', 'build/ol.css', 'build/ol.js', 'build/ol-debug.js') virtual('check', 'lint', 'jshint', 'build/ol-all.js', 'test') @@ -147,9 +147,9 @@ def build_ol_new_js(t): report_sizes(t) -@target('build/ol-whitespace.js', SRC, SHADER_SRC, 'buildcfg/ol-whitespace.json') -def build_ol_whitespace_js(t): - t.run('node', 'tasks/build.js', 'buildcfg/ol-whitespace.json', 'build/ol-whitespace.js') +@target('build/ol-debug.js', SRC, SHADER_SRC, 'buildcfg/ol-debug.json') +def build_ol_debug_js(t): + t.run('node', 'tasks/build.js', 'buildcfg/ol-debug.json', 'build/ol-debug.js') report_sizes(t) @@ -602,7 +602,7 @@ def host_examples(t): split_example_file(example, examples_dir % vars(variables)) 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-whitespace.js', build_dir) + 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', diff --git a/buildcfg/ol-debug.json b/buildcfg/ol-debug.json new file mode 100644 index 0000000000..b8f37e2ff1 --- /dev/null +++ b/buildcfg/ol-debug.json @@ -0,0 +1,3 @@ +{ + "exports": ["*"] +} diff --git a/buildcfg/ol-whitespace.json b/buildcfg/ol-whitespace.json deleted file mode 100644 index e2a04cf611..0000000000 --- a/buildcfg/ol-whitespace.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "exports": ["*"], - "compile": { - "externs": [ - "externs/bingmaps.js", - "externs/closure-compiler.js", - "externs/geojson.js", - "externs/oli.js", - "externs/olx.js", - "externs/proj4js.js", - "externs/tilejson.js", - "externs/topojson.js", - "externs/vbarray.js" - ], - "define": [ - "goog.dom.ASSUME_STANDARDS_MODE=true", - "goog.DEBUG=false" - ], - "jscomp_error": [ - "accessControls", - "ambiguousFunctionDecl", - "checkEventfulObjectDisposal", - "checkRegExp", - "checkStructDictInheritance", - "checkTypes", - "checkVars", - "const", - "constantProperty", - "deprecated", - "duplicateMessage", - "es3", - "externsValidation", - "fileoverviewTags", - "globalThis", - "internetExplorerChecks", - "invalidCasts", - "misplacedTypeAnnotation", - "missingGetCssName", - "missingProperties", - "missingProvide", - "missingRequire", - "missingReturn", - "newCheckTypes", - "nonStandardJsDocs", - "suspiciousCode", - "strictModuleDepCheck", - "typeInvalidation", - "undefinedNames", - "undefinedVars", - "unknownDefines", - "uselessCode", - "visibility" - ], - "extra_annotation_name": [ - "api", "observable" - ], - "jscomp_off": [ - "es5Strict" - ], - "compilation_level": "WHITESPACE_ONLY", - "output_wrapper": "var CLOSURE_DEPS = false;\n%output%", - "use_types_for_optimization": false, - "manage_closure_dependencies": true - } -} From 737e063937df45276401538c72b803789b47009d Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Thu, 17 Jul 2014 21:42:55 -0600 Subject: [PATCH 3/4] Two ways to run the hosted examples: compiled and raw When viewing the hosted examples, people can load the compiled version of the library or load each script individually. --- CONTRIBUTING.md | 5 +---- bin/loader_hosted_examples.js | 15 +++------------ 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 710afd82d2..79b7cbb952 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -122,10 +122,7 @@ executing the `host-examples` build target: After running `host-examples` you can now open the examples index page in the browser, for example: . (This assumes that the `hosted` directory is a web directory, served by Apache for example.) -Append `?mode=debug` or `?mode=raw` to make the example work in full debug mode. In -full debug mode the OpenLayers and Closure Library scripts are loaded individually by -the Closure Library's `base.js` script (which the example page loads and -executes before any other script). +Append `?mode=raw` to make the example work in full debug mode. In raw mode the OpenLayers and Closure Library scripts are loaded individually by the Closure Library's `base.js` script (which the example page loads and executes before any other script). ## Running tests diff --git a/bin/loader_hosted_examples.js b/bin/loader_hosted_examples.js index 96be6e81f4..46b07bd0c8 100644 --- a/bin/loader_hosted_examples.js +++ b/bin/loader_hosted_examples.js @@ -54,20 +54,11 @@ } } - var oljs = 'ol.js', mode; - if ('mode' in pageParams) { - mode = pageParams.mode.toLowerCase(); - if (mode == 'debug') { - mode = 'raw'; - } - if (mode != 'advanced' && mode != 'raw') { - oljs = 'ol-' + mode + '.js'; - } - } + var raw = pageParams.mode && pageParams.mode.toLowerCase() === 'raw'; var scriptId = encodeURIComponent(scriptParams.id); - if (mode != 'raw') { - document.write(''); + if (!raw) { + document.write(''); } else { window.CLOSURE_NO_DEPS = true; // we've got our own deps file document.write(''); From e9c6e58663772699712ba922f22ae31a922c901a Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Thu, 17 Jul 2014 21:48:53 -0600 Subject: [PATCH 4/4] Removing the build-all target The ol-all.json and ol.json build configurations differ only in their use of the manage_closure_dependencies Compiler option. I don't think there is value in running both (there are plenty of other compiler options that we don't exercise in this same way). --- build.py | 14 +++------- buildcfg/ol-all.json | 64 -------------------------------------------- 2 files changed, 3 insertions(+), 75 deletions(-) delete mode 100644 buildcfg/ol-all.json diff --git a/build.py b/build.py index 4c67b14c3b..ac2e383607 100755 --- a/build.py +++ b/build.py @@ -123,14 +123,14 @@ def report_sizes(t): virtual('default', 'build') -virtual('ci', 'lint', 'jshint', 'build', 'build-all', - 'test', 'build/examples/all.combined.js', 'check-examples', 'apidoc') +virtual('ci', 'lint', 'jshint', 'build', 'test', + 'build/examples/all.combined.js', 'check-examples', 'apidoc') virtual('build', 'build/ol.css', 'build/ol.js', 'build/ol-debug.js') -virtual('check', 'lint', 'jshint', 'build/ol-all.js', 'test') +virtual('check', 'lint', 'jshint', 'test') virtual('todo', 'fixme') @@ -153,14 +153,6 @@ def build_ol_debug_js(t): report_sizes(t) -virtual('build-all', 'build/ol-all.js') - - -@target('build/ol-all.js', SRC, SHADER_SRC, 'buildcfg/ol-all.json') -def build_ol_all_js(t): - t.run('node', 'tasks/build.js', 'buildcfg/ol-all.json', 'build/ol-all.js') - - for glsl_src in GLSL_SRC: def shader_src_helper(glsl_src): @target(glsl_src.replace('.glsl', 'shader.js'), glsl_src, diff --git a/buildcfg/ol-all.json b/buildcfg/ol-all.json deleted file mode 100644 index ed2b98497f..0000000000 --- a/buildcfg/ol-all.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "exports": ["*"], - "compile": { - "externs": [ - "externs/bingmaps.js", - "externs/closure-compiler.js", - "externs/geojson.js", - "externs/oli.js", - "externs/olx.js", - "externs/proj4js.js", - "externs/tilejson.js", - "externs/topojson.js", - "externs/vbarray.js" - ], - "define": [ - "goog.dom.ASSUME_STANDARDS_MODE=true", - "goog.DEBUG=false" - ], - "jscomp_error": [ - "accessControls", - "ambiguousFunctionDecl", - "checkEventfulObjectDisposal", - "checkRegExp", - "checkStructDictInheritance", - "checkTypes", - "checkVars", - "const", - "constantProperty", - "deprecated", - "duplicateMessage", - "es3", - "externsValidation", - "fileoverviewTags", - "globalThis", - "internetExplorerChecks", - "invalidCasts", - "misplacedTypeAnnotation", - "missingGetCssName", - "missingProperties", - "missingProvide", - "missingRequire", - "missingReturn", - "newCheckTypes", - "nonStandardJsDocs", - "suspiciousCode", - "strictModuleDepCheck", - "typeInvalidation", - "undefinedNames", - "undefinedVars", - "unknownDefines", - "uselessCode", - "visibility" - ], - "extra_annotation_name": [ - "api", "observable" - ], - "jscomp_off": [ - "es5Strict" - ], - "compilation_level": "ADVANCED", - "output_wrapper": "// OpenLayers 3. See http://ol3.js.org/\n(function(){%output%})();", - "use_types_for_optimization": true - } -}