Skip to content

Commit cb4ff74

Browse files
author
Tim Blasi
committed
chore(dart/transform): Integrate protoc into gulp build
This change detects if the user has `protoc` available and, if so, uses it to generate `.pb.dart` files. If not, pre-built files are used instead.
1 parent 5298eb0 commit cb4ff74

16 files changed

+5365
-2
lines changed

gulpfile.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ var licenseWrap = require('./tools/build/licensewrap');
2121
var watch = require('./tools/build/watch');
2222

2323
var pubget = require('./tools/build/pubget');
24+
var proto = require('./tools/build/proto');
2425
var linknodemodules = require('./tools/build/linknodemodules');
2526
var pubbuild = require('./tools/build/pubbuild');
2627
var dartanalyzer = require('./tools/build/dartanalyzer');
@@ -830,7 +831,7 @@ gulp.task('build/pure-packages.dart', function() {
830831
var transformStream = gulp
831832
.src([
832833
'modules_dart/transform/**/*',
833-
'!modules_dart/transform/pubspec.yaml'
834+
'!modules_dart/transform/**/*.proto'
834835
])
835836
.pipe(gulp.dest(path.join(CONFIG.dest.dart, 'angular2')));
836837

@@ -882,6 +883,7 @@ gulp.task('build/pure-packages.dart', function() {
882883
// Builds all Dart packages, but does not compile them
883884
gulp.task('build/packages.dart', function(done) {
884885
runSequence(
886+
'lint_protos.dart',
885887
'build/tree.dart',
886888
'build/pure-packages.dart',
887889
// Run after 'build/tree.dart' because broccoli clears the dist/dart folder
@@ -1206,9 +1208,21 @@ gulp.task('clean', ['build/clean.tools', 'build/clean.js', 'build/clean.dart', '
12061208
gulp.task('build', ['build.js', 'build.dart']);
12071209

12081210
// ------------
1209-
// change detection codegen
1211+
// transform codegen
1212+
gulp.task('lint_protos.dart', function(done) {
1213+
return proto.lint({
1214+
dir: 'modules_dart/transform/lib/src/transform/common/model/'
1215+
}, done);
1216+
});
12101217

1218+
gulp.task('gen_protos.dart', function(done) {
1219+
return proto.generate({
1220+
dir: 'modules_dart/transform/lib/src/transform/common/model/',
1221+
plugin: 'tools/build/protoc-gen-dart'
1222+
}, done);
1223+
});
12111224

1225+
// change detection codegen
12121226
gulp.task('build.change_detect.dart', function(done) {
12131227
return runSequence('build/packages.dart', '!build/pubget.angular2.dart',
12141228
'!build/change_detect.dart', done);

modules/angular2/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ dependencies:
1818
intl: '^0.12.4'
1919
logging: '>=0.9.0 <0.12.0'
2020
observe: '^0.13.1'
21+
protobuf: '^0.4.2'
2122
quiver: '^0.21.4'
2223
source_span: '^1.0.0'
2324
stack_trace: '^1.1.1'

modules_dart/transform/lib/src/transform/common/model/annotation_model.pb.dart

Lines changed: 128 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
syntax = "proto2";
2+
3+
package angular2.src.transform.common.model.proto;
4+
5+
message NamedParameter {
6+
required string name = 1;
7+
required string value = 2;
8+
}
9+
10+
message AnnotationModel {
11+
// The constructor that creates the annotation, or the name of the field that
12+
// defines the annotation.
13+
required string name = 1;
14+
15+
// The positional parameters provided to the annotation.
16+
repeated string parameters = 2;
17+
18+
// The named parameters provided to the annotation.
19+
repeated NamedParameter named_parameters = 3;
20+
21+
// Whether this is a `View` annotation.
22+
optional bool is_view = 4;
23+
24+
// Whether this is a `Directive` annotation. This takes inheritance into
25+
// account, that is, this should be true if `is_component` is true.
26+
optional bool is_directive = 5;
27+
28+
// Whether htis is a `Component` annotation.
29+
optional bool is_component = 6;
30+
31+
// Whether this is an `Injectable` annotation. This takes inheritance into
32+
// account, that is, this should be true if `is_directive` and/or
33+
// `is_component` is true.
34+
optional bool is_injectable = 7;
35+
}

modules_dart/transform/lib/src/transform/common/model/import_export_model.pb.dart

Lines changed: 115 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
syntax = "proto2";
2+
3+
package angular2.src.transform.common.model.proto;
4+
5+
// Note that the fields that are common between `ImportModel` and `ExportModel`
6+
// are stored at the same indexes, which allows them to be semi-wire-compatible
7+
// with one another. This will hopefully not be necessary to exploit, but on the
8+
// chance that it is it's easier to define this now.
9+
message ImportModel {
10+
required string uri = 1;
11+
12+
repeated string show_combinators = 2;
13+
14+
repeated string hide_combinators = 3;
15+
16+
optional string prefix = 4;
17+
18+
optional bool is_deferred = 5;
19+
}
20+
21+
// See message above about wire-compatiblity with `ImportModel`.
22+
message ExportModel {
23+
required string uri = 1;
24+
25+
repeated string show_combinators = 2;
26+
27+
repeated string hide_combinators = 3;
28+
}

0 commit comments

Comments
 (0)