diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-03-09 16:43:10 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-03-09 16:43:10 +0200 |
commit | 39a0e4230d9f79447755e765446f7fe6b897da99 (patch) | |
tree | ca7d387da1daa0d2c9eb9c53a6ca3a83e1f48c20 /build2/depdb | |
parent | 51267fc81abdbf0ca7f1098fccd7f3e0d7da5306 (diff) |
Use depdb in cxx.link rule
Diffstat (limited to 'build2/depdb')
-rw-r--r-- | build2/depdb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/build2/depdb b/build2/depdb index be45d91..74b6678 100644 --- a/build2/depdb +++ b/build2/depdb @@ -132,6 +132,43 @@ namespace build2 void write (char); + // Read the next line and compare it to the expected value. If it matches, + // return NULL. Otherwise, overwrite it and return the old value (which + // could also be NULL). This strange-sounding result semantics is used to + // detect the "there is a value but it does not match" case for tracing: + // + // if (string* o = d.expect (...)) + // l4 ([&]{trace << "X mismatch forcing update of " << t;}); + // + string* + expect (const string& v) + { + string* l (read ()); + if (l == nullptr || *l != v) + { + write (v); + return l; + } + + return nullptr; + } + + string* + expect (const path& v) {return expect (v.string ());} + + string* + expect (const char* v) + { + string* l (read ()); + if (l == nullptr || *l != v) + { + write (v); + return l; + } + + return nullptr; + } + private: void change (bool flush = true); |