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..fc6fda6446496f08e1203f6d66ac62e91c62c598 100644 |
--- a/pkg/compiler/lib/src/dart2js.dart |
+++ b/pkg/compiler/lib/src/dart2js.dart |
@@ -105,6 +105,8 @@ Future<api.CompilationResult> compile(List<String> argv) { |
Uri libraryRoot = currentDirectory; |
Uri out = currentDirectory.resolve('out.js'); |
Uri sourceMapOut = currentDirectory.resolve('out.js.map'); |
+ Uri serializationSource; |
+ Uri serializationTarget; |
Uri packageConfig = null; |
Uri packageRoot = null; |
List<String> options = new List<String>(); |
@@ -128,26 +130,26 @@ 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) { |
+ void setOutput(Iterator<String> arguments) { |
optionsImplyCompilation.add(arguments.current); |
String path; |
if (arguments.current == '-o') { |
@@ -163,7 +165,7 @@ Future<api.CompilationResult> compile(List<String> argv) { |
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') { |
@@ -183,75 +185,85 @@ Future<api.CompilationResult> compile(List<String> argv) { |
passThrough(argument); |
} |
+ void setSerializationSource(String argument) { |
+ serializationSource = |
+ currentDirectory.resolve(extractPath(argument, isDirectory: false)); |
+ } |
+ |
+ void setSerializationTarget(String argument) { |
+ serializationTarget = |
+ currentDirectory.resolve(extractPath(argument, isDirectory: false)); |
+ } |
+ |
String getDepsOutput(Map<Uri, SourceFile> sourceFiles) { |
var filenames = sourceFiles.keys.map((uri) => '$uri').toList(); |
filenames.sort(); |
return filenames.join("\n"); |
} |
- setStrip(String argument) { |
+ void setStrip(String argument) { |
optionsImplyCompilation.add(argument); |
stripArgumentSet = true; |
passThrough(argument); |
} |
- setAnalyzeOnly(String 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) { |
+ void 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.serializationSource, setSerializationSource), |
+ new OptionHandler(Option.serializationTarget, setSerializationTarget), |
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. |
@@ -446,6 +461,12 @@ Future<api.CompilationResult> compile(List<String> argv) { |
"in combination with the '${Flags.analyzeOnly}' option."); |
} |
} |
+ if (!analyzeAll) { |
+ if (serializationTarget != null) { |
+ helpAndFail("Option '${Option.serializationTarget}' is only supported " |
Siggi Cherem (dart-lang)
2016/05/14 01:10:31
I'd be OK implying it (instead of requiring that w
Johnni Winther
2016/05/17 12:37:33
Done.
|
+ "in combination with the '${Flags.analyzeAll}' option."); |
+ } |
+ } |
if (dumpInfo && outputLanguage == OUTPUT_LANGUAGE_DART) { |
helpAndFail("Option '${Flags.dumpInfo}' is not supported in " |
"combination with the '--output-type=dart' option."); |
@@ -456,7 +477,9 @@ Future<api.CompilationResult> compile(List<String> argv) { |
RandomAccessFileOutputProvider outputProvider = |
new RandomAccessFileOutputProvider(out, sourceMapOut, |
- onInfo: diagnosticHandler.info, onFailure: fail); |
+ onInfo: diagnosticHandler.info, |
+ onFailure: fail, |
+ serializationTarget: serializationTarget); |
api.CompilationResult compilationDone(api.CompilationResult result) { |
if (analyzeOnly) return result; |
@@ -492,10 +515,12 @@ Future<api.CompilationResult> compile(List<String> argv) { |
packageRoot: packageRoot, |
packageConfig: packageConfig, |
packagesDiscoveryProvider: findPackages, |
+ serializationSource: serializationSource, |
+ serializationTarget: serializationTarget, |
options: options, |
environment: environment); |
- return compileFunc(compilerOptions, inputProvider, |
- diagnosticHandler, outputProvider) |
+ return compileFunc( |
+ compilerOptions, inputProvider, diagnosticHandler, outputProvider) |
.then(compilationDone); |
} |