Index: pkg/compiler/lib/src/dart2js.dart |
diff --git a/pkg/compiler/lib/src/dart2js.dart b/pkg/compiler/lib/src/dart2js.dart |
index ee9e612ee969aaaed603ec86f5b9edda50248552..9b2c0bef03855cc08973424a83a54596587173ec 100644 |
--- a/pkg/compiler/lib/src/dart2js.dart |
+++ b/pkg/compiler/lib/src/dart2js.dart |
@@ -105,16 +105,19 @@ Future<api.CompilationResult> compile(List<String> argv) { |
Uri libraryRoot = currentDirectory; |
Uri out = currentDirectory.resolve('out.js'); |
Uri sourceMapOut = currentDirectory.resolve('out.js.map'); |
+ Uri resolutionInput; |
Uri packageConfig = null; |
Uri packageRoot = null; |
List<String> options = new List<String>(); |
- bool explicitOut = false; |
+ List<String> explicitOutputArguments = <String>[]; |
bool wantHelp = false; |
bool wantVersion = false; |
String outputLanguage = 'JavaScript'; |
bool stripArgumentSet = false; |
bool analyzeOnly = false; |
bool analyzeAll = false; |
+ bool resolveOnly = false; |
+ Uri resolutionOutput = currentDirectory.resolve('out.data'); |
bool dumpInfo = false; |
bool allowNativeExtensions = false; |
bool trustTypeAnnotations = false; |
@@ -128,47 +131,47 @@ Future<api.CompilationResult> compile(List<String> argv) { |
diagnosticHandler = new FormattingDiagnosticHandler(inputProvider); |
Map<String, dynamic> environment = new Map<String, dynamic>(); |
- passThrough(String argument) => options.add(argument); |
+ void passThrough(String argument) => options.add(argument); |
if (BUILD_ID != null) { |
passThrough("--build-id=$BUILD_ID"); |
} |
- setLibraryRoot(String argument) { |
+ void setLibraryRoot(String argument) { |
libraryRoot = currentDirectory.resolve(extractPath(argument)); |
} |
- setPackageRoot(String argument) { |
+ void setPackageRoot(String argument) { |
packageRoot = currentDirectory.resolve(extractPath(argument)); |
} |
- setPackageConfig(String argument) { |
+ void setPackageConfig(String argument) { |
packageConfig = |
currentDirectory.resolve(extractPath(argument, isDirectory: false)); |
} |
- setOutput(Iterator<String> arguments) { |
- optionsImplyCompilation.add(arguments.current); |
+ void setOutput(Iterator<String> arguments) { |
+ explicitOutputArguments.add(arguments.current); |
String path; |
if (arguments.current == '-o') { |
if (!arguments.moveNext()) { |
helpAndFail('Error: Missing file after -o option.'); |
} |
+ explicitOutputArguments.add(arguments.current); |
path = arguments.current; |
} else { |
path = extractParameter(arguments.current); |
} |
- explicitOut = true; |
- out = currentDirectory.resolve(nativeToUriPath(path)); |
+ resolutionOutput = out = currentDirectory.resolve(nativeToUriPath(path)); |
sourceMapOut = Uri.parse('$out.map'); |
} |
- setOutputType(String argument) { |
+ void setOutputType(String argument) { |
optionsImplyCompilation.add(argument); |
if (argument == '--output-type=dart' || |
argument == '--output-type=dart-multi') { |
outputLanguage = OUTPUT_LANGUAGE_DART; |
- if (!explicitOut) { |
+ if (explicitOutputArguments.isNotEmpty) { |
out = currentDirectory.resolve('out.dart'); |
sourceMapOut = currentDirectory.resolve('out.dart.map'); |
} |
@@ -183,75 +186,84 @@ Future<api.CompilationResult> compile(List<String> argv) { |
passThrough(argument); |
} |
+ void setResolutionInput(String argument) { |
+ resolutionInput = |
+ currentDirectory.resolve(extractPath(argument, isDirectory: false)); |
+ } |
+ |
+ void setResolveOnly(String argument) { |
+ resolveOnly = true; |
+ passThrough(argument); |
+ } |
+ |
String getDepsOutput(Map<Uri, SourceFile> sourceFiles) { |
var filenames = sourceFiles.keys.map((uri) => '$uri').toList(); |
filenames.sort(); |
return filenames.join("\n"); |
} |
- setStrip(String argument) { |
+ void implyCompilation(String argument) { |
optionsImplyCompilation.add(argument); |
- stripArgumentSet = true; |
passThrough(argument); |
} |
- setAnalyzeOnly(String argument) { |
+ void setStrip(String argument) { |
+ stripArgumentSet = true; |
+ implyCompilation(argument); |
+ } |
+ |
+ void setAnalyzeOnly(String argument) { |
analyzeOnly = true; |
passThrough(argument); |
} |
- setAnalyzeAll(String argument) { |
+ void setAnalyzeAll(String argument) { |
analyzeAll = true; |
passThrough(argument); |
} |
- setAllowNativeExtensions(String argument) { |
+ void setAllowNativeExtensions(String argument) { |
allowNativeExtensions = true; |
passThrough(argument); |
} |
- setVerbose(_) { |
+ void setVerbose(_) { |
diagnosticHandler.verbose = true; |
passThrough('--verbose'); |
} |
- implyCompilation(String argument) { |
- optionsImplyCompilation.add(argument); |
- passThrough(argument); |
- } |
- |
- setDumpInfo(String argument) { |
+ void setDumpInfo(String argument) { |
implyCompilation(argument); |
dumpInfo = true; |
} |
- setTrustTypeAnnotations(String argument) { |
+ void setTrustTypeAnnotations(String argument) { |
trustTypeAnnotations = true; |
implyCompilation(argument); |
} |
- setTrustJSInteropTypeAnnotations(String argument) { |
+ void setTrustJSInteropTypeAnnotations(String argument) { |
trustJSInteropTypeAnnotations = true; |
implyCompilation(argument); |
} |
- setTrustPrimitives(String argument) { |
+ void setTrustPrimitives(String argument) { |
implyCompilation(argument); |
} |
- setCheckedMode(String argument) { |
+ void setCheckedMode(String argument) { |
checkedMode = true; |
passThrough(argument); |
} |
- addInEnvironment(String argument) { |
+ void addInEnvironment(String argument) { |
int eqIndex = argument.indexOf('='); |
String name = argument.substring(2, eqIndex); |
String value = argument.substring(eqIndex + 1); |
environment[name] = value; |
} |
- setCategories(String argument) { |
+ void setCategories(String argument) { |
List<String> categories = extractParameter(argument).split(','); |
if (categories.contains('all')) { |
categories = ["Client", "Server"]; |
@@ -274,7 +286,7 @@ Future<api.CompilationResult> compile(List<String> argv) { |
} |
} |
- handleShortOptions(String argument) { |
+ void handleShortOptions(String argument) { |
var shortOptions = argument.substring(1).split(""); |
for (var shortOption in shortOptions) { |
switch (shortOption) { |
@@ -343,6 +355,8 @@ Future<api.CompilationResult> compile(List<String> argv) { |
new OptionHandler(Flags.analyzeAll, setAnalyzeAll), |
new OptionHandler(Flags.analyzeOnly, setAnalyzeOnly), |
new OptionHandler(Flags.noSourceMaps, passThrough), |
+ new OptionHandler(Option.resolutionInput, setResolutionInput), |
+ new OptionHandler(Flags.resolveOnly, setResolveOnly), |
new OptionHandler(Flags.analyzeSignaturesOnly, setAnalyzeOnly), |
new OptionHandler(Flags.disableNativeLiveTypeAnalysis, passThrough), |
new OptionHandler('--categories=.*', setCategories), |
@@ -356,6 +370,7 @@ Future<api.CompilationResult> compile(List<String> argv) { |
new OptionHandler(Flags.useContentSecurityPolicy, passThrough), |
new OptionHandler(Flags.enableExperimentalMirrors, passThrough), |
new OptionHandler(Flags.enableAssertMessage, passThrough), |
+ |
// TODO(floitsch): remove conditional directives flag. |
// We don't provide the info-message yet, since we haven't publicly |
// launched the feature yet. |
@@ -428,18 +443,31 @@ Future<api.CompilationResult> compile(List<String> argv) { |
helpAndFail("Cannot specify both '--package-root' and '--packages."); |
} |
- if ((analyzeOnly || analyzeAll) && !optionsImplyCompilation.isEmpty) { |
- if (!analyzeOnly) { |
+ List<String> optionsImplyOutput = <String>[] |
+ ..addAll(optionsImplyCompilation) |
+ ..addAll(explicitOutputArguments); |
+ if (resolveOnly && !optionsImplyCompilation.isEmpty) { |
+ diagnosticHandler.info( |
+ "Options $optionsImplyCompilation indicate that compilation is " |
+ "expected, but compilation is turned off by the option " |
+ "'${Flags.resolveOnly}'.", |
+ api.Diagnostic.INFO); |
+ } else if ((analyzeOnly || analyzeAll) && !optionsImplyOutput.isEmpty) { |
+ if (analyzeAll && !analyzeOnly) { |
diagnosticHandler.info( |
"Option '${Flags.analyzeAll}' implies '${Flags.analyzeOnly}'.", |
api.Diagnostic.INFO); |
} |
diagnosticHandler.info( |
- "Options $optionsImplyCompilation indicate that output is expected, " |
+ "Options $optionsImplyOutput indicate that output is expected, " |
"but compilation is turned off by the option '${Flags.analyzeOnly}'.", |
api.Diagnostic.INFO); |
} |
- if (analyzeAll) analyzeOnly = true; |
+ if (resolveOnly) { |
+ analyzeOnly = analyzeAll = true; |
+ } else if (analyzeAll) { |
+ analyzeOnly = true; |
+ } |
if (!analyzeOnly) { |
if (allowNativeExtensions) { |
helpAndFail("Option '${Flags.allowNativeExtensions}' is only supported " |
@@ -456,7 +484,9 @@ Future<api.CompilationResult> compile(List<String> argv) { |
RandomAccessFileOutputProvider outputProvider = |
new RandomAccessFileOutputProvider(out, sourceMapOut, |
- onInfo: diagnosticHandler.info, onFailure: fail); |
+ onInfo: diagnosticHandler.info, |
+ onFailure: fail, |
+ resolutionOutput: resolveOnly ? resolutionOutput : null); |
api.CompilationResult compilationDone(api.CompilationResult result) { |
if (analyzeOnly) return result; |
@@ -477,7 +507,7 @@ Future<api.CompilationResult> compile(List<String> argv) { |
for (String filename in outputProvider.allOutputFiles) { |
print(" $filename"); |
} |
- } else if (!explicitOut) { |
+ } else if (explicitOutputArguments.isNotEmpty) { |
String input = uriPathToNative(arguments[0]); |
String output = relativize(currentDirectory, out, Platform.isWindows); |
print('Dart file ($input) compiled to $outputLanguage: $output'); |
@@ -492,10 +522,12 @@ Future<api.CompilationResult> compile(List<String> argv) { |
packageRoot: packageRoot, |
packageConfig: packageConfig, |
packagesDiscoveryProvider: findPackages, |
+ resolutionInput: resolutionInput, |
+ resolutionOutput: resolutionOutput, |
options: options, |
environment: environment); |
- return compileFunc(compilerOptions, inputProvider, |
- diagnosticHandler, outputProvider) |
+ return compileFunc( |
+ compilerOptions, inputProvider, diagnosticHandler, outputProvider) |
.then(compilationDone); |
} |