From 39a0e4230d9f79447755e765446f7fe6b897da99 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 9 Mar 2016 16:43:10 +0200 Subject: Use depdb in cxx.link rule --- build2/depdb | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'build2/depdb') 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); -- cgit v1.1