aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/algorithm.hxx3
-rw-r--r--libbuild2/algorithm.ixx11
-rw-r--r--libbuild2/cc/link-rule.cxx21
-rw-r--r--libbuild2/dyndep.cxx3
-rw-r--r--libbuild2/target.hxx14
5 files changed, 44 insertions, 8 deletions
diff --git a/libbuild2/algorithm.hxx b/libbuild2/algorithm.hxx
index 300016f..0f981a9 100644
--- a/libbuild2/algorithm.hxx
+++ b/libbuild2/algorithm.hxx
@@ -78,6 +78,9 @@ namespace build2
pair<target&, ulock>
search_locked (const target&, const target_type&, const prerequisite_key&);
+ const target*
+ search_exsiting (context&, const target_type&, const prerequisite_key&);
+
const target&
search_new (context&, const target_type&, const prerequisite_key&);
diff --git a/libbuild2/algorithm.ixx b/libbuild2/algorithm.ixx
index ea4241e..8fc5390 100644
--- a/libbuild2/algorithm.ixx
+++ b/libbuild2/algorithm.ixx
@@ -45,6 +45,17 @@ namespace build2
k.proj, {&tt, k.tk.dir, k.tk.out, k.tk.name, k.tk.ext}, k.scope});
}
+ inline const target*
+ search_exsiting (context& ctx,
+ const target_type& tt,
+ const prerequisite_key& k)
+ {
+ return search_existing (
+ ctx,
+ prerequisite_key {
+ k.proj, {&tt, k.tk.dir, k.tk.out, k.tk.name, k.tk.ext}, k.scope});
+ }
+
inline const target&
search_new (context& ctx,
const target_type& tt,
diff --git a/libbuild2/cc/link-rule.cxx b/libbuild2/cc/link-rule.cxx
index 71d2055..da9cca4 100644
--- a/libbuild2/cc/link-rule.cxx
+++ b/libbuild2/cc/link-rule.cxx
@@ -1596,6 +1596,13 @@ namespace build2
// we will use its bin.lib to decide what will be installed and in
// perform_update() we will confirm that it is actually installed.
//
+ // This, of course, works only if we actually have explicit lib{}.
+ // But the user could only have liba{} (common in testing frameworks
+ // that provide main()) or only libs{} (e.g., plugin that can also
+ // be linked). It's also theoretically possible to have both liba{}
+ // and libs{} but no lib{}, in which case it feels correct not to
+ // generate the common file at all.
+ //
if (ot != otype::e)
{
// Note that here we always use the lib name prefix, even on
@@ -1607,7 +1614,13 @@ namespace build2
// Note also that the order in which we are adding these members
// is important (see add_addhoc_member() for details).
//
- if (ot == otype::a || !link_members (rs).a)
+ if (t.group->decl >= target_decl::implied
+ ? (ot == otype::a || !link_members (rs).a)
+ : search_existing (ctx,
+ ot == otype::a
+ ? libs::static_type
+ : liba::static_type,
+ t.dir, t.out, t.name) == nullptr)
{
auto& pc (add_adhoc_member<pc> (t));
@@ -2786,8 +2799,12 @@ namespace build2
if (!m->is_a (la ? pca::static_type : pcs::static_type))
{
- if (t.group->matched (a))
+ if (t.group->decl >= target_decl::implied
+ ? t.group->matched (a)
+ : true)
+ {
pkgconfig_save (a, t, la, true /* common */, binless);
+ }
else
// Mark as non-existent not to confuse the install rule.
//
diff --git a/libbuild2/dyndep.cxx b/libbuild2/dyndep.cxx
index bc307f6..bbbf807 100644
--- a/libbuild2/dyndep.cxx
+++ b/libbuild2/dyndep.cxx
@@ -542,8 +542,7 @@ namespace build2
// implied ones because pre-entered members of a target group
// (e.g., cli.cxx) are implied.
//
- if (x->decl == target_decl::real ||
- x->decl == target_decl::implied)
+ if (x->decl >= target_decl::implied)
{
r = x;
break;
diff --git a/libbuild2/target.hxx b/libbuild2/target.hxx
index 1a7abfc..038552f 100644
--- a/libbuild2/target.hxx
+++ b/libbuild2/target.hxx
@@ -267,12 +267,18 @@ namespace build2
//
enum class target_decl: uint8_t
{
- prereq_new, // Created from prerequisite (create_new_target()).
- prereq_file, // Created from prerequisite/file (search_existing_file ()).
- implied, // Target-spec variable assignment, implicitly-entered, etc.
- real // Real dependency declaration.
+ prereq_new = 1, // Created from prerequisite (create_new_target()).
+ prereq_file, // Created from prerequisite/file (search_existing_file()).
+ implied, // Target-spec variable assignment, implicitly-entered, etc.
+ real // Real dependency declaration.
};
+ inline bool
+ operator>= (target_decl l, target_decl r)
+ {
+ return static_cast<uint8_t> (l) >= static_cast<uint8_t> (r);
+ }
+
class LIBBUILD2_SYMEXPORT target
{
public: