Skip to content

Commit cfc7b91

Browse files
author
Adam Cozzette
committed
Sync from Piper @392076391
PROTOBUF_SYNC_PIPER
2 parents 6c09dde + 4ca777e commit cfc7b91

7 files changed

Lines changed: 57 additions & 49 deletions

File tree

commonjs/export.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
* the google-protobuf.js file that we build at distribution time.
66
*/
77

8-
// Include a dummy provide statement so that closurebuilder.py does not skip over this
9-
// file.
108
goog.provide('jspb.Export');
119

1210
goog.require('goog.object');

commonjs/export_asserts.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
* closure_asserts_commonjs.js that is only used at testing time.
77
*/
88

9-
// Include a dummy provide statement so that closurebuilder.py does not skip over this
10-
// file.
119
goog.provide('jspb.ExportAsserts');
1210

1311
goog.require('goog.testing.asserts');

commonjs/export_testdeps.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
* export_asserts.js.
88
*/
99

10-
// Include a dummy provide statement so that closurebuilder.py does not skip over this
11-
// file.
1210
goog.provide('jspb.ExportTestDeps');
1311

1412
goog.require('goog.crypt.base64');

compatibility_tests/v3.0.0/test.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,20 @@ for file in *_test.js binary/*_test.js; do
5353
done
5454
cp commonjs/{jasmine.json,import_test.js} commonjs_out/
5555
mkdir -p commonjs_out/test_node_modules
56-
../../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
57-
../../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
56+
../../node_modules/.bin/google-closure-compiler \
57+
--entry_point=commonjs/export_asserts.js \
58+
--js=commonjs/export_asserts.js \
59+
--js=../../node_modules/google-closure-library/closure/goog/**.js \
60+
--js=../../node_modules/google-closure-library/third_party/closure/goog/**.js \
61+
> commonjs_out/test_node_modules/closure_asserts_commonjs.js
62+
../../node_modules/.bin/google-closure-compiler \
63+
--entry_point=commonjs/export_testdeps.js \
64+
--js=commonjs/export_testdeps.js \
65+
--js=../../binary/*.js \
66+
--js=!../../binary/*_test.js \
67+
--js=../../node_modules/google-closure-library/closure/goog/**.js \
68+
--js=../../node_modules/google-closure-library/third_party/closure/goog/**.js \
69+
> commonjs_out/test_node_modules/testdeps_commonjs.js
5870
cp ../../google-protobuf.js commonjs_out/test_node_modules
5971
cp -r ../../commonjs_out/node_modules commonjs_out
6072

gulpfile.js

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -140,50 +140,55 @@ gulp.task('genproto_group3_commonjs_strict', function (cb) {
140140
});
141141

142142

143-
function getClosureBuilderCommand(exportsFile, outputFile) {
144-
return './node_modules/google-closure-library/closure/bin/build/closurebuilder.py ' +
145-
'--root node_modules ' +
146-
'-o compiled ' +
147-
'--compiler_jar node_modules/google-closure-compiler-java/compiler.jar ' +
148-
'-i ' + exportsFile + ' ' +
149-
'map.js message.js binary/arith.js binary/constants.js binary/decoder.js ' +
150-
'binary/encoder.js binary/reader.js binary/utils.js binary/writer.js ' +
151-
exportsFile + ' > ' + outputFile;
143+
function getClosureCompilerCommand(exportsFile, outputFile) {
144+
const closureLib = 'node_modules/google-closure-library';
145+
return [
146+
'node_modules/.bin/google-closure-compiler',
147+
`--js=${closureLib}/closure/goog/**.js`,
148+
`--js=${closureLib}/third_party/closure/goog/**.js`, '--js=map.js',
149+
'--js=message.js', '--js=binary/arith.js', '--js=binary/constants.js',
150+
'--js=binary/decoder.js', '--js=binary/encoder.js', '--js=binary/reader.js',
151+
'--js=binary/utils.js', '--js=binary/writer.js', `--js=${exportsFile}`,
152+
`--entry_point=${exportsFile}`, `> ${outputFile}`
153+
].join(' ');
152154
}
153155

154156
gulp.task('dist', gulp.series(['genproto_wellknowntypes'], function(cb) {
155157
// TODO(haberman): minify this more aggressively.
156158
// Will require proper externs/exports.
157-
exec(getClosureBuilderCommand('commonjs/export.js', 'google-protobuf.js'),
158-
function (err, stdout, stderr) {
159-
console.log(stdout);
160-
console.log(stderr);
161-
cb(err);
162-
});
159+
exec(
160+
getClosureCompilerCommand('commonjs/export.js', 'google-protobuf.js'),
161+
function(err, stdout, stderr) {
162+
console.log(stdout);
163+
console.log(stderr);
164+
cb(err);
165+
});
163166
}));
164167

165-
gulp.task('commonjs_asserts', function (cb) {
166-
exec('mkdir -p commonjs_out/test_node_modules && ' +
167-
getClosureBuilderCommand(
168-
'commonjs/export_asserts.js',
169-
'commonjs_out/test_node_modules/closure_asserts_commonjs.js'),
170-
function (err, stdout, stderr) {
171-
console.log(stdout);
172-
console.log(stderr);
173-
cb(err);
174-
});
168+
gulp.task('commonjs_asserts', function(cb) {
169+
exec(
170+
'mkdir -p commonjs_out/test_node_modules && ' +
171+
getClosureCompilerCommand(
172+
'commonjs/export_asserts.js',
173+
'commonjs_out/test_node_modules/closure_asserts_commonjs.js'),
174+
function(err, stdout, stderr) {
175+
console.log(stdout);
176+
console.log(stderr);
177+
cb(err);
178+
});
175179
});
176180

177-
gulp.task('commonjs_testdeps', function (cb) {
178-
exec('mkdir -p commonjs_out/test_node_modules && ' +
179-
getClosureBuilderCommand(
180-
'commonjs/export_testdeps.js',
181-
'commonjs_out/test_node_modules/testdeps_commonjs.js'),
182-
function (err, stdout, stderr) {
183-
console.log(stdout);
184-
console.log(stderr);
185-
cb(err);
186-
});
181+
gulp.task('commonjs_testdeps', function(cb) {
182+
exec(
183+
'mkdir -p commonjs_out/test_node_modules && ' +
184+
getClosureCompilerCommand(
185+
'commonjs/export_testdeps.js',
186+
'commonjs_out/test_node_modules/testdeps_commonjs.js'),
187+
function(err, stdout, stderr) {
188+
console.log(stdout);
189+
console.log(stderr);
190+
cb(err);
191+
});
187192
});
188193

189194
gulp.task(
@@ -229,7 +234,7 @@ gulp.task(
229234
],
230235
function(cb) {
231236
exec(
232-
'./node_modules/google-closure-library/closure/bin/build/depswriter.py binary/arith.js binary/constants.js binary/decoder.js binary/encoder.js binary/reader.js binary/utils.js binary/writer.js debug.js map.js message.js node_loader.js test_bootstrap.js > deps.js',
237+
'./node_modules/.bin/closure-make-deps --closure-path=. --file=node_modules/google-closure-library/closure/goog/deps.js binary/arith.js binary/constants.js binary/decoder.js binary/encoder.js binary/reader.js binary/utils.js binary/writer.js debug.js map.js message.js node_loader.js test_bootstrap.js > deps.js',
233238
function(err, stdout, stderr) {
234239
console.log(stdout);
235240
console.log(stderr);

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "google-protobuf",
3-
"version": "3.15.8",
3+
"version": "3.17.3",
44
"description": "Protocol Buffers for JavaScript",
55
"main": "google-protobuf.js",
66
"files": [
@@ -10,6 +10,7 @@
1010
"devDependencies": {
1111
"glob": "~7.1.4",
1212
"google-closure-compiler": "~20190819.0.0",
13+
"google-closure-deps": "^20210406.0.0",
1314
"google-closure-library": "~20190819.0.0",
1415
"gulp": "~4.0.2",
1516
"jasmine": "~3.4.0"

src/google/protobuf/compiler/js/js_generator.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ bool IsReserved(const std::string& ident) {
9494
return false;
9595
}
9696

97-
bool StrEndsWith(StringPiece sp, StringPiece x) {
98-
return sp.size() >= x.size() && sp.substr(sp.size() - x.size()) == x;
99-
}
100-
10197
std::string GetSnakeFilename(const std::string& filename) {
10298
std::string snake_name = filename;
10399
ReplaceCharacters(&snake_name, "/", '_');

0 commit comments

Comments
 (0)