From 8a7b3bb944ca08d240fc778a9269c6db0f9746f8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 14 Feb 2017 09:56:42 +0200 Subject: Modify library mate-information protocol not to use lib{} group --- build2/cc/compile.cxx | 26 +++++++++++++++++--------- build2/cc/link.cxx | 22 +++++++++++----------- 2 files changed, 28 insertions(+), 20 deletions(-) (limited to 'build2/cc') diff --git a/build2/cc/compile.cxx b/build2/cc/compile.cxx index c8394a9..3039f00 100644 --- a/build2/cc/compile.cxx +++ b/build2/cc/compile.cxx @@ -213,7 +213,9 @@ namespace build2 const scope& bs (t.base_scope ()); const scope& rs (*bs.root_scope ()); + otype ct (compile_type (t)); + lorder lo (link_order (bs, ct)); // Derive file name from target name. // @@ -286,16 +288,24 @@ namespace build2 { if (a.operation () == update_id) { - // Handle imported libraries. We know that for such libraries - // we don't need to do match() in order to get options (if - // any, they would be set by search_library()). + // Handle imported libraries. We know that for such libraries we + // don't need to do match() in order to get options (if any, they + // would be set by search_library()). // - if (!p.proj () || - search_library ( - sys_lib_dirs, usr_lib_dirs, p.prerequisite) == nullptr) + if (p.proj ()) { - match_only (ml, a, p.search ()); + if (search_library (sys_lib_dirs, + usr_lib_dirs, + p.prerequisite) != nullptr) + continue; } + + target* pt (&p.search ()); + + if (lib* l = pt->is_a ()) + pt = &link_member (*l, lo); + + match_only (ml, a, *pt); } continue; @@ -316,8 +326,6 @@ namespace build2 // if (a == perform_update_id) { - lorder lo (link_order (bs, ct)); - // The cached prerequisite target should be the same as what is in // t.prerequisite_targets since we used standard search() and match() // above. diff --git a/build2/cc/link.cxx b/build2/cc/link.cxx index 0aef9f0..269b11f 100644 --- a/build2/cc/link.cxx +++ b/build2/cc/link.cxx @@ -126,7 +126,7 @@ namespace build2 // Set the library type. // - t.vars.assign (c_type) = string (x); + t.vars.assign (c_type) = string (x); //@@ move to apply()? // If we have any prerequisite libraries, search/import and pre-match // them to implement the "library meta-information protocol". Don't do @@ -140,8 +140,8 @@ namespace build2 op != install_id && oop != install_id && op != uninstall_id && oop != uninstall_id) { - if (t.group != nullptr) - t.group->prerequisite_targets.clear (); // lib{}'s + const scope& bs (t.base_scope ()); + lorder lo (link_order (bs, lt)); optional usr_lib_dirs; // Extract lazily. @@ -159,15 +159,13 @@ namespace build2 if (pt == nullptr) { pt = &p.search (); + + if (lib* l = pt->is_a ()) + pt = &link_member (*l, lo); + match_only (ml, a, *pt); } - // If the prerequisite came from the lib{} group, then also - // add it to lib's prerequisite_targets. - // - if (!p.prerequisite.belongs (t)) - t.group->prerequisite_targets.push_back (pt); - t.prerequisite_targets.push_back (pt); } } @@ -486,8 +484,10 @@ namespace build2 // altogether. So we are going to use the target's project. // - // @@ Why are we creating the obj{} group if the source came from a - // group? + // If the source came from the lib{} group, then create the obj{} + // group and add the source as a prerequisite of the obj{} group, + // not the obj?{} member. This way we only need one prerequisite + // for, say, both liba{} and libs{}. // bool group (!p.prerequisite.belongs (t)); // Group's prerequisite. -- cgit v1.1