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

Unified Diff: pkg/compiler/lib/src/dart2js_resolver.dart

Issue 2294753002: Handle parts as input in resolver. (Closed)
Patch Set: Updated cf. comments. Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/dart2js_resolver.dart
diff --git a/pkg/compiler/bin/resolver.dart b/pkg/compiler/lib/src/dart2js_resolver.dart
similarity index 51%
copy from pkg/compiler/bin/resolver.dart
copy to pkg/compiler/lib/src/dart2js_resolver.dart
index d5b56da25d3c58093f18c0855fcf61658755ec48..2bf460eefd9c656c880d0a2b4014598b39000db7 100644
--- a/pkg/compiler/bin/resolver.dart
+++ b/pkg/compiler/lib/src/dart2js_resolver.dart
@@ -3,8 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
import 'dart:io';
+import 'dart:async';
-import 'package:args/args.dart';
import 'package:compiler/src/apiimpl.dart';
import 'package:compiler/src/filenames.dart';
import 'package:compiler/src/null_compiler_output.dart';
@@ -13,74 +13,60 @@ import 'package:compiler/src/serialization/json_serializer.dart';
import 'package:compiler/src/source_file_provider.dart';
import 'package:package_config/discovery.dart';
-main(var argv) async {
- var parser = new ArgParser();
- parser.addOption('deps', abbr: 'd', allowMultiple: true);
- parser.addOption('out', abbr: 'o');
- parser.addOption('library-root', abbr: 'l');
- parser.addOption('packages', abbr: 'p');
- parser.addOption('bazel-paths', abbr: 'I', allowMultiple: true);
- var args = parser.parse(argv);
-
- var resolutionInputs = args['deps']
+Future<String> resolve(List<Uri> inputs,
+ {List<String> deps: const <String>[],
+ List<String> bazelSearchPaths,
+ String root,
+ String packages,
+ Uri packageRoot,
+ String platformConfig}) async {
+ var resolutionInputs = deps
.map((uri) => currentDirectory.resolve(nativeToUriPath(uri)))
.toList();
- var root = args['library-root'];
var libraryRoot = root == null
? Platform.script.resolve('../../../sdk/')
: currentDirectory.resolve(nativeToUriPath(root));
var options = new CompilerOptions(
libraryRoot: libraryRoot,
- packageConfig: args['packages'] == null
- ? null
- : currentDirectory.resolve(args['packages']),
resolveOnly: true,
+ analyzeMain: true,
resolutionInputs: resolutionInputs,
- packagesDiscoveryProvider: findPackages);
+ packageRoot: packageRoot,
+ packageConfig:
+ packages != null ? currentDirectory.resolve(packages) : null,
+ packagesDiscoveryProvider: findPackages,
+ platformConfigUri:
+ platformConfig != null ? libraryRoot.resolve(platformConfig) : null);
- var bazelSearchPaths = args['bazel-paths'];
var inputProvider = bazelSearchPaths != null
? new BazelInputProvider(bazelSearchPaths)
: new CompilerSourceFileProvider();
var outputProvider = const NullCompilerOutput();
var diagnostics = new FormattingDiagnosticHandler(inputProvider)
- ..enableColors = true;
+ ..enableColors = !Platform.isWindows;
var compiler =
new CompilerImpl(inputProvider, outputProvider, diagnostics, options);
- if (args.rest.isEmpty) {
- print('missing input files');
- exit(1);
- }
-
- var inputs = args.rest
- .map((uri) => currentDirectory.resolve(nativeToUriPath(uri)))
- .toList();
-
await compiler.setupSdk();
await compiler.setupPackages(inputs.first);
- for (var library in inputs) {
- await compiler.libraryLoader.loadLibrary(library);
+ var librariesToSerialize = [];
+ for (var uri in inputs) {
+ var library = await compiler.analyzeUri(uri);
+ if (library != null) {
+ // [library] is `null` if [uri] is a part file.
+ librariesToSerialize.add(library);
+ }
}
- for (var library in inputs) {
- compiler.fullyEnqueueLibrary(compiler.libraryLoader.lookupLibrary(library),
- compiler.enqueuer.resolution);
+ if (librariesToSerialize.isEmpty) {
+ print('no library input files');
+ exit(1);
}
- compiler.processQueue(compiler.enqueuer.resolution, null);
-
- var librariesToSerialize =
- inputs.map((lib) => compiler.libraryLoader.lookupLibrary(lib)).toList();
-
var serializer =
compiler.serialization.createSerializer(librariesToSerialize);
- var text = serializer.toText(const JsonSerializationEncoder());
-
- var outFile = args['out'] ?? 'out.data';
-
- await new File(outFile).writeAsString(text);
+ return serializer.toText(const JsonSerializationEncoder());
}
« no previous file with comments | « pkg/compiler/lib/src/constants/constant_constructors.dart ('k') | tests/compiler/dart2js/analyze_test_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698