aboutsummaryrefslogtreecommitdiff
path: root/ninja.cc
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2016-10-03 00:16:07 -0700
committerDan Willemsen <dwillemsen@google.com>2016-10-03 21:57:39 -0700
commitf06d8019e99ae6aee1d2881f30315aee7b544cfb (patch)
tree220de431495546566c2d01b931173c0d15af3d16 /ninja.cc
parent5e45e973c38c92c42cc86aa5dafeca13e6823b5f (diff)
Implement the `file` function to read and write files
This allows us to do file reading and writing without $(shell). Besides being simpler, this also allows faster regen times, since we can just stat the files to be read, or directly write to the files that need to be written.
Diffstat (limited to 'ninja.cc')
-rw-r--r--ninja.cc36
1 files changed, 16 insertions, 20 deletions
diff --git a/ninja.cc b/ninja.cc
index 90fe404..59e8712 100644
--- a/ninja.cc
+++ b/ninja.cc
@@ -736,31 +736,27 @@ class NinjaGenerator {
const vector<CommandResult*>& crs = GetShellCommandResults();
DumpInt(fp, crs.size());
for (CommandResult* cr : crs) {
+ DumpInt(fp, static_cast<int>(cr->op));
DumpString(fp, cr->shell);
DumpString(fp, cr->cmd);
DumpString(fp, cr->result);
- if (!cr->find.get()) {
- // Always re-run this command.
- DumpInt(fp, 0);
- continue;
- }
- DumpInt(fp, 1);
-
- vector<string> missing_dirs;
- for (StringPiece fd : cr->find->finddirs) {
- const string& d = ConcatDir(cr->find->chdir, fd);
- if (!Exists(d))
- missing_dirs.push_back(d);
- }
- DumpInt(fp, missing_dirs.size());
- for (const string& d : missing_dirs) {
- DumpString(fp, d);
- }
+ if (cr->op == CommandOp::FIND) {
+ vector<string> missing_dirs;
+ for (StringPiece fd : cr->find->finddirs) {
+ const string& d = ConcatDir(cr->find->chdir, fd);
+ if (!Exists(d))
+ missing_dirs.push_back(d);
+ }
+ DumpInt(fp, missing_dirs.size());
+ for (const string& d : missing_dirs) {
+ DumpString(fp, d);
+ }
- DumpInt(fp, cr->find->read_dirs->size());
- for (StringPiece s : *cr->find->read_dirs) {
- DumpString(fp, ConcatDir(cr->find->chdir, s));
+ DumpInt(fp, cr->find->read_dirs->size());
+ for (StringPiece s : *cr->find->read_dirs) {
+ DumpString(fp, ConcatDir(cr->find->chdir, s));
+ }
}
}