From 48e2e4140b8e5aacdfd107a1215f21c9632c81c8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 22 Aug 2016 12:55:21 +0200 Subject: Cache process_path, use fallback search directory for binutils --- build2/variable.cxx | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) (limited to 'build2/variable.cxx') diff --git a/build2/variable.cxx b/build2/variable.cxx index eec0573..54b61b7 100644 --- a/build2/variable.cxx +++ b/build2/variable.cxx @@ -662,6 +662,104 @@ namespace build2 &default_empty }; + // process_path value + // + process_path value_traits:: + convert (name&& n, name* r) + { + path rp (move (n.dir)); + if (rp.empty ()) + rp = path (move (n.value)); + else + rp /= n.value; + + path ep; + if (r != nullptr) + { + ep = move (r->dir); + if (ep.empty ()) + ep = path (move (r->value)); + else + ep /= r->value; + } + + process_path pp (nullptr, move (rp), move (ep)); + pp.initial = pp.recall.string ().c_str (); + return pp; + } + + void + process_path_copy_ctor (value& l, const value& r, bool m) + { + const auto& rhs (r.as ()); + + if (m) + new (&l.data_) process_path (move (const_cast (rhs))); + else + { + auto& lhs ( + *new (&l.data_) process_path ( + nullptr, path (rhs.recall), path (rhs.effect))); + lhs.initial = lhs.recall.string ().c_str (); + } + } + + void + process_path_copy_assign (value& l, const value& r, bool m) + { + auto& lhs (l.as ()); + const auto& rhs (r.as ()); + + if (m) + lhs = move (const_cast (rhs)); + else + { + lhs.recall = rhs.recall; + lhs.effect = rhs.effect; + lhs.initial = lhs.recall.string ().c_str (); + } + } + + static names_view + process_path_reverse (const value& v, names& s) + { + auto& pp (v.as ()); + s.reserve (pp.effect.empty () ? 1 : 2); + + s.push_back (name (pp.recall.directory (), + string (), + pp.recall.leaf ().string ())); + + if (!pp.effect.empty ()) + { + s.back ().pair = '@'; + s.push_back (name (pp.effect.directory (), + string (), + pp.effect.leaf ().string ())); + } + + return s; + } + + const char* const value_traits::type_name = "process_path"; + + const value_type value_traits::value_type + { + type_name, + sizeof (process_path), + nullptr, // No base. + &default_dtor, + &process_path_copy_ctor, + &process_path_copy_assign, + &simple_assign, // Allow empty values. + nullptr, // Append not supported. + nullptr, // Prepend not supported. + &process_path_reverse, + nullptr, // No cast (cast data_ directly). + &simple_compare, + &default_empty + }; + // variable_pool // const variable& variable_pool:: -- cgit v1.1