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/rule.cxx | 58 +++++++++++++++++++++++------------------------------- 1 file changed, 25 insertions(+), 33 deletions(-) (limited to 'build/cxx/rule.cxx') 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; -- cgit v1.1