From 9f5c4c1ae3bff517eefb39130287016514fb31c7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 6 Jan 2017 17:28:45 +0200 Subject: Store platform targets as typed target_triplet --- build2/cc/init.cxx | 55 ++++++++++++++++++++++-------------------------------- 1 file changed, 22 insertions(+), 33 deletions(-) (limited to 'build2/cc/init.cxx') diff --git a/build2/cc/init.cxx b/build2/cc/init.cxx index 32ea8f3..a162daa 100644 --- a/build2/cc/init.cxx +++ b/build2/cc/init.cxx @@ -4,8 +4,6 @@ #include -#include - #include #include #include @@ -56,9 +54,9 @@ namespace build2 // Hint variables (not overridable). // - v.insert ("config.cc.id"); - v.insert ("config.cc.target"); - v.insert ("config.cc.pattern"); + v.insert ("config.cc.id"); + v.insert ("config.cc.pattern"); + v.insert ("config.cc.target"); // Target type, for example, "C library" or "C++ library". Should be set // on the target by the matching rule to the name of the module (e.g., @@ -115,31 +113,20 @@ namespace build2 // config.cc.target // { - // This value must be hinted and already canonicalized. + // This value must be hinted. // - const string& s (cast (hints["config.cc.target"])); + const auto& t (cast (hints["config.cc.target"])); - try - { - //@@ We do it in the hinting module and here. Any way not to - // duplicate the effort? Maybe move the splitting here and - // simply duplicate the values there? - // - triplet t (s); - - // Enter as cc.target.{cpu,vendor,system,version,class}. - // - rs.assign ("cc.target") = s; - rs.assign ("cc.target.cpu") = move (t.cpu); - rs.assign ("cc.target.vendor") = move (t.vendor); - rs.assign ("cc.target.system") = move (t.system); - rs.assign ("cc.target.version") = move (t.version); - rs.assign ("cc.target.class") = move (t.class_); - } - catch (const invalid_argument& e) - { - assert (false); // Should have been caught by the hinting module. - } + // Also enter as cc.target.{cpu,vendor,system,version,class} for + // convenience of access. + // + rs.assign ("cc.target.cpu") = t.cpu; + rs.assign ("cc.target.vendor") = t.vendor; + rs.assign ("cc.target.system") = t.system; + rs.assign ("cc.target.version") = t.version; + rs.assign ("cc.target.class") = t.class_; + + rs.assign ("cc.target") = t; } // config.cc.pattern @@ -182,10 +169,11 @@ namespace build2 variable_map h; if (first) { - h.assign ("config.bin.target") = cast (rs["cc.target"]); + h.assign ("config.bin.target") = + cast (rs["cc.target"]).string (); if (auto l = hints["config.bin.pattern"]) - h.assign ("config.bin.pattern") = cast (l); + h.assign ("config.bin.pattern") = cast (l); } load_module ("bin.config", rs, rs, loc, false, h); @@ -197,8 +185,8 @@ namespace build2 // if (first) { - const string& ct (cast (rs["cc.target"])); - const string& bt (cast (rs["bin.target"])); + const auto& ct (cast (rs["cc.target"])); + const auto& bt (cast (rs["bin.target"])); if (bt != ct) fail (loc) << "cc and bin module target mismatch" << @@ -245,7 +233,8 @@ namespace build2 // Prepare configuration hints. // variable_map h; - h.assign ("config.pkgconfig.target") = cast (rs["cc.target"]); + h.assign ("config.pkgconfig.target") = + cast (rs["cc.target"]); load_module ("pkgconfig.config", rs, rs, loc, true, h); } -- cgit v1.1