aboutsummaryrefslogtreecommitdiff
path: root/build/prerequisite.cxx
diff options
context:
space:
mode:
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);
+ }
}