Index: pkg/compiler/lib/src/dart2js.dart |
diff --git a/pkg/compiler/lib/src/dart2js.dart b/pkg/compiler/lib/src/dart2js.dart |
index 93b9a19112f50bc242189787544d1bda51df7692..9db2af57cf29119b7fbd38b927137eb6456363a9 100644 |
--- a/pkg/compiler/lib/src/dart2js.dart |
+++ b/pkg/compiler/lib/src/dart2js.dart |
@@ -19,6 +19,7 @@ import 'util/uri_extras.dart'; |
import 'util/util.dart' show stackTraceFilePrefix; |
import 'util/command_line.dart'; |
import 'package:_internal/libraries.dart'; |
+import 'package:package_config/discovery.dart' show findPackages; |
const String LIBRARY_ROOT = '../../../../../sdk'; |
const String OUTPUT_LANGUAGE_DART = 'Dart'; |
@@ -105,6 +106,7 @@ Future<api.CompilationResult> compile(List<String> argv) { |
Uri libraryRoot = currentDirectory; |
Uri out = currentDirectory.resolve('out.js'); |
Uri sourceMapOut = currentDirectory.resolve('out.js.map'); |
+ Uri packageConfig = null; |
Uri packageRoot = null; |
List<String> options = new List<String>(); |
bool explicitOut = false; |
@@ -140,6 +142,10 @@ Future<api.CompilationResult> compile(List<String> argv) { |
packageRoot = currentDirectory.resolve(extractPath(argument)); |
} |
+ setPackageConfig(String argument) { |
+ packageConfig = currentDirectory.resolve(extractPath(argument)); |
+ } |
+ |
setOutput(Iterator<String> arguments) { |
optionsImplyCompilation.add(arguments.current); |
String path; |
@@ -329,6 +335,7 @@ Future<api.CompilationResult> compile(List<String> argv) { |
(_) => setTrustPrimitives( |
'--trust-primitives')), |
new OptionHandler(r'--help|/\?|/h', (_) => wantHelp = true), |
+ new OptionHandler('--packages=.+', setPackageConfig), |
new OptionHandler('--package-root=.+|-p.+', setPackageRoot), |
new OptionHandler('--analyze-all', setAnalyzeAll), |
new OptionHandler('--analyze-only', setAnalyzeOnly), |
@@ -404,9 +411,8 @@ Future<api.CompilationResult> compile(List<String> argv) { |
"checked mode."); |
} |
- Uri uri = currentDirectory.resolve(arguments[0]); |
- if (packageRoot == null) { |
- packageRoot = uri.resolve('./packages/'); |
+ if (packageRoot != null && packageConfig != null) { |
+ helpAndFail("Cannot specify both '--package-root' and '--packages."); |
} |
if ((analyzeOnly || analyzeAll) && !optionsImplyCompilation.isEmpty) { |
@@ -432,8 +438,6 @@ Future<api.CompilationResult> compile(List<String> argv) { |
"combination with the '--output-type=dart' option."); |
} |
- diagnosticHandler.info('Package root is $packageRoot'); |
- |
options.add('--out=$out'); |
options.add('--source-map=$sourceMapOut'); |
@@ -468,9 +472,10 @@ Future<api.CompilationResult> compile(List<String> argv) { |
return result; |
} |
- return compileFunc(uri, libraryRoot, packageRoot, |
- inputProvider, diagnosticHandler, |
- options, outputProvider, environment) |
+ Uri uri = currentDirectory.resolve(arguments[0]); |
+ return compileFunc(uri, libraryRoot, packageRoot, inputProvider, |
+ diagnosticHandler, options, outputProvider, environment, |
+ packageConfig, findPackages) |
.then(compilationDone); |
} |
@@ -552,7 +557,12 @@ Supported options: |
Display version information. |
-p<path>, --package-root=<path> |
- Where to find packages, that is, "package:..." imports. |
+ Where to find packages, that is, "package:..." imports. This option cannot |
+ be used with --packages. |
+ |
+ --packages=<path> |
+ Path to the package resolution configuration file, which supplies a mapping |
+ of package names to paths. This option cannot be used with --package-root. |
--analyze-all |
Analyze all code. Without this option, the compiler only analyzes |