[ddc] Allow DDC to compile SDK from dill
This is the first step to removing all of the the sdks precompiled to JS modules from the sdk download. Enables build_runner to produce a JS file on demand from a .dill file bundled in the sdk download. At this time, only the SDK can be compiled from a .dill file. Update build targets to run bin/dartdevc.dart instead of tool/compile_dartdevc_sdk.dart. Will delete tool/compile_dartdevc_sdk.dart after we cleanup all of the uses outside of the SDK. Change-Id: Id6002675419e8e502912cb3f5b626a0d13461df5 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151025 Commit-Queue: Nicholas Shahan <nshahan@google.com> Reviewed-by: Nate Bosch <nbosch@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
2d22e4ca26
commit
7f268aba04
@@ -135,26 +135,26 @@ class SharedCompilerOptions {
|
||||
addModuleFormatOptions(parser, hide: hide);
|
||||
|
||||
parser
|
||||
..addMultiOption('out', abbr: 'o', help: 'Output file (required).')
|
||||
..addMultiOption('summary',
|
||||
abbr: 's',
|
||||
help: 'summary file(s) of imported libraries, optionally\n'
|
||||
'with module import path: -s path.sum=js/import/path')
|
||||
help: 'API summary file(s) of imported libraries, optionally\n'
|
||||
'with module import path: -s path.dill=js/import/path')
|
||||
..addMultiOption('enable-experiment',
|
||||
help: 'used to enable/disable experimental language features',
|
||||
hide: hide)
|
||||
help: 'Enable/disable experimental language features.', hide: hide)
|
||||
..addFlag('summarize',
|
||||
help: 'emit an API summary file', defaultsTo: true, hide: hide)
|
||||
help: 'Emit an API summary file.', defaultsTo: true, hide: hide)
|
||||
..addFlag('source-map',
|
||||
help: 'emit source mapping', defaultsTo: true, hide: hide)
|
||||
help: 'Emit source mapping.', defaultsTo: true, hide: hide)
|
||||
..addFlag('inline-source-map',
|
||||
help: 'emit source mapping inline', defaultsTo: false, hide: hide)
|
||||
help: 'Emit source mapping inline.', defaultsTo: false, hide: hide)
|
||||
..addFlag('enable-asserts',
|
||||
help: 'enable assertions', defaultsTo: true, hide: hide)
|
||||
help: 'Enable assertions.', defaultsTo: true, hide: hide)
|
||||
..addOption('module-name',
|
||||
help: 'The output module name, used in some JS module formats.\n'
|
||||
'Defaults to the output file name (without .js).')
|
||||
..addFlag('repl-compile',
|
||||
help: 'compile in a more permissive REPL mode, allowing access'
|
||||
help: 'Compile in a more permissive REPL mode, allowing access'
|
||||
' to private members across library boundaries. This should'
|
||||
' only be used by debugging tools.',
|
||||
defaultsTo: false,
|
||||
@@ -163,6 +163,13 @@ class SharedCompilerOptions {
|
||||
help: 'Compile for sound null safety at runtime.',
|
||||
negatable: true,
|
||||
defaultsTo: false)
|
||||
..addOption('multi-root-scheme',
|
||||
help: 'The custom scheme to indicate a multi-root uri.',
|
||||
defaultsTo: 'org-dartlang-app')
|
||||
..addOption('multi-root-output-path',
|
||||
help: 'Path to set multi-root files relative to when generating'
|
||||
' source-maps.',
|
||||
hide: true)
|
||||
// TODO(41852) Define a process for breaking changes before graduating from
|
||||
// experimental.
|
||||
..addFlag('experimental-emit-debug-metadata',
|
||||
|
||||
@@ -81,27 +81,21 @@ Future<CompilerResult> _compile(List<String> args,
|
||||
var argParser = ArgParser(allowTrailingOptions: true)
|
||||
..addFlag('help',
|
||||
abbr: 'h', help: 'Display this message.', negatable: false)
|
||||
..addMultiOption('out', abbr: 'o', help: 'Output file (required).')
|
||||
..addOption('packages', help: 'The package spec file to use.')
|
||||
// TODO(jmesserly): is this still useful for us, or can we remove it now?
|
||||
..addFlag('summarize-text',
|
||||
help: 'emit API summary in a .js.txt file',
|
||||
help: 'Emit API summary in a .js.txt file.',
|
||||
defaultsTo: false,
|
||||
hide: true)
|
||||
..addFlag('track-widget-creation',
|
||||
help: 'enable inspecting of Flutter widgets', hide: true)
|
||||
help: 'Enable inspecting of Flutter widgets.', hide: true)
|
||||
// TODO(jmesserly): add verbose help to show hidden options
|
||||
..addOption('dart-sdk-summary',
|
||||
help: 'The path to the Dart SDK summary file.', hide: true)
|
||||
..addOption('multi-root-scheme',
|
||||
help: 'The custom scheme to indicate a multi-root uri.',
|
||||
defaultsTo: 'org-dartlang-app')
|
||||
..addMultiOption('multi-root',
|
||||
help: 'The directories to search when encountering uris with the '
|
||||
'specified multi-root scheme.',
|
||||
defaultsTo: [Uri.base.path])
|
||||
..addOption('multi-root-output-path',
|
||||
help: 'Path to set multi-root files relative to.', hide: true)
|
||||
..addOption('dart-sdk',
|
||||
help: '(unsupported with --kernel) path to the Dart SDK.', hide: true)
|
||||
..addFlag('compile-sdk',
|
||||
@@ -208,6 +202,11 @@ Future<CompilerResult> _compile(List<String> args,
|
||||
throw StateError('Non-dill file detected in input: $summaryPaths');
|
||||
}
|
||||
|
||||
var inputs = [for (var arg in argResults.rest) sourcePathToCustomUri(arg)];
|
||||
if (inputs.length == 1 && inputs.single.path.endsWith('.dill')) {
|
||||
return compileSdkFromDill(args);
|
||||
}
|
||||
|
||||
if (librarySpecPath == null) {
|
||||
// TODO(jmesserly): the `isSupported` bit should be included in the SDK
|
||||
// summary, but front_end requires a separate file, so we have to work
|
||||
@@ -239,8 +238,6 @@ Future<CompilerResult> _compile(List<String> args,
|
||||
// This needs further investigation.
|
||||
var packageFile = argResults['packages'] as String ?? _findPackagesFilePath();
|
||||
|
||||
var inputs = argResults.rest.map(sourcePathToCustomUri).toList();
|
||||
|
||||
var succeeded = true;
|
||||
void diagnosticMessageHandler(fe.DiagnosticMessage message) {
|
||||
if (message.severity == fe.Severity.error) {
|
||||
@@ -262,6 +259,7 @@ Future<CompilerResult> _compile(List<String> args,
|
||||
fe.WorkerInputComponent cachedSdkInput;
|
||||
var recordUsedInputs = argResults['used-inputs-file'] != null;
|
||||
var additionalDills = summaryModules.keys.toList();
|
||||
|
||||
if (!useIncrementalCompiler) {
|
||||
compilerState = await fe.initializeCompiler(
|
||||
oldCompilerState,
|
||||
@@ -470,13 +468,7 @@ Future<CompilerResult> _compile(List<String> args,
|
||||
// well.
|
||||
// TODO(sigmund): refactor the underlying pieces to reduce the code duplication.
|
||||
Future<CompilerResult> compileSdkFromDill(List<String> args) async {
|
||||
var argParser = ArgParser(allowTrailingOptions: true)
|
||||
..addMultiOption('out', abbr: 'o', help: 'Output file (required).')
|
||||
..addOption('multi-root-scheme', defaultsTo: 'org-dartlang-sdk')
|
||||
..addOption('multi-root-output-path',
|
||||
help: 'Path to set multi-root files relative to when generating'
|
||||
' source-maps.',
|
||||
hide: true);
|
||||
var argParser = ArgParser(allowTrailingOptions: true);
|
||||
SharedCompilerOptions.addArguments(argParser);
|
||||
|
||||
ArgResults argResults;
|
||||
@@ -488,6 +480,18 @@ Future<CompilerResult> compileSdkFromDill(List<String> args) async {
|
||||
return CompilerResult(64);
|
||||
}
|
||||
|
||||
var inputs = argResults.rest.toList();
|
||||
if (inputs.length != 1) {
|
||||
print('Only a single input file is supported to compile the sdk from dill'
|
||||
'but found: \n${inputs.join('\n')}');
|
||||
return CompilerResult(64);
|
||||
}
|
||||
|
||||
if (!inputs.single.endsWith('.dill')) {
|
||||
print('Input must be a .dill file: ${inputs.single}');
|
||||
return CompilerResult(64);
|
||||
}
|
||||
|
||||
var outPaths = argResults['out'] as List<String>;
|
||||
var moduleFormats = parseModuleFormatOption(argResults);
|
||||
if (outPaths.isEmpty) {
|
||||
@@ -500,7 +504,19 @@ Future<CompilerResult> compileSdkFromDill(List<String> args) async {
|
||||
return CompilerResult(64);
|
||||
}
|
||||
|
||||
var component = loadComponentFromBinary(argResults.rest[0]);
|
||||
var component = loadComponentFromBinary(inputs.single);
|
||||
var invalidLibraries = <Uri>[];
|
||||
for (var library in component.libraries) {
|
||||
if (library.importUri.scheme != 'dart') {
|
||||
invalidLibraries.add(library.importUri);
|
||||
}
|
||||
}
|
||||
|
||||
if (invalidLibraries.isNotEmpty) {
|
||||
print('Only the SDK libraries can be compiled from .dill but found:\n'
|
||||
'${invalidLibraries.join('\n')}');
|
||||
return CompilerResult(64);
|
||||
}
|
||||
var coreTypes = CoreTypes(component);
|
||||
var hierarchy = ClassHierarchy(component, coreTypes);
|
||||
var multiRootScheme = argResults['multi-root-scheme'] as String;
|
||||
|
||||
@@ -322,16 +322,13 @@ template("compile_dartdevc_platform") {
|
||||
]
|
||||
|
||||
if (invoker.sound_null_safety) {
|
||||
args += [
|
||||
"--nnbd-strong",
|
||||
]
|
||||
args += [ "--nnbd-strong" ]
|
||||
|
||||
outputs = [
|
||||
sdk_full_sound_dill,
|
||||
sdk_outline_sound_dill,
|
||||
]
|
||||
} else {
|
||||
|
||||
outputs = [
|
||||
sdk_full_dill,
|
||||
sdk_outline_dill,
|
||||
@@ -387,7 +384,7 @@ template("dartdevc_sdk_js") {
|
||||
"$js_gen_dir/legacy/dart_sdk.js.map",
|
||||
]
|
||||
|
||||
script = "../../pkg/dev_compiler/tool/compile_dartdevc_sdk.dart"
|
||||
script = "../../pkg/dev_compiler/bin/dartdevc.dart"
|
||||
|
||||
args = [
|
||||
"--multi-root-scheme",
|
||||
|
||||
Reference in New Issue
Block a user