Skip to content

Commit 49dc819

Browse files
committed
chore(build): add experimental Dart build that uses DDC for code analysis
1 parent 03c8e74 commit 49dc819

File tree

6 files changed

+61
-10
lines changed

6 files changed

+61
-10
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ env:
2525
- MODE=js DART_CHANNEL=dev
2626
- MODE=dart DART_CHANNEL=stable
2727
- MODE=dart DART_CHANNEL=dev
28+
- MODE=dart_experimental DART_CHANNEL=dev
2829

2930
addons:
3031
firefox: "38.0"

gulpfile.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,12 @@ gulp.task('build/analyze.dart', dartanalyzer(gulp, gulpPlugins, {
243243
command: DART_SDK.ANALYZER
244244
}));
245245

246+
gulp.task('build/analyze.ddc.dart', dartanalyzer(gulp, gulpPlugins, {
247+
dest: CONFIG.dest.dart,
248+
command: DART_SDK.ANALYZER,
249+
use_ddc: true
250+
}));
251+
246252
// ------------
247253
// pubbuild
248254
// WARNING: this task is very slow (~15m as of July 2015)

scripts/ci/build_and_test.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ echo ===========================================================================
88
SCRIPT_DIR=$(dirname $0)
99
cd $SCRIPT_DIR/../..
1010

11-
${SCRIPT_DIR}/build_$MODE.sh
12-
mkdir deploy; tar -czpf deploy/dist.tgz -C dist .
13-
${SCRIPT_DIR}/test_$MODE.sh
11+
if [ "$MODE" = "dart_experimental" ]
12+
then
13+
${SCRIPT_DIR}/build_$MODE.sh
14+
else
15+
${SCRIPT_DIR}/build_$MODE.sh
16+
mkdir deploy; tar -czpf deploy/dist.tgz -C dist .
17+
${SCRIPT_DIR}/test_$MODE.sh
18+
fi
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo =============================================================================
5+
echo EXPERIMENTAL DART BUILD
6+
echo =============================================================================
7+
8+
# go to project dir
9+
SCRIPT_DIR=$(dirname $0)
10+
source $SCRIPT_DIR/env_dart.sh
11+
cd $SCRIPT_DIR/../..
12+
13+
./node_modules/.bin/gulp build/packages.dart
14+
./node_modules/.bin/gulp build/pubspec.dart
15+
./node_modules/.bin/gulp build/analyze.ddc.dart

scripts/ci/env_dart.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ if [[ -z $ENV_SET ]]; then
7070
export DARTSDK
7171
export DART
7272
export PUB=${PUB:-"$DART_SDK/bin/pub"}
73-
export PUB_CACHE=$DART_SDK/pub-cache
73+
if [ -z "$PUB_CACHE" ]; then
74+
export PUB_CACHE=$DART_SDK/pub-cache
75+
fi
7476
export DARTANALYZER=${DARTANALYZER:-"$DART_SDK/bin/dartanalyzer"}
7577
export DARTDOC=${DARTDOC:-"$DART_SDK/bin/dartdoc"}
7678
export DART_DOCGEN=${DART_DOCGEN:-"$DART_SDK/bin/docgen"}

tools/build/dartanalyzer.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)