aboutsummaryrefslogtreecommitdiff
path: root/build2/cxx/compile.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-03-09 16:43:10 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-03-09 16:43:10 +0200
commit39a0e4230d9f79447755e765446f7fe6b897da99 (patch)
treeca7d387da1daa0d2c9eb9c53a6ca3a83e1f48c20 /build2/cxx/compile.cxx
parent51267fc81abdbf0ca7f1098fccd7f3e0d7da5306 (diff)
Use depdb in cxx.link rule
Diffstat (limited to 'build2/cxx/compile.cxx')
-rw-r--r--build2/cxx/compile.cxx88
1 files changed, 29 insertions, 59 deletions
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<string> (*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<string> (*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<lib> () || pt.is_a<liba> () || pt.is_a<libso> ())
- 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<objso> ())
- {
- if (sys != "darwin")
- cs.append ("-fPIC");
- }
+ if (pt.is_a<lib> () || pt.is_a<liba> () || pt.is_a<libso> ())
+ 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<objso> ())
+ {
+ 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