Chromium Code Reviews| Index: pkg/compiler/bin/resolver.dart |
| diff --git a/pkg/compiler/bin/resolver.dart b/pkg/compiler/bin/resolver.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cb58a48ff649474b79c966091028546bbcf847f1 |
| --- /dev/null |
| +++ b/pkg/compiler/bin/resolver.dart |
| @@ -0,0 +1,65 @@ |
| +// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +import 'dart:io'; |
| + |
| +import 'package:args/args.dart'; |
| +import 'package:compiler/src/apiimpl.dart'; |
| +import 'package:compiler/src/dart2js.dart'; |
| +import 'package:compiler/src/filenames.dart'; |
| +import 'package:compiler/src/null_compiler_output.dart'; |
| +import 'package:compiler/src/source_file_provider.dart'; |
| +import 'package:compiler/src/options.dart'; |
| +import 'package:compiler/src/serialization/json_serializer.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'); |
| + var args = parser.parse(argv); |
| + |
| + var resolutionInputs = |
| + args['deps'].map((uri) => currentDirectory.resolve(uri)).toList(); |
|
Johnni Winther
2016/05/30 11:09:54
Use `currentDirectory.resolve(nativeToUriPath(uri)
Harry Terkelsen
2016/05/31 16:28:26
Done.
|
| + var root = uriPathToNative("../../../sdk"); |
|
Johnni Winther
2016/05/30 11:09:54
This should be [nativeToUriPath], otherwise on Win
Harry Terkelsen
2016/05/31 16:28:27
Done.
Siggi Cherem (dart-lang)
2016/06/02 00:20:36
Actually here it was already in URL form, seems li
Johnni Winther
2016/06/02 07:41:10
Correct
|
| + var libraryRoot = Platform.script.resolve("$root/"); |
| + var options = new CompilerOptions( |
| + libraryRoot: libraryRoot, |
| + resolveOnly: true, |
| + resolutionInputs: resolutionInputs, |
| + packagesDiscoveryProvider: findPackages); |
| + var inputProvider = new CompilerSourceFileProvider(); |
| + var outputProvider = const NullCompilerOutput(); |
| + var diagnostics = new FormattingDiagnosticHandler(inputProvider); |
| + |
| + var compiler = |
| + new CompilerImpl(inputProvider, outputProvider, diagnostics, options); |
| + |
| + var inputs = args.rest.map((uri) => currentDirectory.resolve(uri)).toList(); |
|
Johnni Winther
2016/05/30 11:09:54
Use `nativeToUriPath` here as well.
Harry Terkelsen
2016/05/31 16:28:26
Done.
|
| + |
| + await compiler.setupSdk(); |
| + await compiler.setupPackages(inputs.first); |
| + |
| + for (var library in inputs) { |
| + await compiler.libraryLoader.loadLibrary(library); |
| + } |
| + |
| + for (var library in inputs) { |
| + compiler.fullyEnqueueLibrary(compiler.libraryLoader.lookupLibrary(library), |
| + compiler.enqueuer.resolution); |
| + } |
| + |
| + 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.json'; |
| + |
| + await new File(outFile).writeAsString(text); |
| +} |