Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1148)

Side by Side Diff: pkg/compiler/tool/generate_kernel.dart

Issue 2953703002: Tweak public APIs and use them in patch_sdk, dart2js, and kernel-service (Closed)
Patch Set: cl review updates: cleanup in kernel deserialization Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// Helper to run fasta with the right target configuration to build dart2js 5 /// Helper to run fasta with the right target configuration to build dart2js
6 /// applications using the dart2js platform libraries. 6 /// applications using the dart2js platform libraries.
7 // TODO(sigmund): delete this file once we can configure fasta directly on the 7 // TODO(sigmund): delete this file once we can configure fasta directly on the
8 // command line. 8 // command line.
9 library compiler.tool.generate_kernel; 9 library compiler.tool.generate_kernel;
10 10
11 import 'dart:io' show exitCode; 11 import 'dart:io';
12 12
13 import 'package:front_end/src/fasta/compiler_command_line.dart' 13 import 'package:args/args.dart';
14 show CompilerCommandLine; 14 import 'package:compiler/src/kernel/dart2js_target.dart';
15 import 'package:front_end/src/fasta/compiler_context.dart' show CompilerContext; 15 import 'package:front_end/front_end.dart';
16 import 'package:front_end/src/fasta/errors.dart' show InputError; 16 import 'package:front_end/src/fasta/util/relativize.dart';
17 import 'package:front_end/src/fasta/ticker.dart' show Ticker; 17 import 'package:kernel/kernel.dart';
18 import 'package:compiler/src/kernel/fasta_support.dart' show Dart2jsCompileTask; 18 import 'package:kernel/target/targets.dart';
19 19
20 main(List<String> arguments) async { 20 main(List<String> args) async {
21 try { 21 ArgResults flags = _argParser.parse(args);
22 await CompilerCommandLine.withGlobalOptions("generate_kernel", arguments, 22 var options = new CompilerOptions()
23 (CompilerContext c) async { 23 ..target = new Dart2jsTarget(new TargetFlags())
24 if (c.options.verbose) { 24 ..packagesFileUri = Platform.script.resolve('../../../.packages')
25 print("Compiling directly to Kernel: ${arguments.join(' ')}"); 25 ..linkedDependencies = [Uri.base.resolve(flags['platform'])]
26 } 26 ..onError = errorHandler;
27 var task = 27
28 new Dart2jsCompileTask(c, new Ticker(isVerbose: c.options.verbose)); 28 if (flags.rest.isEmpty) {
29 await task.compile(); 29 var script = relativizeUri(Platform.script);
30 }); 30 var platform = relativizeUri(Uri.base.resolve(flags['platform']));
31 } on InputError catch (e) { 31 print('usage: ${Platform.executable} $script '
32 exitCode = 1; 32 '[--platform=$platform] [--out=out.dill] program.dart');
33 print(e.format()); 33 exit(1);
34 return null;
35 } 34 }
35
36 Uri entry = Uri.base.resolve(flags.rest.first);
37 var program = await kernelForProgram(entry, options);
38 program.uriToSource.clear();
39 await writeProgramToBinary(program, flags['out']);
36 } 40 }
41
42 void errorHandler(CompilationError e) {
43 exitCode = 1;
44 print(e.message);
45 }
46
47 ArgParser _argParser = new ArgParser()
48 ..addOption('platform',
49 help: 'location of the precompiled dart2js sdk',
50 defaultsTo: _defaultPlatform)
51 ..addOption('out',
52 abbr: 'o', help: 'output location', defaultsTo: 'out.dill');
53
54 String _defaultPlatform = Uri
55 .parse(Platform.resolvedExecutable)
56 .resolve('patched_dart2js_sdk/platform.dill')
57 .toString();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698