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

Unified Diff: runtime/bin/main.cc

Issue 11086065: - Generate a version string based on the VERSION file. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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: runtime/bin/main.cc
===================================================================
--- runtime/bin/main.cc (revision 13511)
+++ runtime/bin/main.cc (working copy)
@@ -80,6 +80,16 @@
}
+static bool has_version_option = false;
+static bool ProcessVersionOption(const char* arg) {
+ if (*arg != '\0') {
+ return false;
+ }
+ has_version_option = true;
+ return true;
+}
+
+
static bool has_help_option = false;
static bool ProcessHelpOption(const char* arg) {
if (*arg != '\0') {
@@ -196,6 +206,7 @@
bool (*process)(const char* option);
} main_options[] = {
// Standard options shared with dart2js.
+ { "--version", ProcessVersionOption },
{ "--help", ProcessHelpOption },
{ "-h", ProcessHelpOption },
{ "--verbose", ProcessVerboseOption },
@@ -508,6 +519,11 @@
}
+static void PrintVersion() {
+ fprintf(stderr, "Dart VM version: %s\n", Dart_VersionString());
+}
+
+
static void PrintUsage() {
fprintf(stderr,
"Usage: dart [<vm-flags>] <dart-script-file> [<dart-options>]\n"
@@ -518,14 +534,18 @@
fprintf(stderr,
"Common options:\n"
"--checked Insert runtime type checks and enable assertions (checked mode).\n"
+"--version Print the VM version.\n"
"--help Display this message (add --verbose for information about all\n"
" VM options).\n");
} else {
fprintf(stderr,
"Supported options:\n"
-"--checked \n"
+"--checked\n"
" Insert runtime type checks and enable assertions (checked mode).\n"
"\n"
+"--version\n"
+" Print the VM version.\n"
+"\n"
"--help\n"
" Display this message (add --verbose for information about all VM options).\n"
"\n"
@@ -648,7 +668,13 @@
&script_name,
&dart_options,
&print_flags_seen) < 0) {
- if (print_flags_seen) {
+ if (has_help_option) {
+ PrintUsage();
+ return 0;
+ } else if (has_version_option) {
+ PrintVersion();
+ return 0;
+ } else if (print_flags_seen) {
// Will set the VM flags, print them out and then we exit as no
// script was specified on the command line.
Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
@@ -659,11 +685,6 @@
}
}
- if (has_help_option) {
- PrintUsage();
- return 0;
- }
-
Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
// Initialize the Dart VM.
« no previous file with comments | « runtime/bin/bin.gypi ('k') | runtime/dart-runtime.gyp » ('j') | runtime/tools/make_version.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698