aboutsummaryrefslogtreecommitdiff
path: root/build/module.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-07-07 09:18:22 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-07-07 09:18:22 +0200
commit49d5628e35593a5300d39596286c768d7aa435b6 (patch)
tree43f20983a381c54aac7536e78e4f9543d8761aac /build/module.cxx
parent16c19b739a58845af7f807c3dee8021a1c421006 (diff)
Rework module architecture
Now the target type and rule maps are in scopes (builtins -- in global scope). We also now have the map of loaded modules in the root scope of each project.
Diffstat (limited to 'build/module.cxx')
-rw-r--r--build/module.cxx32
1 files changed, 31 insertions, 1 deletions
diff --git a/build/module.cxx b/build/module.cxx
index 6b410e6..0f2b1b2 100644
--- a/build/module.cxx
+++ b/build/module.cxx
@@ -4,9 +4,39 @@
#include <build/module>
+#include <utility> // make_pair()
+
+#include <build/scope>
+#include <build/diagnostics>
+
using namespace std;
namespace build
{
- module_map modules;
+ available_module_map builtin_modules;
+
+ void
+ load_module (const string& name, scope& root, scope& base, const location& l)
+ {
+ // First see if this modules has already been loaded for this
+ // project.
+ //
+ loaded_module_map& lm (root.modules);
+ auto i (lm.find (name));
+ bool f (i == lm.end ());
+
+ if (f)
+ {
+ // Otherwise search for this module.
+ //
+ auto j (builtin_modules.find (name));
+
+ if (j == builtin_modules.end ())
+ fail (l) << "unknown module " << name;
+
+ i = lm.emplace (name, make_pair (j->second, nullptr)).first;
+ }
+
+ i->second.first (root, base, l, i->second.second, f);
+ }
}