From 49d5628e35593a5300d39596286c768d7aa435b6 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 7 Jul 2015 09:18:22 +0200 Subject: 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. --- build/module.cxx | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'build/module.cxx') 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 +#include // make_pair() + +#include +#include + 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); + } } -- cgit v1.1