diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-06-24 13:53:28 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-06-24 13:53:28 +0200 |
commit | e815af118562c68794efbd310c887acd8eae800c (patch) | |
tree | cedd8745cce259693c038c309d663a682c982e98 /build/cxx | |
parent | 4f52c4ed65883dacef32587cf066fbb1182c6628 (diff) |
First take on the cli module plus necessary infrastructure
Diffstat (limited to 'build/cxx')
-rw-r--r-- | build/cxx/module.cxx | 3 | ||||
-rw-r--r-- | build/cxx/rule.cxx | 58 | ||||
-rw-r--r-- | build/cxx/target.cxx | 12 |
3 files changed, 39 insertions, 34 deletions
diff --git a/build/cxx/module.cxx b/build/cxx/module.cxx index 21f1b85..495819d 100644 --- a/build/cxx/module.cxx +++ b/build/cxx/module.cxx @@ -87,7 +87,8 @@ namespace build throw failed (); } - //text << "toolchain version " << ver; + if (verb) + text << cxx << " " << ver; } } diff --git a/build/cxx/rule.cxx b/build/cxx/rule.cxx index e4c0dd7..cba1a1b 100644 --- a/build/cxx/rule.cxx +++ b/build/cxx/rule.cxx @@ -24,6 +24,8 @@ #include <build/bin/target> #include <build/cxx/target> +#include <build/config/utility> + using namespace std; using namespace butl; @@ -33,24 +35,7 @@ namespace build { using namespace bin; - // T is either target or scope. - // - template <typename T> - static void - append_options (vector<const char*>& args, T& s, const char* var) - { - if (auto val = s[var]) - { - for (const name& n: val.template as<const list_value&> ()) - { - if (!n.type.empty () || !n.dir.empty ()) - fail << "expected option instead of " << n << - info << "in variable " << var; - - args.push_back (n.value.c_str ()); - } - } - } + using config::append_options; static void append_std (vector<const char*>& args, target& t, string& opt) @@ -127,12 +112,7 @@ namespace build // Derive file name from target name. // if (t.path ().empty ()) - { - if (t.is_a <obja> ()) - t.path (t.derived_path ("o")); - else - t.path (t.derived_path ("o", nullptr, "-so")); - } + t.derive_path ("o", nullptr, (t.is_a<objso> () ? "-so" : nullptr)); // Inject dependency on the output directory. // @@ -236,7 +216,7 @@ namespace build { tracer trace ("cxx::compile::inject_prerequisites"); - scope& rs (*t.root_scope ()); // Shouldn't have matched if nullptr. + scope& rs (t.root_scope ()); const string& cxx (rs["config.cxx"].as<const string&> ()); vector<const char*> args {cxx.c_str ()}; @@ -346,7 +326,20 @@ namespace build // then assume it is a header. Otherwise, let the standard // mechanism derive the type from the extension. @@ TODO. // - path_target& pt (search<hxx> (d, n, e, &ds)); + const target_type* tt (&hxx::static_type); + + //@@ TMP + // + if (e != nullptr) + { + if (*e == "ixx") + tt = &ixx::static_type; + else if (*e == "txx") + tt = &txx::static_type; + } + + path_target& pt ( + static_cast<path_target&> (search (*tt, d, n, e, &ds))); // Assign path. // @@ -398,7 +391,7 @@ namespace build path relo (relative (t.path ())); path rels (relative (s->path ())); - scope& rs (*t.root_scope ()); // Shouldn't have matched if nullptr. + scope& rs (t.root_scope ()); const string& cxx (rs["config.cxx"].as<const string&> ()); vector<const char*> args {cxx.c_str ()}; @@ -580,9 +573,9 @@ namespace build { switch (lt) { - case type::e: t.path (t.derived_path ( )); break; - case type::a: t.path (t.derived_path ("a", "lib")); break; - case type::so: t.path (t.derived_path ("so", "lib")); break; + case type::e: t.derive_path ("" ); break; + case type::a: t.derive_path ("a", "lib"); break; + case type::so: t.derive_path ("so", "lib"); break; } } @@ -674,8 +667,7 @@ namespace build // but possible, the prerequisite is from a different project // altogether. So we are going to use the target's project. // - root = t.root_scope (); - assert (root != nullptr); // Otherwise shouldn't have matched. + root = &t.root_scope (); out_root = &root->path (); src_root = &root->src_path (); } @@ -837,7 +829,7 @@ namespace build // path relt (relative (t.path ())); - scope& rs (*t.root_scope ()); // Shouldn't have matched if nullptr. + scope& rs (t.root_scope ()); vector<const char*> args; string storage1; diff --git a/build/cxx/target.cxx b/build/cxx/target.cxx index e02801b..9fd5487 100644 --- a/build/cxx/target.cxx +++ b/build/cxx/target.cxx @@ -10,57 +10,69 @@ namespace build { namespace cxx { + constexpr const char hxx_ext_var[] = "hxx.ext"; const target_type hxx::static_type { typeid (hxx), "hxx", &file::static_type, &target_factory<hxx>, + &target_extension_var<hxx_ext_var>, &search_file }; + constexpr const char ixx_ext_var[] = "ixx.ext"; const target_type ixx::static_type { typeid (ixx), "ixx", &file::static_type, &target_factory<ixx>, + &target_extension_var<ixx_ext_var>, &search_file }; + constexpr const char txx_ext_var[] = "txx.ext"; const target_type txx::static_type { typeid (txx), "txx", &file::static_type, &target_factory<txx>, + &target_extension_var<txx_ext_var>, &search_file }; + constexpr const char cxx_ext_var[] = "cxx.ext"; const target_type cxx::static_type { typeid (cxx), "cxx", &file::static_type, &target_factory<cxx>, + &target_extension_var<cxx_ext_var>, &search_file }; + constexpr const char h_ext_var[] = "h.ext"; const target_type h::static_type { typeid (h), "h", &file::static_type, &target_factory<h>, + &target_extension_var<h_ext_var>, &search_file }; + constexpr const char c_ext_var[] = "c.ext"; const target_type c::static_type { typeid (c), "c", &file::static_type, &target_factory<c>, + &target_extension_var<c_ext_var>, &search_file }; } |