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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <string.h> 6 #include <string.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "include/dart_api.h" 9 #include "include/dart_api.h"
10 #include "include/dart_debugger_api.h" 10 #include "include/dart_debugger_api.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 static bool IsValidFlag(const char* name, 74 static bool IsValidFlag(const char* name,
75 const char* prefix, 75 const char* prefix,
76 intptr_t prefix_length) { 76 intptr_t prefix_length) {
77 intptr_t name_length = strlen(name); 77 intptr_t name_length = strlen(name);
78 return ((name_length > prefix_length) && 78 return ((name_length > prefix_length) &&
79 (strncmp(name, prefix, prefix_length) == 0)); 79 (strncmp(name, prefix, prefix_length) == 0));
80 } 80 }
81 81
82 82
83 static bool has_version_option = false;
84 static bool ProcessVersionOption(const char* arg) {
85 if (*arg != '\0') {
86 return false;
87 }
88 has_version_option = true;
89 return true;
90 }
91
92
83 static bool has_help_option = false; 93 static bool has_help_option = false;
84 static bool ProcessHelpOption(const char* arg) { 94 static bool ProcessHelpOption(const char* arg) {
85 if (*arg != '\0') { 95 if (*arg != '\0') {
86 return false; 96 return false;
87 } 97 }
88 has_help_option = true; 98 has_help_option = true;
89 return true; 99 return true;
90 } 100 }
91 101
92 102
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 ASSERT(flow_graph_file != NULL); 199 ASSERT(flow_graph_file != NULL);
190 return true; 200 return true;
191 } 201 }
192 202
193 203
194 static struct { 204 static struct {
195 const char* option_name; 205 const char* option_name;
196 bool (*process)(const char* option); 206 bool (*process)(const char* option);
197 } main_options[] = { 207 } main_options[] = {
198 // Standard options shared with dart2js. 208 // Standard options shared with dart2js.
209 { "--version", ProcessVersionOption },
199 { "--help", ProcessHelpOption }, 210 { "--help", ProcessHelpOption },
200 { "-h", ProcessHelpOption }, 211 { "-h", ProcessHelpOption },
201 { "--verbose", ProcessVerboseOption }, 212 { "--verbose", ProcessVerboseOption },
202 { "-v", ProcessVerboseOption }, 213 { "-v", ProcessVerboseOption },
203 { "--package-root=", ProcessPackageRootOption }, 214 { "--package-root=", ProcessPackageRootOption },
204 { "-p", ProcessPackageRootOption }, 215 { "-p", ProcessPackageRootOption },
205 // VM specific options to the standalone dart program. 216 // VM specific options to the standalone dart program.
206 { "--break_at=", ProcessBreakpointOption }, 217 { "--break_at=", ProcessBreakpointOption },
207 { "--compile_all", ProcessCompileAllOption }, 218 { "--compile_all", ProcessCompileAllOption },
208 { "--debug", ProcessDebugOption }, 219 { "--debug", ProcessDebugOption },
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 const char* main, 512 const char* main,
502 void* data, char** error) { 513 void* data, char** error) {
503 return CreateIsolateAndSetupHelper(script_uri, 514 return CreateIsolateAndSetupHelper(script_uri,
504 main, 515 main,
505 false, // script_uri already canonical. 516 false, // script_uri already canonical.
506 new IsolateData(), 517 new IsolateData(),
507 error); 518 error);
508 } 519 }
509 520
510 521
522 static void PrintVersion() {
523 fprintf(stderr, "Dart VM version: %s\n", Dart_VersionString());
524 }
525
526
511 static void PrintUsage() { 527 static void PrintUsage() {
512 fprintf(stderr, 528 fprintf(stderr,
513 "Usage: dart [<vm-flags>] <dart-script-file> [<dart-options>]\n" 529 "Usage: dart [<vm-flags>] <dart-script-file> [<dart-options>]\n"
514 "\n" 530 "\n"
515 "Executes the Dart script passed as <dart-script-file>.\n" 531 "Executes the Dart script passed as <dart-script-file>.\n"
516 "\n"); 532 "\n");
517 if (!has_verbose_option) { 533 if (!has_verbose_option) {
518 fprintf(stderr, 534 fprintf(stderr,
519 "Common options:\n" 535 "Common options:\n"
520 "--checked Insert runtime type checks and enable assertions (checked mode).\n" 536 "--checked Insert runtime type checks and enable assertions (checked mode).\n"
537 "--version Print the VM version.\n"
521 "--help Display this message (add --verbose for information about all\n" 538 "--help Display this message (add --verbose for information about all\n"
522 " VM options).\n"); 539 " VM options).\n");
523 } else { 540 } else {
524 fprintf(stderr, 541 fprintf(stderr,
525 "Supported options:\n" 542 "Supported options:\n"
526 "--checked \n" 543 "--checked\n"
527 " Insert runtime type checks and enable assertions (checked mode).\n" 544 " Insert runtime type checks and enable assertions (checked mode).\n"
528 "\n" 545 "\n"
546 "--version\n"
547 " Print the VM version.\n"
548 "\n"
529 "--help\n" 549 "--help\n"
530 " Display this message (add --verbose for information about all VM options).\n" 550 " Display this message (add --verbose for information about all VM options).\n"
531 "\n" 551 "\n"
532 "--package-root=<path>\n" 552 "--package-root=<path>\n"
533 " Where to find packages, that is, \"package:...\" imports.\n" 553 " Where to find packages, that is, \"package:...\" imports.\n"
534 "\n" 554 "\n"
535 "--debug[:<port number>]\n" 555 "--debug[:<port number>]\n"
536 " enables debugging and listens on specified port for debugger connections\n" 556 " enables debugging and listens on specified port for debugger connections\n"
537 " (default port number is 5858)\n" 557 " (default port number is 5858)\n"
538 "\n" 558 "\n"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 } 661 }
642 662
643 // Parse command line arguments. 663 // Parse command line arguments.
644 if (ParseArguments(argc, 664 if (ParseArguments(argc,
645 argv, 665 argv,
646 &vm_options, 666 &vm_options,
647 &executable_name, 667 &executable_name,
648 &script_name, 668 &script_name,
649 &dart_options, 669 &dart_options,
650 &print_flags_seen) < 0) { 670 &print_flags_seen) < 0) {
651 if (print_flags_seen) { 671 if (has_help_option) {
672 PrintUsage();
673 return 0;
674 } else if (has_version_option) {
675 PrintVersion();
676 return 0;
677 } else if (print_flags_seen) {
652 // Will set the VM flags, print them out and then we exit as no 678 // Will set the VM flags, print them out and then we exit as no
653 // script was specified on the command line. 679 // script was specified on the command line.
654 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); 680 Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
655 return 0; 681 return 0;
656 } else { 682 } else {
657 PrintUsage(); 683 PrintUsage();
658 return kErrorExitCode; 684 return kErrorExitCode;
659 } 685 }
660 } 686 }
661 687
662 if (has_help_option) {
663 PrintUsage();
664 return 0;
665 }
666
667 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); 688 Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
668 689
669 // Initialize the Dart VM. 690 // Initialize the Dart VM.
670 if (!Dart_Initialize(CreateIsolateAndSetup, 691 if (!Dart_Initialize(CreateIsolateAndSetup,
671 NULL, 692 NULL,
672 ShutdownIsolate)) { 693 ShutdownIsolate)) {
673 return ErrorExit("VM initialization failed\n"); 694 return ErrorExit("VM initialization failed\n");
674 } 695 }
675 696
676 DartUtils::SetOriginalWorkingDirectory(); 697 DartUtils::SetOriginalWorkingDirectory();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 Dart_ExitScope(); 767 Dart_ExitScope();
747 // Dump symbol information for the profiler. 768 // Dump symbol information for the profiler.
748 DumpPprofSymbolInfo(); 769 DumpPprofSymbolInfo();
749 // Shutdown the isolate. 770 // Shutdown the isolate.
750 Dart_ShutdownIsolate(); 771 Dart_ShutdownIsolate();
751 // Terminate process exit-code handler. 772 // Terminate process exit-code handler.
752 Process::TerminateExitCodeHandler(); 773 Process::TerminateExitCodeHandler();
753 774
754 return 0; 775 return 0;
755 } 776 }
OLDNEW
« 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