chore(build): add experimental Dart build that uses DDC for code analysis

This commit is contained in:
Yegor Jbanov 2015-06-03 17:22:30 -07:00 committed by yjbanov
parent 03c8e7428f
commit 49dc819d23
6 changed files with 61 additions and 10 deletions

View File

@ -25,6 +25,7 @@ env:
- MODE=js DART_CHANNEL=dev
- MODE=dart DART_CHANNEL=stable
- MODE=dart DART_CHANNEL=dev
- MODE=dart_experimental DART_CHANNEL=dev
addons:
firefox: "38.0"

View File

@ -243,6 +243,12 @@ gulp.task('build/analyze.dart', dartanalyzer(gulp, gulpPlugins, {
command: DART_SDK.ANALYZER
}));
gulp.task('build/analyze.ddc.dart', dartanalyzer(gulp, gulpPlugins, {
dest: CONFIG.dest.dart,
command: DART_SDK.ANALYZER,
use_ddc: true
}));
// ------------
// pubbuild
// WARNING: this task is very slow (~15m as of July 2015)

View File

@ -8,6 +8,11 @@ echo ===========================================================================
SCRIPT_DIR=$(dirname $0)
cd $SCRIPT_DIR/../..
${SCRIPT_DIR}/build_$MODE.sh
mkdir deploy; tar -czpf deploy/dist.tgz -C dist .
${SCRIPT_DIR}/test_$MODE.sh
if [ "$MODE" = "dart_experimental" ]
then
${SCRIPT_DIR}/build_$MODE.sh
else
${SCRIPT_DIR}/build_$MODE.sh
mkdir deploy; tar -czpf deploy/dist.tgz -C dist .
${SCRIPT_DIR}/test_$MODE.sh
fi

View File

@ -0,0 +1,15 @@
#!/bin/bash
set -e
echo =============================================================================
echo EXPERIMENTAL DART BUILD
echo =============================================================================
# go to project dir
SCRIPT_DIR=$(dirname $0)
source $SCRIPT_DIR/env_dart.sh
cd $SCRIPT_DIR/../..
./node_modules/.bin/gulp build/packages.dart
./node_modules/.bin/gulp build/pubspec.dart
./node_modules/.bin/gulp build/analyze.ddc.dart

View File

@ -70,7 +70,9 @@ if [[ -z $ENV_SET ]]; then
export DARTSDK
export DART
export PUB=${PUB:-"$DART_SDK/bin/pub"}
export PUB_CACHE=$DART_SDK/pub-cache
if [ -z "$PUB_CACHE" ]; then
export PUB_CACHE=$DART_SDK/pub-cache
fi
export DARTANALYZER=${DARTANALYZER:-"$DART_SDK/bin/dartanalyzer"}
export DARTDOC=${DARTDOC:-"$DART_SDK/bin/dartdoc"}
export DART_DOCGEN=${DART_DOCGEN:-"$DART_SDK/bin/docgen"}

View File

@ -16,10 +16,9 @@ module.exports = function(gulp, plugins, config) {
var packageName = pubspec.name;
var libFiles = [].slice.call(glob.sync('lib/**/*.dart', {cwd: dir}));
var webFiles = [].slice.call(glob.sync('web/**/*.dart', {cwd: dir}));
var testFiles = [].slice.call(glob.sync('test/**/*_spec.dart', {cwd: dir}));
var analyzeFile = ['library _analyzer;'];
libFiles.concat(testFiles).concat(webFiles).forEach(function(fileName, index) {
if (fileName !== tempFile && fileName.indexOf("/packages/") === -1) {
@ -31,13 +30,24 @@ module.exports = function(gulp, plugins, config) {
});
fs.writeFileSync(path.join(dir, tempFile), analyzeFile.join('\n'));
var defer = Q.defer();
analyze(dir, defer.makeNodeResolver());
if (config.use_ddc) {
analyze(dir, defer.makeNodeResolver(), true);
} else {
analyze(dir, defer.makeNodeResolver());
}
return defer.promise;
});
function analyze(dirName, done) {
function analyze(dirName, done, useDdc) {
// TODO remove --package-warnings once dartanalyzer handles transitive libraries
var args = ['--fatal-warnings', '--package-warnings', '--format=machine'].concat(tempFile);
var flags = ['--fatal-warnings', '--package-warnings', '--format=machine'];
if (useDdc) {
console.log('Using DDC analyzer to analyze', dirName);
flags.push('--strong');
}
var args = flags.concat(tempFile);
var stream = spawn(config.command, args, {
// inherit stdin and stderr, but filter stdout
@ -97,7 +107,19 @@ module.exports = function(gulp, plugins, config) {
if (report.length > 0) {
error = 'Dartanalyzer showed ' + report.join(', ');
}
done(error);
if (useDdc) {
// TODO(yjbanov): fail the build when:
// - DDC analyzer is stable enough
// - We have cleaned up all DDC warnings
console.log(error);
done();
} else {
done(error);
}
});
stream.on('error', function(e) {
// TODO(yjbanov): fail the build when DDC is stable enough
console.log('ERROR: failed to run DDC at all: ' + e);
});
}
};