aboutsummaryrefslogtreecommitdiff
path: root/build/prerequisite.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-01-16 14:11:14 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-01-16 14:11:14 +0200
commitc106259517d7693ea8e24564bc890fe575d5edcd (patch)
treebbf87f83edeaf60ff3dfa6fff33c6b7504f5318b /build/prerequisite.cxx
parentdf50091259a34fa4718f38c0e3b7b64f6e2469ac (diff)
Implement rule chaining for cxx::link
Diffstat (limited to 'build/prerequisite.cxx')
-rw-r--r--build/prerequisite.cxx42
1 files changed, 42 insertions, 0 deletions
diff --git a/build/prerequisite.cxx b/build/prerequisite.cxx
index 370f5d0..f5461ef 100644
--- a/build/prerequisite.cxx
+++ b/build/prerequisite.cxx
@@ -9,6 +9,7 @@
#include <build/scope>
#include <build/target> // target_type
#include <build/context>
+#include <build/diagnostics>
using namespace std;
@@ -72,4 +73,45 @@ namespace build
x.directory == y.directory &&
x.ext != nullptr && y.ext != nullptr && x.ext < y.ext);
}
+
+ // prerequisite_set
+ //
+ auto prerequisite_set::
+ insert (const target_type& tt,
+ path dir,
+ std::string name,
+ const std::string* ext,
+ scope& s,
+ tracer& tr) -> pair<prerequisite&, bool>
+ {
+ //@@ OPT: would be nice to somehow first check if this prerequisite is
+ // already in the set before allocating a new instance.
+
+ // Find or insert.
+ //
+ auto r (emplace (tt, move (dir), move (name), ext, s));
+ prerequisite& p (const_cast<prerequisite&> (*r.first));
+
+ // Update extension if the existing prerequisite has it unspecified.
+ //
+ if (p.ext != ext)
+ {
+ trace (4, [&]{
+ tracer::record r (tr);
+ r << "assuming prerequisite " << p << " is the same as the "
+ << "one with ";
+ if (ext == nullptr)
+ r << "unspecified extension";
+ else if (ext->empty ())
+ r << "no extension";
+ else
+ r << "extension " << *ext;
+ });
+
+ if (ext != nullptr)
+ p.ext = ext;
+ }
+
+ return pair<prerequisite&, bool> (p, r.second);
+ }
}