aboutsummaryrefslogtreecommitdiff
path: root/build2/cc
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-02-14 09:56:42 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-02-14 14:53:51 +0200
commit8a7b3bb944ca08d240fc778a9269c6db0f9746f8 (patch)
tree750e1ae74d9fdd3989871f92b71df4b0feb3b3f1 /build2/cc
parentcc2b346d96bc2877efc9719507ceaa4fefbc9668 (diff)
Modify library mate-information protocol not to use lib{} group
Diffstat (limited to 'build2/cc')
-rw-r--r--build2/cc/compile.cxx26
-rw-r--r--build2/cc/link.cxx22
2 files changed, 28 insertions, 20 deletions
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<lib> ())
+ 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<dir_paths> usr_lib_dirs; // Extract lazily.
@@ -159,15 +159,13 @@ namespace build2
if (pt == nullptr)
{
pt = &p.search ();
+
+ if (lib* l = pt->is_a<lib> ())
+ 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.