diff options
author | Adam Cozzette <acozzette@google.com> | 2017-02-23 11:32:16 -0800 |
---|---|---|
committer | Adam Cozzette <acozzette@google.com> | 2017-03-01 07:43:11 -0800 |
commit | 671e075c5e642627ccbd03cf71226d8d5f2ec897 (patch) | |
tree | 1ed30b82de5a9e5dcb3d852b47d5f6d75486a261 /js/gulpfile.js | |
parent | 7339fc04c49a055ec0688cd0cb24cf7ea64f7783 (diff) | |
download | protobuf-671e075c5e642627ccbd03cf71226d8d5f2ec897.tar.gz protobuf-671e075c5e642627ccbd03cf71226d8d5f2ec897.tar.bz2 protobuf-671e075c5e642627ccbd03cf71226d8d5f2ec897.zip |
Use closurebuilder.py in favor of calcdeps.py for compiling JavaScript
There are two motivations for this:
1) calcdeps.py is deprecated and replaced by closurebuilder.py.
2) As part of this I was able to tweak things so that the Closure
compiler does not attempt to examine every .js file in the tree under
js/. This makes it possible to put compatibility tests and related files
in a subdirectory without them getting mixed up with the main .js files
we care about.
Diffstat (limited to 'js/gulpfile.js')
-rw-r--r-- | js/gulpfile.js | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/js/gulpfile.js b/js/gulpfile.js index 5f1b1d93..16c302ed 100644 --- a/js/gulpfile.js +++ b/js/gulpfile.js @@ -59,10 +59,21 @@ gulp.task('genproto_wellknowntypes', function (cb) { }); }); +function getClosureBuilderCommand(exportsFile, outputFile) { + return './node_modules/google-closure-library/closure/bin/build/closurebuilder.py ' + + '--root node_modules ' + + '-o compiled ' + + '--compiler_jar node_modules/google-closure-compiler/compiler.jar ' + + '-i ' + exportsFile + ' ' + + 'map.js message.js binary/arith.js binary/constants.js binary/decoder.js ' + + 'binary/encoder.js binary/reader.js binary/utils.js binary/writer.js ' + + exportsFile + ' > ' + outputFile; +} + gulp.task('dist', ['genproto_wellknowntypes'], function (cb) { // TODO(haberman): minify this more aggressively. // Will require proper externs/exports. - exec('./node_modules/google-closure-library/closure/bin/calcdeps.py -i message.js -i binary/reader.js -i binary/writer.js -i commonjs/export.js -p . -p node_modules/google-closure-library/closure -o compiled --compiler_jar node_modules/google-closure-compiler/compiler.jar > google-protobuf.js', + exec(getClosureBuilderCommand('commonjs/export.js', 'google-protobuf.js'), function (err, stdout, stderr) { console.log(stdout); console.log(stderr); @@ -71,7 +82,10 @@ gulp.task('dist', ['genproto_wellknowntypes'], function (cb) { }); gulp.task('commonjs_asserts', function (cb) { - exec('mkdir -p commonjs_out/test_node_modules && ./node_modules/google-closure-library/closure/bin/calcdeps.py -i commonjs/export_asserts.js -p . -p node_modules/google-closure-library/closure -o compiled --compiler_jar node_modules/google-closure-compiler/compiler.jar > commonjs_out/test_node_modules/closure_asserts_commonjs.js', + exec('mkdir -p commonjs_out/test_node_modules && ' + + getClosureBuilderCommand( + 'commonjs/export_asserts.js', + 'commonjs_out/test_node_modules/closure_asserts_commonjs.js'), function (err, stdout, stderr) { console.log(stdout); console.log(stderr); @@ -80,7 +94,10 @@ gulp.task('commonjs_asserts', function (cb) { }); gulp.task('commonjs_testdeps', function (cb) { - exec('mkdir -p commonjs_out/test_node_modules && ./node_modules/google-closure-library/closure/bin/calcdeps.py -i commonjs/export_testdeps.js -p . -p node_modules/google-closure-library/closure -o compiled --compiler_jar node_modules/google-closure-compiler/compiler.jar > commonjs_out/test_node_modules/testdeps_commonjs.js', + exec('mkdir -p commonjs_out/test_node_modules && ' + + getClosureBuilderCommand( + 'commonjs/export_testdeps.js', + 'commonjs_out/test_node_modules/testdeps_commonjs.js'), function (err, stdout, stderr) { console.log(stdout); console.log(stderr); |