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/cxx/compile.cxx | 88 +++++++++++++++++--------------------------------- 1 file changed, 29 insertions(+), 59 deletions(-) (limited to 'build2/cxx/compile.cxx') diff --git a/build2/cxx/compile.cxx b/build2/cxx/compile.cxx index 2d42cbc..2b37250 100644 --- a/build2/cxx/compile.cxx +++ b/build2/cxx/compile.cxx @@ -161,78 +161,48 @@ namespace build2 // First should come the rule name/version. // - string* dl (dd.read ()); - if (dl == nullptr || *dl != "cxx.compile 1") - { - dd.write ("cxx.compile 1"); - - if (dl != nullptr) - l4 ([&]{trace << "rule mismatch forcing update of " << t;}); - } + if (dd.expect ("cxx.compile 1") != nullptr) + l4 ([&]{trace << "rule mismatch forcing update of " << t;}); // Then the compiler checksum. // - { - const string& cs (as (*rs["cxx.checksum"])); - - dl = dd.read (); - if (dl == nullptr || *dl != cs) - { - dd.write (cs); - - if (dl != nullptr) - l4 ([&]{trace << "compiler mismatch forcing update of " << t;}); - } - } + if (dd.expect (as (*rs["cxx.checksum"])) != nullptr) + l4 ([&]{trace << "compiler mismatch forcing update of " << t;}); // Then the options checksum. // - { - // The idea is to keep them exactly as they are passed to the - // compiler since the order may be significant. - // - sha256 cs; - - // Hash cxx.export.poptions from prerequisite libraries. - // - for (prerequisite& p: group_prerequisites (t)) - { - target& pt (*p.target); // Already searched and matched. - - if (pt.is_a () || pt.is_a () || pt.is_a ()) - hash_lib_options (cs, pt, "cxx.export.poptions"); - } + // The idea is to keep them exactly as they are passed to the compiler + // since the order may be significant. + // + sha256 cs; - hash_options (cs, t, "cxx.poptions"); - hash_options (cs, t, "cxx.coptions"); - hash_std (cs, t); + // Hash cxx.export.poptions from prerequisite libraries. + // + for (prerequisite& p: group_prerequisites (t)) + { + target& pt (*p.target); // Already searched and matched. - if (t.is_a ()) - { - if (sys != "darwin") - cs.append ("-fPIC"); - } + if (pt.is_a () || pt.is_a () || pt.is_a ()) + hash_lib_options (cs, pt, "cxx.export.poptions"); + } - dl = dd.read (); - if (dl == nullptr || *dl != cs.string ()) - { - dd.write (cs.string ()); + hash_options (cs, t, "cxx.poptions"); + hash_options (cs, t, "cxx.coptions"); + hash_std (cs, t); - if (dl != nullptr) - l4 ([&]{trace << "options mismatch forcing update of " << t;}); - } + if (t.is_a ()) + { + if (sys != "darwin") + cs.append ("-fPIC"); } - // Then the source file. - // - dl = dd.read (); - if (dl == nullptr || *dl != st.path ().string ()) - { - dd.write (st.path ()); + if (dd.expect (cs.string ()) != nullptr) + l4 ([&]{trace << "options mismatch forcing update of " << t;}); - if (dl != nullptr) - l4 ([&]{trace << "source file mismatch forcing update of " << t;}); - } + // Finally the source file. + // + if (dd.expect (st.path ()) != nullptr) + l4 ([&]{trace << "source file mismatch forcing update of " << t;}); // If any of the above checks resulted in a mismatch (different // compiler, options, or source file), or if the database is newer -- cgit v1.1