OLD | NEW |
1 var gulp = require('gulp'); | 1 var gulp = require('gulp'); |
2 var exec = require('child_process').exec; | 2 var execFile = require('child_process').execFile; |
| 3 var glob = require('glob'); |
3 | 4 |
4 gulp.task('genproto', function (cb) { | 5 function exec(command, cb) { |
5 exec('../src/protoc --js_out=library=testproto_libs,binary:. -I ../src -I . *.
proto ../src/google/protobuf/descriptor.proto', | 6 execFile('sh', ['-c', command], cb); |
| 7 } |
| 8 |
| 9 var protoc = process.env.PROTOC || '../src/protoc'; |
| 10 |
| 11 gulp.task('genproto_closure', function (cb) { |
| 12 exec(protoc + ' --js_out=library=testproto_libs,binary:. -I ../src -I . *.pro
to ../src/google/protobuf/descriptor.proto', |
6 function (err, stdout, stderr) { | 13 function (err, stdout, stderr) { |
7 console.log(stdout); | 14 console.log(stdout); |
8 console.log(stderr); | 15 console.log(stderr); |
9 cb(err); | 16 cb(err); |
10 }); | 17 }); |
11 }) | 18 }); |
12 | 19 |
13 gulp.task('deps', ['genproto'], function (cb) { | 20 gulp.task('genproto_commonjs', function (cb) { |
| 21 exec('mkdir -p commonjs_out && ' + protoc + ' --js_out=import_style=commonjs,b
inary:commonjs_out -I ../src -I commonjs -I . *.proto commonjs/test*/*.proto ../
src/google/protobuf/descriptor.proto', |
| 22 function (err, stdout, stderr) { |
| 23 console.log(stdout); |
| 24 console.log(stderr); |
| 25 cb(err); |
| 26 }); |
| 27 }); |
| 28 |
| 29 gulp.task('dist', function (cb) { |
| 30 // TODO(haberman): minify this more aggressively. |
| 31 // Will require proper externs/exports. |
| 32 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_m
odules/google-closure-library/closure -o compiled --compiler_jar node_modules/go
ogle-closure-compiler/compiler.jar > google-protobuf.js', |
| 33 function (err, stdout, stderr) { |
| 34 console.log(stdout); |
| 35 console.log(stderr); |
| 36 cb(err); |
| 37 }); |
| 38 }); |
| 39 |
| 40 gulp.task('commonjs_asserts', function (cb) { |
| 41 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_modu
les/google-closure-library/closure -o compiled --compiler_jar node_modules/googl
e-closure-compiler/compiler.jar > commonjs_out/test_node_modules/closure_asserts
_commonjs.js', |
| 42 function (err, stdout, stderr) { |
| 43 console.log(stdout); |
| 44 console.log(stderr); |
| 45 cb(err); |
| 46 }); |
| 47 }); |
| 48 |
| 49 gulp.task('commonjs_testdeps', function (cb) { |
| 50 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_mod
ules/google-closure-library/closure -o compiled --compiler_jar node_modules/goog
le-closure-compiler/compiler.jar > commonjs_out/test_node_modules/testdeps_commo
njs.js', |
| 51 function (err, stdout, stderr) { |
| 52 console.log(stdout); |
| 53 console.log(stderr); |
| 54 cb(err); |
| 55 }); |
| 56 }); |
| 57 |
| 58 gulp.task('make_commonjs_out', ['dist', 'genproto_commonjs', 'commonjs_asserts',
'commonjs_testdeps'], function (cb) { |
| 59 // TODO(haberman): minify this more aggressively. |
| 60 // Will require proper externs/exports. |
| 61 var cmd = "mkdir -p commonjs_out/binary && mkdir -p commonjs_out/test_node_mod
ules && "; |
| 62 function addTestFile(file) { |
| 63 cmd += 'node commonjs/rewrite_tests_for_commonjs.js < ' + file + |
| 64 ' > commonjs_out/' + file + '&& '; |
| 65 } |
| 66 |
| 67 glob.sync('*_test.js').forEach(addTestFile); |
| 68 glob.sync('binary/*_test.js').forEach(addTestFile); |
| 69 |
| 70 exec(cmd + |
| 71 'cp commonjs/jasmine.json commonjs_out/jasmine.json && ' + |
| 72 'cp google-protobuf.js commonjs_out/test_node_modules && ' + |
| 73 'cp commonjs/import_test.js commonjs_out/import_test.js', |
| 74 function (err, stdout, stderr) { |
| 75 console.log(stdout); |
| 76 console.log(stderr); |
| 77 cb(err); |
| 78 }); |
| 79 }); |
| 80 |
| 81 gulp.task('deps', ['genproto_closure'], function (cb) { |
14 exec('./node_modules/google-closure-library/closure/bin/build/depswriter.py *.
js binary/*.js > deps.js', | 82 exec('./node_modules/google-closure-library/closure/bin/build/depswriter.py *.
js binary/*.js > deps.js', |
15 function (err, stdout, stderr) { | 83 function (err, stdout, stderr) { |
16 console.log(stdout); | 84 console.log(stdout); |
17 console.log(stderr); | 85 console.log(stderr); |
18 cb(err); | 86 cb(err); |
19 }); | 87 }); |
20 }) | 88 }); |
21 | 89 |
22 gulp.task('test', ['genproto', 'deps'], function (cb) { | 90 gulp.task('test_closure', ['genproto_closure', 'deps'], function (cb) { |
23 exec('JASMINE_CONFIG_PATH=jasmine.json ./node_modules/.bin/jasmine', | 91 exec('JASMINE_CONFIG_PATH=jasmine.json ./node_modules/.bin/jasmine', |
24 function (err, stdout, stderr) { | 92 function (err, stdout, stderr) { |
25 console.log(stdout); | 93 console.log(stdout); |
26 console.log(stderr); | 94 console.log(stderr); |
27 cb(err); | 95 cb(err); |
28 }); | 96 }); |
29 }); | 97 }); |
| 98 |
| 99 gulp.task('test_commonjs', ['make_commonjs_out'], function (cb) { |
| 100 exec('cd commonjs_out && JASMINE_CONFIG_PATH=jasmine.json NODE_PATH=test_node_
modules ../node_modules/.bin/jasmine', |
| 101 function (err, stdout, stderr) { |
| 102 console.log(stdout); |
| 103 console.log(stderr); |
| 104 cb(err); |
| 105 }); |
| 106 }); |
| 107 |
| 108 gulp.task('test', ['test_closure', 'test_commonjs'], function(cb) { |
| 109 cb(); |
| 110 }); |
OLD | NEW |