49
49
50
50
namespace {
51
51
52
+ // / The version number of the current Ninja release. This will always
53
+ // / be "git" on trunk.
54
+ const char * kVersion = " git" ;
55
+
52
56
// / Global information passed into subtools.
53
57
struct Globals {
54
58
Globals () : state(new State()) {}
@@ -83,6 +87,7 @@ void Usage(const BuildConfig& config) {
83
87
" options:\n "
84
88
" -C DIR change to DIR before doing anything else\n "
85
89
" -f FILE specify input build file [default=build.ninja]\n "
90
+ " -V print ninja version (\" %s\" )\n "
86
91
" \n "
87
92
" -j N run N jobs in parallel [default=%d]\n "
88
93
" -l N do not start new jobs if the load average is greater than N\n "
@@ -94,7 +99,7 @@ void Usage(const BuildConfig& config) {
94
99
" -t TOOL run a subtool\n "
95
100
" use '-t list' to list subtools.\n "
96
101
" terminates toplevel options; further flags are passed to the tool.\n " ,
97
- config.parallelism );
102
+ kVersion , config.parallelism );
98
103
}
99
104
100
105
// / Choose a default value for the -j (parallelism) flag.
@@ -641,7 +646,7 @@ int main(int argc, char** argv) {
641
646
642
647
int opt;
643
648
while (tool.empty () &&
644
- (opt = getopt_long (argc, argv, " d:f:hj:k:l:nt:vC:" , kLongOptions ,
649
+ (opt = getopt_long (argc, argv, " d:f:hj:k:l:nt:vC:V " , kLongOptions ,
645
650
NULL )) != -1 ) {
646
651
switch (opt) {
647
652
case ' d' :
@@ -686,6 +691,9 @@ int main(int argc, char** argv) {
686
691
case ' C' :
687
692
working_dir = optarg ;
688
693
break ;
694
+ case ' V' :
695
+ printf (" %s\n " , kVersion );
696
+ return 0 ;
689
697
case ' h' :
690
698
default :
691
699
Usage (globals.config );
0 commit comments