chore(build): add experimental Dart build that uses DDC for code analysis
This commit is contained in:
parent
03c8e7428f
commit
49dc819d23
|
@ -25,6 +25,7 @@ env:
|
||||||
- MODE=js DART_CHANNEL=dev
|
- MODE=js DART_CHANNEL=dev
|
||||||
- MODE=dart DART_CHANNEL=stable
|
- MODE=dart DART_CHANNEL=stable
|
||||||
- MODE=dart DART_CHANNEL=dev
|
- MODE=dart DART_CHANNEL=dev
|
||||||
|
- MODE=dart_experimental DART_CHANNEL=dev
|
||||||
|
|
||||||
addons:
|
addons:
|
||||||
firefox: "38.0"
|
firefox: "38.0"
|
||||||
|
|
|
@ -243,6 +243,12 @@ gulp.task('build/analyze.dart', dartanalyzer(gulp, gulpPlugins, {
|
||||||
command: DART_SDK.ANALYZER
|
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
|
// pubbuild
|
||||||
// WARNING: this task is very slow (~15m as of July 2015)
|
// WARNING: this task is very slow (~15m as of July 2015)
|
||||||
|
|
|
@ -8,6 +8,11 @@ echo ===========================================================================
|
||||||
SCRIPT_DIR=$(dirname $0)
|
SCRIPT_DIR=$(dirname $0)
|
||||||
cd $SCRIPT_DIR/../..
|
cd $SCRIPT_DIR/../..
|
||||||
|
|
||||||
${SCRIPT_DIR}/build_$MODE.sh
|
if [ "$MODE" = "dart_experimental" ]
|
||||||
mkdir deploy; tar -czpf deploy/dist.tgz -C dist .
|
then
|
||||||
${SCRIPT_DIR}/test_$MODE.sh
|
${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
|
||||||
|
|
|
@ -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
|
|
@ -70,7 +70,9 @@ if [[ -z $ENV_SET ]]; then
|
||||||
export DARTSDK
|
export DARTSDK
|
||||||
export DART
|
export DART
|
||||||
export PUB=${PUB:-"$DART_SDK/bin/pub"}
|
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 DARTANALYZER=${DARTANALYZER:-"$DART_SDK/bin/dartanalyzer"}
|
||||||
export DARTDOC=${DARTDOC:-"$DART_SDK/bin/dartdoc"}
|
export DARTDOC=${DARTDOC:-"$DART_SDK/bin/dartdoc"}
|
||||||
export DART_DOCGEN=${DART_DOCGEN:-"$DART_SDK/bin/docgen"}
|
export DART_DOCGEN=${DART_DOCGEN:-"$DART_SDK/bin/docgen"}
|
||||||
|
|
|
@ -16,10 +16,9 @@ module.exports = function(gulp, plugins, config) {
|
||||||
var packageName = pubspec.name;
|
var packageName = pubspec.name;
|
||||||
|
|
||||||
var libFiles = [].slice.call(glob.sync('lib/**/*.dart', {cwd: dir}));
|
var libFiles = [].slice.call(glob.sync('lib/**/*.dart', {cwd: dir}));
|
||||||
|
|
||||||
var webFiles = [].slice.call(glob.sync('web/**/*.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 testFiles = [].slice.call(glob.sync('test/**/*_spec.dart', {cwd: dir}));
|
||||||
|
|
||||||
var analyzeFile = ['library _analyzer;'];
|
var analyzeFile = ['library _analyzer;'];
|
||||||
libFiles.concat(testFiles).concat(webFiles).forEach(function(fileName, index) {
|
libFiles.concat(testFiles).concat(webFiles).forEach(function(fileName, index) {
|
||||||
if (fileName !== tempFile && fileName.indexOf("/packages/") === -1) {
|
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'));
|
fs.writeFileSync(path.join(dir, tempFile), analyzeFile.join('\n'));
|
||||||
var defer = Q.defer();
|
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;
|
return defer.promise;
|
||||||
});
|
});
|
||||||
|
|
||||||
function analyze(dirName, done) {
|
function analyze(dirName, done, useDdc) {
|
||||||
// TODO remove --package-warnings once dartanalyzer handles transitive libraries
|
// 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, {
|
var stream = spawn(config.command, args, {
|
||||||
// inherit stdin and stderr, but filter stdout
|
// inherit stdin and stderr, but filter stdout
|
||||||
|
@ -97,7 +107,19 @@ module.exports = function(gulp, plugins, config) {
|
||||||
if (report.length > 0) {
|
if (report.length > 0) {
|
||||||
error = 'Dartanalyzer showed ' + report.join(', ');
|
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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue