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