From 76be0a35f6c37cda7ba65530330f1ac246fb52a8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 6 Apr 2022 11:26:52 +0200 Subject: Add support for rule hints A rule hint is a target attribute, for example: [rule_hint=cxx] exe{hello}: c{hello} Rule hints can be used to resolve ambiguity when multiple rules match the same target as well as to override an unambiguous match. --- libbuild2/install/init.cxx | 13 ++++++------- libbuild2/install/rule.cxx | 12 ++++++------ libbuild2/install/rule.hxx | 12 ++++++------ 3 files changed, 18 insertions(+), 19 deletions(-) (limited to 'libbuild2/install') diff --git a/libbuild2/install/init.cxx b/libbuild2/install/init.cxx index 1bf1623..ef9de05 100644 --- a/libbuild2/install/init.cxx +++ b/libbuild2/install/init.cxx @@ -372,19 +372,19 @@ namespace build2 const auto& gr (group_rule_); bs.insert_rule (perform_install_id, "install.alias", ar); - bs.insert_rule (perform_uninstall_id, "uninstall.alias", ar); + bs.insert_rule (perform_uninstall_id, "install.alias", ar); bs.insert_rule (perform_install_id, "install.fsdir", dr); bs.insert_rule (perform_uninstall_id, "install.fsdir", dr); bs.insert_rule (perform_install_id, "install.file", fr); - bs.insert_rule (perform_uninstall_id, "uninstall.file", fr); + bs.insert_rule (perform_uninstall_id, "install.file", fr); // Note: use mtime_target (instead of target) to take precedence over // the fallback file rules below. // bs.insert_rule (perform_install_id, "install.group", gr); - bs.insert_rule (perform_uninstall_id, "uninstall.group", gr); + bs.insert_rule (perform_uninstall_id, "install.group", gr); // Register the fallback file rule for the update-for-[un]install // operation, similar to update. @@ -392,11 +392,10 @@ namespace build2 // @@ Hm, it's a bit fuzzy why we would be updating-for-install // something outside of any project..? // - rs.global_scope ().insert_rule ( - perform_install_id, "install.file", fr); + scope& gs (rs.global_scope ()); - rs.global_scope ().insert_rule ( - perform_uninstall_id, "uninstall.file", fr); + gs.insert_rule (perform_install_id, "install.file", fr); + gs.insert_rule (perform_uninstall_id, "install.file", fr); } // Configuration. diff --git a/libbuild2/install/rule.cxx b/libbuild2/install/rule.cxx index 468fcc3..0a1b994 100644 --- a/libbuild2/install/rule.cxx +++ b/libbuild2/install/rule.cxx @@ -53,7 +53,7 @@ namespace build2 const alias_rule alias_rule::instance; bool alias_rule:: - match (action, target&, const string&) const + match (action, target&) const { // We always match. // @@ -168,7 +168,7 @@ namespace build2 const fsdir_rule fsdir_rule::instance; bool fsdir_rule:: - match (action, target&, const string&) const + match (action, target&) const { // We always match. // @@ -203,10 +203,10 @@ namespace build2 const group_rule group_rule::instance (false /* see_through_only */); bool group_rule:: - match (action a, target& t, const string& h) const + match (action a, target& t) const { - return (!see_through || t.type ().see_through) && - alias_rule::match (a, t, h); + return (!see_through_only || t.type ().see_through ()) && + alias_rule::match (a, t); } const target* group_rule:: @@ -300,7 +300,7 @@ namespace build2 const file_rule file_rule::instance; bool file_rule:: - match (action, target&, const string&) const + match (action, target&) const { // We always match, even if this target is not installable (so that we // can ignore it; see apply()). diff --git a/libbuild2/install/rule.hxx b/libbuild2/install/rule.hxx index 79cef85..ad9d6e7 100644 --- a/libbuild2/install/rule.hxx +++ b/libbuild2/install/rule.hxx @@ -22,7 +22,7 @@ namespace build2 { public: virtual bool - match (action, target&, const string&) const override; + match (action, target&) const override; // Return NULL if this prerequisite should be ignored and pointer to its // target otherwise. @@ -54,7 +54,7 @@ namespace build2 { public: virtual bool - match (action, target&, const string&) const override; + match (action, target&) const override; virtual recipe apply (action, target&) const override; @@ -78,7 +78,7 @@ namespace build2 { public: virtual bool - match (action, target&, const string&) const override; + match (action, target&) const override; // Return NULL if this group member should be ignored and pointer to its // target otherwise. @@ -103,10 +103,10 @@ namespace build2 virtual recipe apply (action, target&) const override; - group_rule (bool see_through_only): see_through (see_through_only) {} + group_rule (bool sto): see_through_only (sto) {} static const group_rule instance; - bool see_through; + bool see_through_only; }; struct install_dir; @@ -115,7 +115,7 @@ namespace build2 { public: virtual bool - match (action, target&, const string&) const override; + match (action, target&) const override; // Return NULL if this prerequisite should be ignored and pointer to its // target otherwise. -- cgit v1.1