Index: tools/gn/gn_main.cc |
diff --git a/tools/gn/gn_main.cc b/tools/gn/gn_main.cc |
index 9c86ab5f01468947a8e958183ed35de5d507e6ec..bfd501064cf05c6ee82744b07c46aa7c7d2f2fcd 100644 |
--- a/tools/gn/gn_main.cc |
+++ b/tools/gn/gn_main.cc |
@@ -8,6 +8,15 @@ |
#include "tools/gn/commands.h" |
#include "tools/gn/err.h" |
#include "tools/gn/location.h" |
+#include "tools/gn/standard_out.h" |
+ |
+// Only the GN-generated build makes this header for now. |
+// TODO(brettw) consider adding this if we need it in GYP. |
+#if defined(GN_BUILD) |
+#include "build/util/last_change.h" |
+#else |
+#define LAST_CHANGE "UNKNOWN" |
+#endif |
namespace { |
@@ -39,6 +48,10 @@ int main(int argc, char** argv) { |
if (cmdline.HasSwitch("help")) { |
// Make "--help" default to help command. |
command = commands::kHelp; |
+ } else if (cmdline.HasSwitch("version")) { |
+ // Make "--version" print the version and exit. |
+ OutputString(std::string(LAST_CHANGE) + "\n"); |
+ exit(0); |
} else if (args.empty()) { |
command = commands::kGen; |
} else { |