Skip to content

Commit 3b0e78a

Browse files
committed
include version number
1 parent d73af72 commit 3b0e78a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/ninja.cc

+10-2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949

5050
namespace {
5151

52+
/// The version number of the current Ninja release. This will always
53+
/// be "git" on trunk.
54+
const char* kVersion = "git";
55+
5256
/// Global information passed into subtools.
5357
struct Globals {
5458
Globals() : state(new State()) {}
@@ -83,6 +87,7 @@ void Usage(const BuildConfig& config) {
8387
"options:\n"
8488
" -C DIR change to DIR before doing anything else\n"
8589
" -f FILE specify input build file [default=build.ninja]\n"
90+
" -V print ninja version (\"%s\")\n"
8691
"\n"
8792
" -j N run N jobs in parallel [default=%d]\n"
8893
" -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) {
9499
" -t TOOL run a subtool\n"
95100
" use '-t list' to list subtools.\n"
96101
" terminates toplevel options; further flags are passed to the tool.\n",
97-
config.parallelism);
102+
kVersion, config.parallelism);
98103
}
99104

100105
/// Choose a default value for the -j (parallelism) flag.
@@ -641,7 +646,7 @@ int main(int argc, char** argv) {
641646

642647
int opt;
643648
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,
645650
NULL)) != -1) {
646651
switch (opt) {
647652
case 'd':
@@ -686,6 +691,9 @@ int main(int argc, char** argv) {
686691
case 'C':
687692
working_dir = optarg;
688693
break;
694+
case 'V':
695+
printf("%s\n", kVersion);
696+
return 0;
689697
case 'h':
690698
default:
691699
Usage(globals.config);

0 commit comments

Comments
 (0)