@@ -16,10 +16,9 @@ module.exports = function(gulp, plugins, config) {
1616 var packageName = pubspec . name ;
1717
1818 var libFiles = [ ] . slice . call ( glob . sync ( 'lib/**/*.dart' , { cwd : dir } ) ) ;
19-
2019 var webFiles = [ ] . slice . call ( glob . sync ( 'web/**/*.dart' , { cwd : dir } ) ) ;
21-
2220 var testFiles = [ ] . slice . call ( glob . sync ( 'test/**/*_spec.dart' , { cwd : dir } ) ) ;
21+
2322 var analyzeFile = [ 'library _analyzer;' ] ;
2423 libFiles . concat ( testFiles ) . concat ( webFiles ) . forEach ( function ( fileName , index ) {
2524 if ( fileName !== tempFile && fileName . indexOf ( "/packages/" ) === - 1 ) {
@@ -31,13 +30,24 @@ module.exports = function(gulp, plugins, config) {
3130 } ) ;
3231 fs . writeFileSync ( path . join ( dir , tempFile ) , analyzeFile . join ( '\n' ) ) ;
3332 var defer = Q . defer ( ) ;
34- analyze ( dir , defer . makeNodeResolver ( ) ) ;
33+ if ( config . use_ddc ) {
34+ analyze ( dir , defer . makeNodeResolver ( ) , true ) ;
35+ } else {
36+ analyze ( dir , defer . makeNodeResolver ( ) ) ;
37+ }
3538 return defer . promise ;
3639 } ) ;
3740
38- function analyze ( dirName , done ) {
41+ function analyze ( dirName , done , useDdc ) {
3942 // TODO remove --package-warnings once dartanalyzer handles transitive libraries
40- var args = [ '--fatal-warnings' , '--package-warnings' , '--format=machine' ] . concat ( tempFile ) ;
43+ var flags = [ '--fatal-warnings' , '--package-warnings' , '--format=machine' ] ;
44+
45+ if ( useDdc ) {
46+ console . log ( 'Using DDC analyzer to analyze' , dirName ) ;
47+ flags . push ( '--strong' ) ;
48+ }
49+
50+ var args = flags . concat ( tempFile ) ;
4151
4252 var stream = spawn ( config . command , args , {
4353 // inherit stdin and stderr, but filter stdout
@@ -97,7 +107,19 @@ module.exports = function(gulp, plugins, config) {
97107 if ( report . length > 0 ) {
98108 error = 'Dartanalyzer showed ' + report . join ( ', ' ) ;
99109 }
100- done ( error ) ;
110+ if ( useDdc ) {
111+ // TODO(yjbanov): fail the build when:
112+ // - DDC analyzer is stable enough
113+ // - We have cleaned up all DDC warnings
114+ console . log ( error ) ;
115+ done ( ) ;
116+ } else {
117+ done ( error ) ;
118+ }
119+ } ) ;
120+ stream . on ( 'error' , function ( e ) {
121+ // TODO(yjbanov): fail the build when DDC is stable enough
122+ console . log ( 'ERROR: failed to run DDC at all: ' + e ) ;
101123 } ) ;
102124 }
103125 } ;
0 commit comments