aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-11-01 09:44:05 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-11-01 09:44:05 +0200
commitbc0d26129a33967576485092c292451f4d4d5115 (patch)
treeceb7725f054bae526d7bc24d5d2f32dbb98ad2ed
parente745077de53aa0e21affea66c2f55bba172ec286 (diff)
Handle match options for post hoc libs{} prerequisites in cc::install_rule
-rw-r--r--libbuild2/cc/install-rule.cxx72
-rw-r--r--libbuild2/cc/install-rule.hxx6
2 files changed, 78 insertions, 0 deletions
diff --git a/libbuild2/cc/install-rule.cxx b/libbuild2/cc/install-rule.cxx
index d3fa522..3d20272 100644
--- a/libbuild2/cc/install-rule.cxx
+++ b/libbuild2/cc/install-rule.cxx
@@ -18,6 +18,9 @@ namespace build2
{
using namespace bin;
+ using posthoc_prerequisite_target =
+ context::posthoc_target::prerequisite_target;
+
// install_rule
//
install_rule::
@@ -381,6 +384,30 @@ namespace build2
}
void install_rule::
+ apply_posthoc (action a, target& t, match_extra& me) const
+ {
+ // Similar semantics to filter() above for shared libraries specified as
+ // post hoc prerequisites (e.g., plugins).
+ //
+ if (a.operation () != update_id)
+ {
+ for (posthoc_prerequisite_target& p: *me.posthoc_prerequisite_targets)
+ {
+ if (p.target != nullptr && p.target->is_a<libs> ())
+ {
+ if (t.is_a<exe> ())
+ p.match_options = lib::option_install_runtime;
+ else
+ {
+ if (me.cur_options == lib::option_install_runtime)
+ p.match_options = lib::option_install_runtime;
+ }
+ }
+ }
+ }
+ }
+
+ void install_rule::
reapply (action a, target& t, match_extra& me) const
{
assert (a.operation () != update_id && !t.is_a<exe> ());
@@ -413,6 +440,19 @@ namespace build2
}
}
+ // Also to post hoc.
+ //
+ if (me.posthoc_prerequisite_targets != nullptr)
+ {
+ for (posthoc_prerequisite_target& p: *me.posthoc_prerequisite_targets)
+ {
+ if (p.target != nullptr && p.target->is_a<libs> ())
+ {
+ p.match_options = match_extra::all_options;
+ }
+ }
+ }
+
// Also match any additional prerequisites (e.g., headers).
//
file_rule::reapply_impl (a, t, me);
@@ -685,6 +725,27 @@ namespace build2
}
void libux_install_rule::
+ apply_posthoc (action a, target& t, match_extra& me) const
+ {
+ if (a.operation () != update_id)
+ {
+ for (posthoc_prerequisite_target& p: *me.posthoc_prerequisite_targets)
+ {
+ if (p.target != nullptr && p.target->is_a<libs> ())
+ {
+ if (t.is_a<libue> ())
+ p.match_options = lib::option_install_runtime;
+ else
+ {
+ if (me.cur_options == lib::option_install_runtime)
+ p.match_options = lib::option_install_runtime;
+ }
+ }
+ }
+ }
+ }
+
+ void libux_install_rule::
reapply (action a, target& t, match_extra& me) const
{
assert (a.operation () != update_id && !t.is_a<libue> ());
@@ -704,6 +765,17 @@ namespace build2
rematch_sync (a, *pt, match_extra::all_options);
}
+ if (me.posthoc_prerequisite_targets != nullptr)
+ {
+ for (posthoc_prerequisite_target& p: *me.posthoc_prerequisite_targets)
+ {
+ if (p.target != nullptr && p.target->is_a<libs> ())
+ {
+ p.match_options = match_extra::all_options;
+ }
+ }
+ }
+
alias_rule::reapply_impl (a, t, me);
}
}
diff --git a/libbuild2/cc/install-rule.hxx b/libbuild2/cc/install-rule.hxx
index 9d9211b..771c33b 100644
--- a/libbuild2/cc/install-rule.hxx
+++ b/libbuild2/cc/install-rule.hxx
@@ -55,6 +55,9 @@ namespace build2
apply (action, target&, match_extra&) const override;
virtual void
+ apply_posthoc (action, target&, match_extra&) const override;
+
+ virtual void
reapply (action, target&, match_extra&) const override;
virtual bool
@@ -97,6 +100,9 @@ namespace build2
apply (action, target&, match_extra&) const override;
virtual void
+ apply_posthoc (action, target&, match_extra&) const override;
+
+ virtual void
reapply (action, target&, match_extra&) const override;
private: