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

Unified Diff: sdk/lib/_internal/compiler/implementation/dart2js.dart

Issue 16114013: Reland "Add --version option to dart2js and add version information (if available) to generated cod… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix formatting. Created 7 years, 7 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: sdk/lib/_internal/compiler/implementation/dart2js.dart
diff --git a/sdk/lib/_internal/compiler/implementation/dart2js.dart b/sdk/lib/_internal/compiler/implementation/dart2js.dart
index 8d3c7da267dd827a5c2765fd143b337892ddbe12..c4242ca84a84ef86f37b7d37e74410a8ef976ae5 100644
--- a/sdk/lib/_internal/compiler/implementation/dart2js.dart
+++ b/sdk/lib/_internal/compiler/implementation/dart2js.dart
@@ -86,6 +86,7 @@ void compile(List<String> argv) {
List<String> options = new List<String>();
bool explicitOut = false;
bool wantHelp = false;
+ bool wantVersion = false;
String outputLanguage = 'JavaScript';
bool stripArgumentSet = false;
bool analyzeOnly = false;
@@ -197,6 +198,7 @@ void compile(List<String> argv) {
(_) => diagnosticHandler.showWarnings = false),
new OptionHandler('--output-type=dart|--output-type=js', setOutputType),
new OptionHandler('--verbose', setVerbose),
+ new OptionHandler('--version', (_) => wantVersion = true),
new OptionHandler('--library-root=.+', setLibraryRoot),
new OptionHandler('--out=.+|-o.+', setOutput),
new OptionHandler('--allow-mock-compilation', passThrough),
@@ -235,7 +237,9 @@ void compile(List<String> argv) {
];
parseCommandLine(handlers, argv);
- if (wantHelp) helpAndExit(diagnosticHandler.verbose);
+ if (wantHelp || wantVersion) {
+ helpAndExit(wantHelp, wantVersion, diagnosticHandler.verbose);
+ }
if (outputLanguage != OUTPUT_LANGUAGE_DART && stripArgumentSet) {
helpAndFail('Error: --force-strip may only be used with '
@@ -413,6 +417,9 @@ Supported options:
-v, --verbose
Display verbose information.
+ --version
+ Display version information.
+
-p<path>, --package-root=<path>
Where to find packages, that is, "package:..." imports.
@@ -487,11 +494,19 @@ be removed in a future version:
'''.trim());
}
-void helpAndExit(bool verbose) {
- if (verbose) {
- verboseHelp();
- } else {
- help();
+void helpAndExit(bool wantHelp, bool wantVersion, bool verbose) {
+ if (wantVersion) {
+ var version = (BUILD_ID == null)
+ ? '<non-SDK build>'
+ : BUILD_ID;
+ print('Dart-to-JavaScript compiler (dart2js) version: $version');
+ }
+ if (wantHelp) {
+ if (verbose) {
+ verboseHelp();
+ } else {
+ help();
+ }
}
exit(0);
}

Powered by Google App Engine
This is Rietveld 408576698