From e815af118562c68794efbd310c887acd8eae800c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 24 Jun 2015 13:53:28 +0200 Subject: First take on the cli module plus necessary infrastructure --- build/cxx/module.cxx | 3 ++- build/cxx/rule.cxx | 58 ++++++++++++++++++++++------------------------------ build/cxx/target.cxx | 12 +++++++++++ 3 files changed, 39 insertions(+), 34 deletions(-) (limited to 'build/cxx') 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 #include +#include + using namespace std; using namespace butl; @@ -33,24 +35,7 @@ namespace build { using namespace bin; - // T is either target or scope. - // - template - static void - append_options (vector& args, T& s, const char* var) - { - if (auto val = s[var]) - { - for (const name& n: val.template as ()) - { - 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& 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 ()) - t.path (t.derived_path ("o")); - else - t.path (t.derived_path ("o", nullptr, "-so")); - } + t.derive_path ("o", nullptr, (t.is_a () ? "-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 ()); vector 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 (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 (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 ()); vector 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 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, + &target_extension_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, + &target_extension_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, + &target_extension_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, + &target_extension_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, + &target_extension_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, + &target_extension_var, &search_file }; } -- cgit v1.1