From 3740ef0a57116e35445379b8cc31868718729889 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 11 Jan 2021 11:53:59 +0200 Subject: Fix libul{} rule diagnostics --- libbuild2/bin/init.cxx | 19 ++++++++++--------- libbuild2/bin/rule.cxx | 18 +++++++++++++++--- libbuild2/bin/rule.hxx | 23 +++++++++++++++++++---- 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/libbuild2/bin/init.cxx b/libbuild2/bin/init.cxx index 6d2d2c2..ff00e89 100644 --- a/libbuild2/bin/init.cxx +++ b/libbuild2/bin/init.cxx @@ -29,7 +29,8 @@ namespace build2 { namespace bin { - static const fail_rule fail_; + static const obj_rule obj_; + static const libul_rule libul_; static const lib_rule lib_; // Default config.bin.*.lib values. @@ -563,17 +564,17 @@ namespace build2 { auto& r (bs.rules); - r.insert (perform_update_id, "bin.obj", fail_); - r.insert (perform_clean_id, "bin.obj", fail_); + r.insert (perform_update_id, "bin.obj", obj_); + r.insert (perform_clean_id, "bin.obj", obj_); - r.insert (perform_update_id, "bin.bmi", fail_); - r.insert (perform_clean_id, "bin.bmi", fail_); + r.insert (perform_update_id, "bin.bmi", obj_); + r.insert (perform_clean_id, "bin.bmi", obj_); - r.insert (perform_update_id, "bin.hbmi", fail_); - r.insert (perform_clean_id, "bin.hbmi", fail_); + r.insert (perform_update_id, "bin.hbmi", obj_); + r.insert (perform_clean_id, "bin.hbmi", obj_); - r.insert (perform_update_id, "bin.libul", fail_); - r.insert (perform_clean_id, "bin.libul", fail_); + r.insert (perform_update_id, "bin.libul", libul_); + r.insert (perform_clean_id, "bin.libul", libul_); // Similar to alias. // diff --git a/libbuild2/bin/rule.cxx b/libbuild2/bin/rule.cxx index 0abfcb5..021a768 100644 --- a/libbuild2/bin/rule.cxx +++ b/libbuild2/bin/rule.cxx @@ -17,9 +17,9 @@ namespace build2 { namespace bin { - // fail_rule + // obj_rule // - bool fail_rule:: + bool obj_rule:: match (action a, target& t, const string&) const { const char* n (t.dynamic_type ().name); // Ignore derived type. @@ -29,7 +29,19 @@ namespace build2 << n << "s{} member" << endf; } - recipe fail_rule:: + recipe obj_rule:: + apply (action, target&) const {return empty_recipe;} + + // libul_rule + // + bool libul_rule:: + match (action a, target& t, const string&) const + { + fail << diag_doing (a, t) << " target group" << + info << "explicitly select libua{} or libus{} member" << endf; + } + + recipe libul_rule:: apply (action, target&) const {return empty_recipe;} // lib_rule diff --git a/libbuild2/bin/rule.hxx b/libbuild2/bin/rule.hxx index 51693a7..ffb975d 100644 --- a/libbuild2/bin/rule.hxx +++ b/libbuild2/bin/rule.hxx @@ -15,13 +15,28 @@ namespace build2 { namespace bin { - // "Fail rule" for obj{}, [h]bmi{}, and libu{} that issues diagnostics if - // someone tries to build any of these groups directly. + // "Fail rule" for obj{} and [h]bmi{} that issues diagnostics if someone + // tries to build these groups directly. // - class fail_rule: public simple_rule + class obj_rule: public simple_rule { public: - fail_rule () {} + obj_rule () {} + + virtual bool + match (action, target&, const string&) const override; + + virtual recipe + apply (action, target&) const override; + }; + + // "Fail rule" for libul{} that issues diagnostics if someone tries to + // build this group directly. + // + class libul_rule: public simple_rule + { + public: + libul_rule () {} virtual bool match (action, target&, const string&) const override; -- cgit v1.1