summaryrefslogtreecommitdiffstats
path: root/src/ninja.cc
diff options
context:
space:
mode:
authorJan Niklas Hasse <jhasse@bixense.com>2020-01-16 22:10:52 (GMT)
committerJan Niklas Hasse <jhasse@bixense.com>2020-01-16 22:10:52 (GMT)
commitd47e1eb00d2eac4a3b864639ab972a53e60f4925 (patch)
tree90aada012686ab9f16128ea55c238ce6ecfae4d2 /src/ninja.cc
parent26fc40c59a5630bf1429f8df90bb9352c7b593a0 (diff)
downloadNinja-d47e1eb00d2eac4a3b864639ab972a53e60f4925.zip
Ninja-d47e1eb00d2eac4a3b864639ab972a53e60f4925.tar.gz
Ninja-d47e1eb00d2eac4a3b864639ab972a53e60f4925.tar.bz2
restat: Accept list of outputs to restat (none means all)
This will become handy when the generator only wants to restat the build.ninja entry in the log. See #1718.
Diffstat (limited to 'src/ninja.cc')
-rw-r--r--src/ninja.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/ninja.cc b/src/ninja.cc
index 08f717f..b122cb6 100644
--- a/src/ninja.cc
+++ b/src/ninja.cc
@@ -859,6 +859,24 @@ int NinjaMain::ToolRecompact(const Options* options, int argc, char* argv[]) {
}
int NinjaMain::ToolRestat(const Options* options, int argc, char* argv[]) {
+ // The restat tool uses getopt, and expects argv[0] to contain the name of the
+ // tool, i.e. "restat"
+ argc++;
+ argv--;
+
+ optind = 1;
+ int opt;
+ while ((opt = getopt(argc, argv, const_cast<char*>("h"))) != -1) {
+ switch (opt) {
+ case 'h':
+ default:
+ printf("usage: ninja -t restat [outputs]\n");
+ return 1;
+ }
+ }
+ argv += optind;
+ argc -= optind;
+
if (!EnsureBuildDirExists())
return 1;
@@ -882,7 +900,7 @@ int NinjaMain::ToolRestat(const Options* options, int argc, char* argv[]) {
err.clear();
}
- bool success = build_log_.Restat(log_path, disk_interface_, &err);
+ bool success = build_log_.Restat(log_path, disk_interface_, argc, argv, &err);
if (!success) {
Error("failed recompaction: %s", err.c_str());
return EXIT_FAILURE;