aboutsummaryrefslogtreecommitdiff
path: root/build/b.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/b.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/b.cxx')
-rw-r--r--build/b.cxx103
1 files changed, 9 insertions, 94 deletions
diff --git a/build/b.cxx b/build/b.cxx
index d7fb9d3..0291729 100644
--- a/build/b.cxx
+++ b/build/b.cxx
@@ -77,15 +77,8 @@ namespace build
}
#include <build/config/module>
-
-#include <build/bin/target> //@@ tmp
-#include <build/bin/rule> //@@ tmp
#include <build/bin/module>
-
-#include <build/cxx/target> //@@ tmp
-#include <build/cxx/rule> //@@ tmp
#include <build/cxx/module>
-
#include <build/cli/module>
using namespace build;
@@ -131,91 +124,12 @@ main (int argc, char* argv[])
//
tzset ();
- // Register modules.
- //
- modules["config"] = &config::init;
- modules["bin"] = &bin::init;
- modules["cxx"] = &cxx::init;
- modules["cli"] = &cli::init;
-
- // Register target types.
- //
- target_types.insert (file::static_type);
- target_types.insert (dir::static_type);
- target_types.insert (fsdir::static_type);
-
- target_types.insert (bin::obja::static_type);
- target_types.insert (bin::objso::static_type);
- target_types.insert (bin::obj::static_type);
- target_types.insert (bin::exe::static_type);
- target_types.insert (bin::liba::static_type);
- target_types.insert (bin::libso::static_type);
- target_types.insert (bin::lib::static_type);
-
- target_types.insert (cxx::h::static_type);
- target_types.insert (cxx::c::static_type);
-
- target_types.insert (cxx::cxx::static_type);
- target_types.insert (cxx::hxx::static_type);
- target_types.insert (cxx::ixx::static_type);
- target_types.insert (cxx::txx::static_type);
-
- // Register rules.
+ // Register builtin modules.
//
- bin::obj_rule obj_rule;
- bin::lib_rule lib_rule;
- {
- using namespace bin;
-
- rules[default_id][typeid (obj)].emplace ("bin.obj", obj_rule);
- rules[update_id][typeid (obj)].emplace ("bin.obj", obj_rule);
- rules[clean_id][typeid (obj)].emplace ("bin.obj", obj_rule);
-
- rules[default_id][typeid (lib)].emplace ("bin.lib", lib_rule);
- rules[update_id][typeid (lib)].emplace ("bin.lib", lib_rule);
- rules[clean_id][typeid (lib)].emplace ("bin.lib", lib_rule);
- }
-
- cxx::compile cxx_compile;
- cxx::link cxx_link;
- {
- using namespace bin;
-
- rules[default_id][typeid (obja)].emplace ("cxx.gnu.compile", cxx_compile);
- rules[update_id][typeid (obja)].emplace ("cxx.gnu.compile", cxx_compile);
- rules[clean_id][typeid (obja)].emplace ("cxx.gnu.compile", cxx_compile);
-
- rules[default_id][typeid (objso)].emplace ("cxx.gnu.compile", cxx_compile);
- rules[update_id][typeid (objso)].emplace ("cxx.gnu.compile", cxx_compile);
- rules[clean_id][typeid (objso)].emplace ("cxx.gnu.compile", cxx_compile);
-
- rules[default_id][typeid (exe)].emplace ("cxx.gnu.link", cxx_link);
- rules[update_id][typeid (exe)].emplace ("cxx.gnu.link", cxx_link);
- rules[clean_id][typeid (exe)].emplace ("cxx.gnu.link", cxx_link);
-
- rules[default_id][typeid (liba)].emplace ("cxx.gnu.link", cxx_link);
- rules[update_id][typeid (liba)].emplace ("cxx.gnu.link", cxx_link);
- rules[clean_id][typeid (liba)].emplace ("cxx.gnu.link", cxx_link);
-
- rules[default_id][typeid (libso)].emplace ("cxx.gnu.link", cxx_link);
- rules[update_id][typeid (libso)].emplace ("cxx.gnu.link", cxx_link);
- rules[clean_id][typeid (libso)].emplace ("cxx.gnu.link", cxx_link);
- }
-
- dir_rule dir_r;
- rules[default_id][typeid (dir)].emplace ("dir", dir_r);
- rules[update_id][typeid (dir)].emplace ("dir", dir_r);
- rules[clean_id][typeid (dir)].emplace ("dir", dir_r);
-
- fsdir_rule fsdir_r;
- rules[default_id][typeid (fsdir)].emplace ("fsdir", fsdir_r);
- rules[update_id][typeid (fsdir)].emplace ("fsdir", fsdir_r);
- rules[clean_id][typeid (fsdir)].emplace ("fsdir", fsdir_r);
-
- file_rule file_r;
- rules[default_id][typeid (file)].emplace ("file", file_r);
- rules[update_id][typeid (file)].emplace ("file", file_r);
- rules[clean_id][typeid (file)].emplace ("file", file_r);
+ builtin_modules["config"] = &config::config_init;
+ builtin_modules["bin"] = &bin::bin_init;
+ builtin_modules["cxx"] = &cxx::cxx_init;
+ builtin_modules["cli"] = &cli::cli_init;
// Figure out work and home directories.
//
@@ -379,7 +293,7 @@ main (int argc, char* argv[])
// Handle a few common cases as special: empty name, '.',
// '..', as well as dir{foo/bar} (without trailing '/').
- // This code must be consistent with target_type_map::find().
+ // This code must be consistent with find_target_type().
//
if (v.empty () || v == "." || v == ".." || tn.type == "dir")
out_base = dir_path (v);
@@ -744,7 +658,6 @@ main (int argc, char* argv[])
current_mif = mif;
current_oif = oif;
current_mode = oif->mode;
- current_rules = &rules[oid];
}
//
// Similar to meta-operations, check that all the targets in
@@ -787,8 +700,10 @@ main (int argc, char* argv[])
// operation batch.
//
{
+ scope& bs (scopes.find (out_base));
+
const string* e;
- const target_type* ti (target_types.find (tn, e));
+ const target_type* ti (bs.find_target_type (tn, e));
if (ti == nullptr)
fail (l) << "unknown target type " << tn.type;