Build DDC's SDK as part of the regular build.

This involves a few main pieces:

- Add code to the GN scripts to generate DDC's patched SDK and then
  compile it to summaries and JS in the build output directory.

- Add support to the underlying DDC build scripts to support controlling
  which files are built where.

- Update test.dart to use the DDC SDK from the build directory.

- Update create_sdk to use the built SDK instead of the checked in one.

- Fix various internal DDC tools to build their own copy of the SDK
  (since they can't easily find the one in the build directory because
  it's path if config-specific) and use those.

- Delete the checked DDC SDK JS and summaries.

I think I got everything working. The built Dart SDK looks fine -- it's
identical to one built using the old build scripts.

The various tools and DDC's little test runner I *think* work, but there
may be a bug or two in there. I tried the various things I could and it
seems like they work but it's hard to tell since they may be kind of
broken right now anyway.

Bug:
Change-Id: Iea77915a5c1cc8450f60ebfbdf8c725c7ea2f32c
Reviewed-on: https://dart-review.googlesource.com/18144
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
This commit is contained in:
Bob Nystrom 2017-11-20 23:24:07 +00:00 committed by commit-bot@chromium.org
parent a595dc2af5
commit 68dc77f456
28 changed files with 431 additions and 477365 deletions

View file

@ -74,7 +74,7 @@ script:
- if [[ "$TEST" == sdk ]]; then ./tool/build_sdk.sh && git diff --exit-code ; fi
- if [[ "$TEST" == coverage ]]; then ./tool/build_sdk.sh && ./tool/coverage.sh ; fi
- if [[ "$TEST" == node ]]; then ./tool/node_test.sh ; fi
- if [[ "$TEST" == package ]]; then ./tool/build_sdk.sh && ./tool/build_pkgs.dart gen/codegen_output/pkg travis; fi
- if [[ "$TEST" == package ]]; then ./tool/build_sdk.sh && ./tool/build_pkgs.dart --analyzer-sdk=gen/sdk/ddc_gen.sum --output=gen/codegen_output/pkg --travis; fi
env:
- ANALYZER=master DDC_BROWSERS=ChromeTravis
- ANALYZER=master DDC_BROWSERS=Firefox

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

View file

@ -45,7 +45,7 @@ Future<bool> compile(List<String> args) async {
(argResults['summary'] as List<String>).map(Uri.parse).toList();
var sdkSummaryPath = argResults['dart-sdk-summary'] ??
path.absolute(ddcPath, 'lib', 'sdk', 'ddc_sdk.dill');
path.absolute(ddcPath, 'gen', 'sdk', 'ddc_sdk.dill');
var succeeded = true;
void errorHandler(CompilationMessage error) {

View file

@ -75,7 +75,7 @@ main(List<String> arguments) {
var sdkDir = path.join(repoDirectory, 'gen', 'patched_sdk');
var sdkSummaryFile =
path.join(testDirectory, '..', 'lib', 'sdk', 'ddc_sdk.sum');
path.join(testDirectory, '..', 'gen', 'sdk', 'ddc_sdk.sum');
var summaryPaths = new Directory(path.join(codegenOutputDir, 'pkg'))
.listSync()

View file

@ -18,7 +18,7 @@ import '../testing.dart' show repoDirectory, testDirectory;
final optionsDir = path.join(testDirectory, 'options');
/// Summary file for testing.
final sdkSummaryFile = path.join(repoDirectory, 'lib', 'sdk', 'ddc_sdk.sum');
final sdkSummaryFile = path.join(repoDirectory, 'gen', 'sdk', 'ddc_sdk.sum');
final sdkSummaryArgs = ['--$sdkSummaryPathOption', sdkSummaryFile];

View file

@ -21,7 +21,7 @@ main() {
final argsFile = file('test/worker/hello_world.args');
final inputDartFile = file('test/worker/hello_world.dart');
final outputJsFile = file('test/worker/out/hello_world.js');
final dartSdkSummary = file('lib/sdk/ddc_sdk.sum');
final dartSdkSummary = file('gen/sdk/ddc_sdk.sum');
final executableArgs = [dartdevc];
final compilerArgs = [
'--no-source-map',
@ -156,7 +156,7 @@ main() {
});
test('can compile in basic mode', () {
final dartSdkSummary = file('lib/sdk/ddc_sdk.sum');
final dartSdkSummary = file('gen/sdk/ddc_sdk.sum');
var result = Process.runSync(Platform.executable, [
dartdevc,
'--summary-extension=api.ds',
@ -193,7 +193,7 @@ main() {
});
test('reports error on overlapping summaries', () {
final dartSdkSummary = file('lib/sdk/ddc_sdk.sum');
final dartSdkSummary = file('gen/sdk/ddc_sdk.sum');
var result = Process.runSync(Platform.executable, [
dartdevc,
'--summary-extension=api.ds',
@ -251,7 +251,7 @@ main() {
});
group('Error handling', () {
final dartSdkSummary = file('lib/sdk/ddc_sdk.sum');
final dartSdkSummary = file('gen/sdk/ddc_sdk.sum');
final badFileDart = file('test/worker/bad.dart');
final badFileJs = file('test/worker/bad.js');
@ -290,7 +290,7 @@ main() {
});
group('Parts', () {
final dartSdkSummary = file('lib/sdk/ddc_sdk.sum');
final dartSdkSummary = file('gen/sdk/ddc_sdk.sum');
final partFile = file('test/worker/greeting.dart');
final libraryFile = file('test/worker/hello.dart');

View file

@ -2,6 +2,7 @@
import 'dart:async';
import 'dart:io';
import 'package:args/args.dart';
import 'package:front_end/compilation_message.dart';
import 'package:front_end/compiler_options.dart';
import 'package:front_end/summary_generator.dart';
@ -12,6 +13,14 @@ import 'package:dev_compiler/src/kernel/target.dart';
final String scriptDirectory = p.dirname(p.fromUri(Platform.script));
final String repoDirectory = p.normalize(p.join(scriptDirectory, "../../../"));
/// Path to the SDK analyzer summary file, "ddc_sdk.sum".
String analyzerSummary;
/// Path to the SDK kernel summary file, "ddc_sdk.dill".
String kernelSummary;
/// The directory that output is written to.
///
/// The DDC kernel SDK should be directly in this directory. The resulting
@ -21,24 +30,46 @@ String outputDirectory;
String get pkgDirectory => p.join(outputDirectory, "pkg");
/// Compiles the packages that the DDC tests use to JS into the given output
/// directory. Usage:
/// directory.
///
/// dart build_pkgs.dart <output_dir> [travis]
///
/// If "travis" is passed, builds the all of the modules tested on Travis.
/// If "--travis" is passed, builds the all of the modules tested on Travis.
/// Otherwise, only builds the modules needed by the tests.
///
/// If "--analyzer-sdk" is provided, uses that summary file and compiles the
/// packages to JS and analyzer summaries against that SDK summary. Otherwise,
/// it skips generating analyzer summaries and compiling to JS.
///
/// If "--kernel-sdk" is provided, uses that summary file and generates kernel
/// summaries for the test packages against that SDK summary. Otherwise, skips
/// generating kernel summaries.
Future main(List<String> arguments) async {
var isTravis = arguments.isNotEmpty && arguments.last == "travis";
if (isTravis) {
arguments = arguments.sublist(0, arguments.length - 1);
var argParser = new ArgParser();
argParser.addOption("analyzer-sdk",
help: "Path to SDK analyzer summary '.sum' file");
argParser.addOption("kernel-sdk",
help: "Path to SDK Kernel summary '.dill' file");
argParser.addOption("output",
abbr: "o", help: "Directory to write output to.");
argParser.addFlag("travis",
help: "Build the additional packages tested on Travis.");
ArgResults argResults;
try {
argResults = argParser.parse(arguments);
} on ArgParserException catch (ex) {
_usageError(argParser, ex.message);
}
if (arguments.length != 1) {
print("Usage: dart build_pkgs.dart <output_dir> [travis]");
exit(1);
if (argResults.rest.isNotEmpty) {
_usageError(
argParser, 'Unexpected arguments "${argResults.rest.join(' ')}".');
}
outputDirectory = arguments[0];
var isTravis = argResults["travis"];
analyzerSummary = argResults["analyzer-sdk"];
kernelSummary = argResults["kernel-sdk"];
outputDirectory = argResults["output"];
new Directory(pkgDirectory).createSync(recursive: true);
// Build leaf packages. These have no other package dependencies.
@ -89,18 +120,32 @@ Future main(List<String> arguments) async {
}
}
void _usageError(ArgParser parser, [String message]) {
if (message != null) {
stderr.writeln(message);
stderr.writeln();
}
stderr.writeln("Usage: dart build_pkgs.dart ...");
stderr.writeln();
stderr.writeln(parser.usage);
exit(1);
}
/// Compiles a [module] with a single matching ".dart" library and additional
/// [libs] and [deps] on other modules.
Future compileModule(String module,
{List<String> libs, List<String> deps}) async {
compileModuleUsingAnalyzer(module, libs, deps);
await compileKernelSummary(module, libs, deps);
if (analyzerSummary != null) compileModuleUsingAnalyzer(module, libs, deps);
if (kernelSummary != null) await compileKernelSummary(module, libs, deps);
}
void compileModuleUsingAnalyzer(
String module, List<String> libraries, List<String> dependencies) {
var sdkSummary = p.join(scriptDirectory, "../lib/sdk/ddc_sdk.sum");
var args = ['--dart-sdk-summary=$sdkSummary', '-o${pkgDirectory}/$module.js'];
var args = [
'--dart-sdk-summary=$analyzerSummary',
'-o${pkgDirectory}/$module.js'
];
// There is always a library that matches the module.
args.add('package:$module/$module.dart');
@ -140,10 +185,8 @@ Future compileKernelSummary(
if (error.severity == Severity.error) succeeded = false;
}
var sdk = p.toUri(p.join(outputDirectory, "ddc_sdk.dill"));
print(sdk);
var options = new CompilerOptions()
..sdkSummary = sdk
..sdkSummary = p.toUri(kernelSummary)
..packagesFileUri = _uriInRepo(".packages")
..strongMode = true
..debugDump = true

View file

@ -1,5 +0,0 @@
#!/bin/bash
# TODO: This script is deprecated in favor of the Dart version. For now, forward
# to it so existing scripts don't break. Eventually, delete this one.
./tool/build_pkgs.dart gen/codegen_output travis

View file

@ -19,18 +19,18 @@ echo "*** Compiling SDK to JavaScript"
dart -c tool/build_sdk.dart \
--dart-sdk gen/patched_sdk \
--dart-sdk-summary=build \
--summary-out lib/sdk/ddc_sdk.sum \
--summary-out gen/sdk/ddc_sdk.sum \
--source-map \
--source-map-comment \
--inline-source-map \
--modules=amd \
-o lib/js/amd/dart_sdk.js \
-o gen/sdk/amd/dart_sdk.js \
--modules=es6 \
-o lib/js/es6/dart_sdk.js \
-o gen/sdk/es6/dart_sdk.js \
--modules=common \
-o lib/js/common/dart_sdk.js \
-o gen/sdk/common/dart_sdk.js \
--modules=legacy \
-o lib/js/legacy/dart_sdk.js \
-o gen/sdk/legacy/dart_sdk.js \
"$@" > tool/sdk_expected_errors.txt
} || { # Catch
# Show errors if the sdk didn't compile.

View file

@ -14,7 +14,7 @@
#
D8=$(type -P d8)
if [ ! $D8 ]; then
echo "Please add d8 to your PATH"
echo "Please add d8 to your PATH."
exit 1
fi
set -e
@ -22,16 +22,21 @@ DDC_PATH=$( cd $( dirname "${BASH_SOURCE[0]}" )/.. && pwd )
BASENAME=$( basename "${1%.*}")
LIBROOT=$(cd $( dirname "${1%.*}") && pwd)
# Build the SDK in a place where we can find it if it's not already there.
if [ ! -e gen/sdk/ddc_sdk.sum ]; then
./tool/build_sdk.sh
fi
# D8 uses relative paths. That won't work for the sdk right now as the
# summary is in a slightly different location.
# D8/ES6 imports also do not add a ".js" extension, so this is "dart_sdk"
# instead of "dart_sdk.js".
if [ ! -f dart_sdk ]; then
ln -s $DDC_PATH/lib/js/es6/dart_sdk.js dart_sdk
ln -s $DDC_PATH/gen/sdk/es6/dart_sdk.js dart_sdk
fi
dart -c $DDC_PATH/bin/dartdevc.dart --modules=es6 --library-root=$LIBROOT \
--dart-sdk-summary=$DDC_PATH/lib/sdk/ddc_sdk.sum \
--dart-sdk-summary=$DDC_PATH/gen/sdk/ddc_sdk.sum \
-o $LIBROOT/$BASENAME.js $*
pushd $LIBROOT > /dev/null
echo "

View file

@ -6,25 +6,35 @@
#
# Saves the output in the same directory as the sources for convenient
# inspection, modification or rerunning the code.
#
set -e
DDC_PATH=$( cd $( dirname "${BASH_SOURCE[0]}" )/.. && pwd )
KERNEL=false
if [ "$1" = "-k" ]; then
KERNEL=true
shift
fi
BASENAME=$( basename "${1%.*}")
LIBROOT=$(cd $( dirname "${1%.*}") && pwd)
export NODE_PATH=$DDC_PATH/lib/js/common:$LIBROOT:$NODE_PATH
# Build the SDK in a place where we can find it if it's not already there.
if [ ! -e gen/sdk/ddc_sdk.sum ]; then
./tool/build_sdk.sh
fi
if [ "$KERNEL" = true ]; then
dart -c $DDC_PATH/bin/dartdevk.dart \
-o $BASENAME.js $*
else
dart -c $DDC_PATH/bin/dartdevc.dart --modules=node --library-root=$LIBROOT \
--dart-sdk-summary=$DDC_PATH/lib/sdk/ddc_sdk.sum \
--dart-sdk-summary=$DDC_PATH/gen/sdk/ddc_sdk.sum \
-o $LIBROOT/$BASENAME.js $*
fi
pushd $LIBROOT > /dev/null
# TODO(jmesserly): we could have this output the same content as the devtool
# script, so you could debug the output without recompiling?

View file

@ -7,25 +7,35 @@
#
# Saves the output in the same directory as the sources for convenient
# inspection, modification or rerunning the code.
#
set -e
DDC_PATH=$( cd $( dirname "${BASH_SOURCE[0]}" )/.. && pwd )
KERNEL=false
if [ "$1" = "-k" ]; then
KERNEL=true
shift
fi
BASENAME=$( basename "${1%.*}")
LIBROOT=$(cd $( dirname "${1%.*}") && pwd)
export NODE_PATH=$DDC_PATH/lib/js/common:$LIBROOT:$NODE_PATH
# Build the SDK in a place where we can find it if it's not already there.
if [ ! -e gen/sdk/ddc_sdk.sum ]; then
./tool/build_sdk.sh
fi
if [ "$KERNEL" = true ]; then
dart -c $DDC_PATH/bin/dartdevk.dart \
-o $BASENAME.js $*
else
dart -c $DDC_PATH/bin/dartdevc.dart --modules=node --library-root=$LIBROOT \
--dart-sdk-summary=$DDC_PATH/lib/sdk/ddc_sdk.sum \
--dart-sdk-summary=$DDC_PATH/gen/sdk/ddc_sdk.sum \
-o $LIBROOT/$BASENAME.js $*
fi
pushd $LIBROOT > /dev/null
echo "
// Fix the node.js search paths that Electron cleared out.

View file

@ -18,22 +18,22 @@ void main(List<String> argv) {
if (argv.length < 3) {
var toolDir = path.relative(path.dirname(path.fromUri(Platform.script)));
var inputExample = path.join(toolDir, '..', '..', '..');
var repoExample = path.join(toolDir, '..', '..', '..');
var patchExample = path.join(toolDir, 'input_sdk');
var outExample =
path.relative(path.normalize(path.join('gen', 'patched_sdk')));
print('Usage: $self INPUT_SDK_DIR PATCH_DIR OUTPUT_DIR');
print('Usage: $self DART_REPO_DIR PATCH_DIR OUTPUT_DIR');
print('For example:');
print('\$ $self $inputExample $patchExample $outExample');
print('\$ $self $repoExample $patchExample $outExample');
exit(1);
}
var selfModifyTime = new File(self).lastModifiedSync().millisecondsSinceEpoch;
var inputDir = argv[0];
var repoDir = argv[0];
var patchDir = argv[1];
var sdkLibIn = path.join(inputDir, 'sdk', 'lib');
var sdkLibIn = path.join(repoDir, 'sdk', 'lib');
var patchIn = path.join(patchDir, 'patch');
var privateIn = path.join(patchDir, 'private');
var sdkOut = path.join(argv[2], 'lib');
@ -52,7 +52,7 @@ void main(List<String> argv) {
sdkOut, '_internal', 'sdk_library_metadata', 'lib', 'libraries.dart'),
libContents);
_writeSync(path.join(sdkOut, '..', 'version'),
new File(path.join(inputDir, 'tools', 'VERSION')).readAsStringSync());
new File(path.join(repoDir, 'tools', 'VERSION')).readAsStringSync());
// Parse libraries.dart
var sdkLibraries = _getSdkLibraries(libContents);

View file

@ -27,7 +27,15 @@ if [ -d gen/codegen_output ]; then
rm -r gen/codegen_output || fail
fi
./tool/build_pkgs.dart gen/codegen_output/pkg
# Build the SDK summary in a place where the tests can find it if it's not
# already there.
if [ ! -e gen/sdk/ddc_sdk.sum ]; then
./tool/build_sdk.sh
fi
./tool/build_pkgs.dart \
--analyzer-sdk=gen/sdk/ddc_sdk.sum \
--output=gen/codegen_output/pkg
# Make sure we don't run tests in code coverage mode.
# this will cause us to generate files that are not part of the baseline

View file

@ -253,19 +253,6 @@ copy_tree_specs += [ {
ignore_patterns = "{}"
} ]
# This rule copies js needed by ddc to lib/dev_compiler
copy_tree_specs += [ {
target = "copy_dev_compiler_js"
visibility = [
":copy_dev_compiler_sdk",
":copy_dev_compiler_require_js",
":copy_dev_compiler_tools",
]
source = "../pkg/dev_compiler/lib/js"
dest = "$root_out_dir/dart-sdk/lib/dev_compiler"
ignore_patterns = "{}"
} ]
# This rule copies pub assets to lib/_internal/pub/asset
copy_tree_specs += [ {
target = "copy_pub_assets"
@ -525,11 +512,11 @@ copy("copy_dill_files") {
"../utils/compiler:compile_dart2js_platform",
]
sources = [
"$root_out_dir/dart2js_platform.dill",
"$root_out_dir/vm_outline.dill",
"$root_out_dir/vm_outline_strong.dill",
"$root_out_dir/vm_platform.dill",
"$root_out_dir/vm_platform_strong.dill",
"$root_out_dir/dart2js_platform.dill",
]
outputs = [
"$root_out_dir/dart-sdk/lib/_internal/{{source_file_part}}",
@ -541,22 +528,25 @@ copy("copy_dev_compiler_summary") {
visibility = [ ":copy_dev_compiler_sdk" ]
deps = [
":copy_libraries",
"../utils/dartdevc:dartdevc_sdk",
]
sources = [
"../pkg/dev_compiler/lib/sdk/ddc_sdk.sum",
"$root_out_dir/gen/utils/dartdevc/ddc_sdk.sum",
]
outputs = [
"$root_out_dir/dart-sdk/lib/_internal/{{source_file_part}}",
]
}
# This rule copies require.js to lib/dev_compiler/amd
copy("copy_dev_compiler_require_js") {
visibility = [ ":copy_dev_compiler_sdk" ]
# This rule copies DDC's JS SDK and require.js to lib/dev_compiler/amd.
copy("copy_dev_compiler_js_amd") {
visibility = [ ":copy_dev_compiler_js" ]
deps = [
":copy_dev_compiler_js",
"../utils/dartdevc:dartdevc_sdk",
]
sources = [
"$root_gen_dir/utils/dartdevc/js/amd/dart_sdk.js",
"$root_gen_dir/utils/dartdevc/js/amd/dart_sdk.js.map",
"../third_party/requirejs/require.js",
]
outputs = [
@ -564,6 +554,67 @@ copy("copy_dev_compiler_require_js") {
]
}
# This rule copies DDC's JS SDK and run.js to lib/dev_compiler/common.
copy("copy_dev_compiler_js_common") {
visibility = [ ":copy_dev_compiler_js" ]
deps = [
"../utils/dartdevc:dartdevc_sdk",
]
sources = [
"$root_gen_dir/utils/dartdevc/js/common/dart_sdk.js",
"$root_gen_dir/utils/dartdevc/js/common/dart_sdk.js.map",
"../pkg/dev_compiler/lib/js/common/run.js",
]
outputs = [
"$root_out_dir/dart-sdk/lib/dev_compiler/common/{{source_file_part}}",
]
}
# This rule copies DDC's JS SDK to lib/dev_compiler/es6.
copy("copy_dev_compiler_js_es6") {
visibility = [ ":copy_dev_compiler_js" ]
deps = [
"../utils/dartdevc:dartdevc_sdk",
]
sources = [
"$root_gen_dir/utils/dartdevc/js/es6/dart_sdk.js",
"$root_gen_dir/utils/dartdevc/js/es6/dart_sdk.js.map",
]
outputs = [
"$root_out_dir/dart-sdk/lib/dev_compiler/es6/{{source_file_part}}",
]
}
# This rule copies DDC's JS SDK and dart_library.js to lib/dev_compiler/legacy.
copy("copy_dev_compiler_js_legacy") {
visibility = [ ":copy_dev_compiler_js" ]
deps = [
"../utils/dartdevc:dartdevc_sdk",
]
sources = [
"$root_gen_dir/utils/dartdevc/js/legacy/dart_sdk.js",
"$root_gen_dir/utils/dartdevc/js/legacy/dart_sdk.js.map",
"../pkg/dev_compiler/lib/js/legacy/dart_library.js",
]
outputs = [
"$root_out_dir/dart-sdk/lib/dev_compiler/legacy/{{source_file_part}}",
]
}
# Copies all of the JS artifacts needed by DDC.
group("copy_dev_compiler_js") {
visibility = [
":copy_dev_compiler_sdk",
":copy_dev_compiler_tools",
]
deps = [
":copy_dev_compiler_js_amd",
":copy_dev_compiler_js_common",
":copy_dev_compiler_js_es6",
":copy_dev_compiler_js_legacy",
]
}
# This rule copies tools to go along with ddc.
copy("copy_dev_compiler_tools") {
visibility = [ ":copy_dev_compiler_sdk" ]
@ -587,7 +638,6 @@ group("copy_dev_compiler_sdk") {
visibility = [ ":create_full_sdk" ]
deps = [
":copy_dev_compiler_js",
":copy_dev_compiler_require_js",
":copy_dev_compiler_summary",
":copy_dev_compiler_tools",
]
@ -659,7 +709,9 @@ group("copy_libraries") {
# This rule writes the version file.
action("write_version_file") {
visibility = [ ":create_common_sdk" ]
inputs = [ "../tools/VERSION" ]
inputs = [
"../tools/VERSION",
]
output = "$root_out_dir/dart-sdk/version"
outputs = [
output,
@ -747,13 +799,13 @@ group("create_common_sdk") {
":copy_api_readme",
":copy_dart",
":copy_dartdoc_files",
":copy_dill_files",
":copy_headers",
":copy_libraries_dart",
":copy_license",
":copy_platform_files",
":copy_pub_assets",
":copy_readme",
":copy_dill_files",
":write_revision_file",
":write_version_file",
]

View file

@ -32,6 +32,9 @@ def BuildArguments():
result.add_argument("--dart-executable",
help="dart executable",
default=None)
result.add_argument("--script",
help="patch script to run",
default=None)
return result
def main():
@ -47,7 +50,12 @@ def main():
else:
print >> sys.stderr, 'ERROR: cannot locate dart executable'
return -1
dart_file = os.path.join(os.path.dirname(__file__), 'patch_sdk.dart')
if options.script is not None:
dart_file = options.script
else:
dart_file = os.path.join(os.path.dirname(__file__), 'patch_sdk.dart')
subprocess.check_call([options.dart_executable, dart_file] + args)
return 0

50
tools/run_dart.py Normal file
View file

@ -0,0 +1,50 @@
#!/usr/bin/env python
# Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
import argparse
import os
import subprocess
import sys
import utils
usage = """run_dart.py [--dart=<path>] <script> args..."""
def DisplayBootstrapWarning():
print """\
WARNING: Your system cannot run the checked-in Dart SDK. Using the
bootstrap Dart executable will make debug builds slow.
Please see the Wiki for instructions on replacing the checked-in Dart SDK.
https://github.com/dart-lang/sdk/wiki/The-checked-in-SDK-in-tools
"""
def BuildArguments():
result = argparse.ArgumentParser(usage=usage)
result.add_argument("--dart",
help="dart executable",
default=None)
return result
def main():
# Parse the options.
parser = BuildArguments()
(options, args) = parser.parse_known_args()
if utils.CheckedInSdkCheckExecutable():
options.dart_executable = utils.CheckedInSdkExecutable()
elif options.dart_executable is not None:
DisplayBootstrapWarning()
options.dart_executable = os.path.abspath(options.dart_executable)
else:
print >> sys.stderr, 'ERROR: cannot locate dart executable'
return -1
subprocess.check_call([options.dart_executable] + args)
return 0
if __name__ == '__main__':
sys.exit(main())

View file

@ -69,7 +69,7 @@ String dartdevcHtml(String testName, String testJSDir, String buildDir) {
var require = {
baseUrl: "/root_dart/$testJSDir",
paths: {
"dart_sdk": "/root_dart/pkg/dev_compiler/lib/js/amd/dart_sdk",
"dart_sdk": "/root_build/gen/utils/dartdevc/js/amd/dart_sdk",
$packagePaths
},
waitSeconds: 30,

View file

@ -402,11 +402,14 @@ class DevCompilerConfiguration extends CompilerConfiguration {
var moduleRoot =
new Path(outputFile).directoryPath.directoryPath.toNativePath();
var sdkSummary = new Path(_configuration.buildDirectory)
.append("/gen/utils/dartdevc/ddc_sdk.sum")
.absolute
.toNativePath();
var args = _useSdk
? ["--dart-sdk", "${_configuration.buildDirectory}/dart-sdk"]
// TODO(jmesserly): once we can build DDC's SDK summary+JS as part of
// the main build, change this to reflect that output path.
: ["--dart-sdk-summary", "pkg/dev_compiler/lib/sdk/ddc_sdk.sum"];
: ["--dart-sdk-summary", sdkSummary];
args.addAll(sharedOptions);
args.addAll([

View file

@ -2,16 +2,21 @@
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
import("../../build/prebuilt_dart_sdk.gni")
import("../application_snapshot.gni")
import("../create_timestamp.gni")
patched_sdk_dir = "$target_gen_dir/patched_sdk"
sdk_summary = "$target_gen_dir/ddc_sdk.sum"
application_snapshot("dartdevc") {
main_dart = "../../pkg/dev_compiler/bin/dartdevc.dart"
training_args = [
"--dart-sdk",
rebase_path("../../sdk"),
"--dart-sdk-summary",
rebase_path("../../pkg/dev_compiler/lib/sdk/ddc_sdk.sum"),
rebase_path(sdk_summary),
"--library-root",
rebase_path("../../pkg/dev_compiler"),
"-o",
@ -19,12 +24,18 @@ application_snapshot("dartdevc") {
"--unsafe-force-compile",
rebase_path("../../pkg/dev_compiler/bin/dartdevc.dart"),
]
deps = [
":dartdevc_sdk",
]
inputs = exec_script("../../tools/list_dart_files.py",
[
"absolute",
rebase_path("../../pkg/dev_compiler/bin"),
],
"list lines")
inputs += [ sdk_summary ]
}
sdk_lib_files = exec_script("../../tools/list_dart_files.py",
@ -87,10 +98,158 @@ dart2js_compile("stack_trace_mapper") {
out = "$root_out_dir/dev_compiler/build/web/dart_stack_trace_mapper.js"
}
# Apply dev_compiler's patch files to create the Dart version of the dartdevc
# SDK.
action("dartdevc_patch_sdk") {
# TODO(rnystrom): Unfork DDC's patch_sdk.dart script with the
# tools/patch_sdk.dart and then change this to use generate_patch_sdk().
deps = [
":dartdevc_files_stamp",
# The patch script uses several packages, including analyzer, so consider
# it dirty if any of those change.
"../../pkg:pkg_files_stamp",
]
if (!prebuilt_dart_exe_works) {
deps += [ "$_dart_root/runtime/bin:dart_bootstrap($dart_host_toolchain)" ]
}
script = "../../tools/patch_sdk.py"
# We list the `patch_sdk.dart` tool here because the [script] (which is
# implicitly an input) will call it.
inputs = [
"../../pkg/dev_compiler/tool/patch_sdk.dart",
]
# The main SDK library sources.
inputs += sdk_lib_files
# dev_compiler's additional sources and patch files.
inputs += exec_script("../../tools/list_dart_files.py",
[
"absolute",
rebase_path("../../pkg/dev_compiler/tool/input_sdk"),
],
"list lines")
# Arbitrarily use the version file as a token file to check against to see if
# the sources have changed.
# TODO(rnystrom): List the outputs more precisely?
outputs = [
"$patched_sdk_dir/version",
]
args = []
if (!prebuilt_dart_exe_works) {
dart_out_dir = get_label_info(
"$_dart_root/runtime/bin:dart_bootstrap($dart_host_toolchain)",
"root_out_dir")
dart_bootstrap =
rebase_path("$dart_out_dir/dart_bootstrap$executable_suffix")
args += [
"--dart-executable",
dart_bootstrap,
]
}
args += [
"--script",
rebase_path("../../pkg/dev_compiler/tool/patch_sdk.dart"),
rebase_path("../../"),
rebase_path("../../pkg/dev_compiler/tool/input_sdk"),
rebase_path(patched_sdk_dir),
]
}
# Compiles the Dart core libraries and DDC runtime to an analyzer summary and
# JS.
action("dartdevc_sdk") {
deps = [
":dartdevc_files_stamp",
":dartdevc_patch_sdk",
"../../pkg:pkg_files_stamp",
]
if (!prebuilt_dart_exe_works) {
deps += [ "$_dart_root/runtime/bin:dart_bootstrap($dart_host_toolchain)" ]
}
script = "../../tools/run_dart.py"
args = []
if (!prebuilt_dart_exe_works) {
dart_out_dir = get_label_info(
"$_dart_root/runtime/bin:dart_bootstrap($dart_host_toolchain)",
"root_out_dir")
dart_bootstrap =
rebase_path("$dart_out_dir/dart_bootstrap$executable_suffix")
args += [
"--dart",
dart_bootstrap,
]
}
args = [
rebase_path("../../pkg/dev_compiler/tool/build_sdk.dart"),
"--dart-sdk",
rebase_path(patched_sdk_dir),
"--dart-sdk-summary=build",
"--summary-out",
rebase_path(sdk_summary),
"--source-map",
"--source-map-comment",
"--inline-source-map",
"--modules=amd",
"-o",
rebase_path("$target_gen_dir/js/amd/dart_sdk.js"),
"--modules=es6",
"-o",
rebase_path("$target_gen_dir/js/es6/dart_sdk.js"),
"--modules=common",
"-o",
rebase_path("$target_gen_dir/js/common/dart_sdk.js"),
"--modules=legacy",
"-o",
rebase_path("$target_gen_dir/js/legacy/dart_sdk.js"),
]
inputs = [
"../../pkg/dev_compiler/tool/build_sdk.dart",
# Since the entire patched SDK is built in one step, if any file changes,
# they all will. Instead of listing them all as outputs of
# dartdevc_patch_sdk (which would require something like a depfile), just
# use version as the token file whose timestamp we track.
# TODO(rnystrom): Do something better?
"$patched_sdk_dir/version",
# If dev_compiler itself changes, it can affect the generated SDK.
"$target_gen_dir/dartdevc_files.stamp",
# Likewise, the packages dev_compiler depends on may affect its output.
"$root_gen_dir/pkg_files.stamp",
]
outputs = [
sdk_summary,
"$target_gen_dir/js/amd/dart_sdk.js",
"$target_gen_dir/js/amd/dart_sdk.js.map",
"$target_gen_dir/js/common/dart_sdk.js",
"$target_gen_dir/js/common/dart_sdk.js.map",
"$target_gen_dir/js/es6/dart_sdk.js",
"$target_gen_dir/js/es6/dart_sdk.js.map",
"$target_gen_dir/js/legacy/dart_sdk.js",
"$target_gen_dir/js/legacy/dart_sdk.js.map",
]
}
# Builds everything needed to run dartdevc and dartdevk tests using test.dart.
group("dartdevc_test") {
deps = [
":dartdevc",
":dartdevc_sdk",
":dartdevc_sdk_kernel_summary",
":dartdevc_test_pkg",
"../../sdk:create_sdk",
@ -108,13 +267,15 @@ compiled_action("dartdevc_test_pkg") {
tool = "../../runtime/bin:dart"
deps = [
":dartdevc_sdk_kernel_summary",
":dartdevc_files_stamp",
"../../pkg:pkg_files_stamp"
":dartdevc_sdk",
":dartdevc_sdk_kernel_summary",
"../../pkg:pkg_files_stamp",
]
inputs = [
"$target_gen_dir/ddc_sdk.dill",
sdk_summary,
"$target_gen_dir/dartdevc_files.stamp",
"$root_gen_dir/pkg_files.stamp",
]
@ -154,6 +315,11 @@ compiled_action("dartdevc_test_pkg") {
args = [
rebase_path("../../pkg/dev_compiler/tool/build_pkgs.dart"),
"--analyzer-sdk",
rebase_path(sdk_summary),
"--kernel-sdk",
rebase_path("$target_gen_dir/ddc_sdk.dill"),
"--output",
rebase_path("$target_gen_dir"),
]
}