22// Use of this source code is governed by a BSD-style license that can be
33// found in the LICENSE file.
44
5+ // These packages exist in the third_party/dart .package, but not locally
6+ // which confuses the analyzer.
7+ // ignore_for_file: uri_does_not_exist
58import 'dart:async' ;
69import 'dart:convert' show json;
710import 'dart:io' ;
811import 'package:args/args.dart' show ArgParser;
9- import 'package:dev_compiler/src/compiler/module_builder.dart' ; // ignore: uri_does_not_exist
10- import 'package:dev_compiler/src/compiler/shared_command.dart' show SharedCompilerOptions; // ignore: uri_does_not_exist
11- import 'package:dev_compiler/src/kernel/target.dart' ; // ignore: uri_does_not_exist
12- import 'package:dev_compiler/src/kernel/command.dart' ; // ignore: uri_does_not_exist
13- import 'package:dev_compiler/src/kernel/compiler.dart' ; // ignore: uri_does_not_exist
14- import 'package:front_end/src/api_unstable/ddc.dart' show CompilerOptions, kernelForComponent;
12+ import 'package:dev_compiler/src/compiler/module_builder.dart' ;
13+ import 'package:dev_compiler/src/compiler/shared_command.dart'
14+ show SharedCompilerOptions;
15+ import 'package:dev_compiler/src/kernel/target.dart' ;
16+ import 'package:dev_compiler/src/kernel/command.dart' ;
17+ import 'package:dev_compiler/src/kernel/compiler.dart' ;
18+ import 'package:front_end/src/api_unstable/ddc.dart'
19+ show
20+ CompilerOptions,
21+ kernelForComponent,
22+ DiagnosticMessage,
23+ printDiagnosticMessage,
24+ Severity;
1525import 'package:kernel/kernel.dart' ;
1626import 'package:kernel/target/targets.dart' ;
1727import 'package:path/path.dart' as path;
@@ -36,14 +46,24 @@ Future main(List<String> args) async {
3646 }
3747
3848 var librarySpecPath = parserOptions['libraries' ] as String ;
49+ var packagesPath = path.join (ddcPath, '../third_party/dart/.packages' );
50+ void onDiagnostic (DiagnosticMessage message) {
51+ printDiagnosticMessage (message, print);
52+ if (message.severity == Severity .error ||
53+ message.severity == Severity .internalProblem) {
54+ exitCode = 1 ;
55+ }
56+ }
3957
4058 var target = FlutterDevCompilerTarget ();
4159 var options = CompilerOptions ()
4260 ..compileSdk = true
4361 // TODO(sigmund): remove this unnecessary option when possible.
4462 ..sdkRoot = Uri .base
63+ ..packagesFileUri = Uri .base .resolveUri (Uri .file (packagesPath))
4564 ..librariesSpecificationUri = Uri .base .resolveUri (Uri .file (librarySpecPath))
46- ..target = target;
65+ ..target = target
66+ ..onDiagnostic = onDiagnostic;
4767
4868 var inputs = target.extraRequiredLibraries.map (Uri .parse).toList ();
4969 var component = await kernelForComponent (inputs, options);
0 commit comments