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

Side by Side Diff: pkg/compiler/bin/resolver.dart

Issue 2294753002: Handle parts as input in resolver. (Closed)
Patch Set: Updated cf. comments. Created 4 years, 3 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/constants/constant_constructors.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import 'dart:io'; 5 import 'dart:io';
6 6
7 import 'package:args/args.dart'; 7 import 'package:args/args.dart';
8 import 'package:compiler/src/apiimpl.dart';
9 import 'package:compiler/src/filenames.dart'; 8 import 'package:compiler/src/filenames.dart';
10 import 'package:compiler/src/null_compiler_output.dart'; 9
11 import 'package:compiler/src/options.dart'; 10 import 'package:compiler/src/dart2js_resolver.dart';
12 import 'package:compiler/src/serialization/json_serializer.dart';
13 import 'package:compiler/src/source_file_provider.dart';
14 import 'package:package_config/discovery.dart';
15 11
16 main(var argv) async { 12 main(var argv) async {
17 var parser = new ArgParser(); 13 var parser = new ArgParser();
18 parser.addOption('deps', abbr: 'd', allowMultiple: true); 14 parser.addOption('deps', abbr: 'd', allowMultiple: true);
19 parser.addOption('out', abbr: 'o'); 15 parser.addOption('out', abbr: 'o');
20 parser.addOption('library-root', abbr: 'l'); 16 parser.addOption('library-root', abbr: 'l');
21 parser.addOption('packages', abbr: 'p'); 17 parser.addOption('packages', abbr: 'p');
22 parser.addOption('bazel-paths', abbr: 'I', allowMultiple: true); 18 parser.addOption('bazel-paths', abbr: 'I', allowMultiple: true);
23 var args = parser.parse(argv); 19 var args = parser.parse(argv);
24 20
25 var resolutionInputs = args['deps']
26 .map((uri) => currentDirectory.resolve(nativeToUriPath(uri)))
27 .toList();
28 var root = args['library-root'];
29 var libraryRoot = root == null
30 ? Platform.script.resolve('../../../sdk/')
31 : currentDirectory.resolve(nativeToUriPath(root));
32
33 var options = new CompilerOptions(
34 libraryRoot: libraryRoot,
35 packageConfig: args['packages'] == null
36 ? null
37 : currentDirectory.resolve(args['packages']),
38 resolveOnly: true,
39 resolutionInputs: resolutionInputs,
40 packagesDiscoveryProvider: findPackages);
41
42 var bazelSearchPaths = args['bazel-paths'];
43 var inputProvider = bazelSearchPaths != null
44 ? new BazelInputProvider(bazelSearchPaths)
45 : new CompilerSourceFileProvider();
46
47 var outputProvider = const NullCompilerOutput();
48 var diagnostics = new FormattingDiagnosticHandler(inputProvider)
49 ..enableColors = true;
50 var compiler =
51 new CompilerImpl(inputProvider, outputProvider, diagnostics, options);
52
53 if (args.rest.isEmpty) { 21 if (args.rest.isEmpty) {
54 print('missing input files'); 22 print('missing input files');
55 exit(1); 23 exit(1);
56 } 24 }
57 25
58 var inputs = args.rest 26 var inputs = args.rest
59 .map((uri) => currentDirectory.resolve(nativeToUriPath(uri))) 27 .map((uri) => currentDirectory.resolve(nativeToUriPath(uri)))
60 .toList(); 28 .toList();
61 29
62 await compiler.setupSdk(); 30 var text = await resolve(
63 await compiler.setupPackages(inputs.first); 31 inputs,
64 32 deps: args['deps'],
65 for (var library in inputs) { 33 root: args['library-root'],
66 await compiler.libraryLoader.loadLibrary(library); 34 packages: args['packages'],
67 } 35 bazelSearchPaths: args['bazel-paths']);
68
69 for (var library in inputs) {
70 compiler.fullyEnqueueLibrary(compiler.libraryLoader.lookupLibrary(library),
71 compiler.enqueuer.resolution);
72 }
73
74 compiler.processQueue(compiler.enqueuer.resolution, null);
75
76 var librariesToSerialize =
77 inputs.map((lib) => compiler.libraryLoader.lookupLibrary(lib)).toList();
78
79 var serializer =
80 compiler.serialization.createSerializer(librariesToSerialize);
81 var text = serializer.toText(const JsonSerializationEncoder());
82 36
83 var outFile = args['out'] ?? 'out.data'; 37 var outFile = args['out'] ?? 'out.data';
84 38
85 await new File(outFile).writeAsString(text); 39 await new File(outFile).writeAsString(text);
86 } 40 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/constants/constant_constructors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698