From 7bcb45cba78795dccdb2684f6f290daeb8bab488 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 1 Nov 2023 09:44:05 +0200 Subject: Handle match options for post hoc libs{} prerequisites in cc::install_rule --- libbuild2/cc/install-rule.cxx | 72 +++++++++++++++++++++++++++++++++++++++++++ libbuild2/cc/install-rule.hxx | 6 ++++ 2 files changed, 78 insertions(+) diff --git a/libbuild2/cc/install-rule.cxx b/libbuild2/cc/install-rule.cxx index 7327711..28d1a58 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:: @@ -376,6 +379,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 ()) + { + if (t.is_a ()) + 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 { tracer trace ("cc::install_rule::reapply"); @@ -410,6 +437,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 ()) + { + 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 ()) + { + if (t.is_a ()) + 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 { tracer trace ("cc::linux_install_rule::reapply"); @@ -706,6 +767,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 ()) + { + 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: -- cgit v1.1