diff options
author | Adam Cozzette <acozzette@gmail.com> | 2017-03-02 08:47:20 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-02 08:47:20 -0800 |
commit | a7e3b0ab016312f7427426d2cb88b0ab77210b79 (patch) | |
tree | 58df4c28a1c3bc9b0516fce52551556e9fc779c6 /js | |
parent | 8b182cc45575117d19f0695cbde80f6e43b722d5 (diff) | |
parent | 671e075c5e642627ccbd03cf71226d8d5f2ec897 (diff) | |
download | protobuf-a7e3b0ab016312f7427426d2cb88b0ab77210b79.tar.gz protobuf-a7e3b0ab016312f7427426d2cb88b0ab77210b79.tar.bz2 protobuf-a7e3b0ab016312f7427426d2cb88b0ab77210b79.zip |
Merge pull request #2774 from acozzette/closure-builder
Use closurebuilder.py in favor of calcdeps.py for compiling JavaScript
Diffstat (limited to 'js')
-rw-r--r-- | js/commonjs/export.js | 4 | ||||
-rw-r--r-- | js/commonjs/export_asserts.js | 4 | ||||
-rw-r--r-- | js/commonjs/export_testdeps.js | 4 | ||||
-rw-r--r-- | js/gulpfile.js | 23 |
4 files changed, 32 insertions, 3 deletions
diff --git a/js/commonjs/export.js b/js/commonjs/export.js index 1eaab5d5..a93ee928 100644 --- a/js/commonjs/export.js +++ b/js/commonjs/export.js @@ -5,6 +5,10 @@ * the google-protobuf.js file that we build at distribution time. */ +// Include a dummy provide statement so that closurebuilder.py does not skip over this +// file. +goog.provide('jspb.Export'); + goog.require('goog.object'); goog.require('jspb.BinaryReader'); goog.require('jspb.BinaryWriter'); diff --git a/js/commonjs/export_asserts.js b/js/commonjs/export_asserts.js index 5219d120..ad9446c7 100644 --- a/js/commonjs/export_asserts.js +++ b/js/commonjs/export_asserts.js @@ -6,6 +6,10 @@ * closure_asserts_commonjs.js that is only used at testing time. */ +// Include a dummy provide statement so that closurebuilder.py does not skip over this +// file. +goog.provide('jspb.ExportAsserts'); + goog.require('goog.testing.asserts'); var global = Function('return this')(); diff --git a/js/commonjs/export_testdeps.js b/js/commonjs/export_testdeps.js index 174c61e6..6f5cd083 100644 --- a/js/commonjs/export_testdeps.js +++ b/js/commonjs/export_testdeps.js @@ -7,6 +7,10 @@ * export_asserts.js. */ +// Include a dummy provide statement so that closurebuilder.py does not skip over this +// file. +goog.provide('jspb.ExportTestDeps'); + goog.require('goog.crypt.base64'); goog.require('jspb.arith.Int64'); goog.require('jspb.arith.UInt64'); 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); |