Skip to content

Commit f44b7b5

Browse files
author
Jonah Williams
authored
Catch errors during production of kernel dill (#9248)
1 parent e7853df commit f44b7b5

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

web_sdk/flutter_kernel_sdk.dart

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,26 @@
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
58
import 'dart:async';
69
import 'dart:convert' show json;
710
import 'dart:io';
811
import '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;
1525
import 'package:kernel/kernel.dart';
1626
import 'package:kernel/target/targets.dart';
1727
import '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

Comments
 (0)