From c0105aad0074aee0efb3ba41f8132496412f8790 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 28 Jan 2020 08:11:16 +0200 Subject: Use scope::insert_rule() --- build2/cli/init.cxx | 14 ++++++-------- libbuild2/bash/init.cxx | 28 ++++++++++++---------------- libbuild2/bin/init.cxx | 4 ++-- libbuild2/config/init.cxx | 22 ++++++++-------------- libbuild2/dist/init.cxx | 4 ++-- libbuild2/in/init.cxx | 22 +++++++++------------- libbuild2/install/init.cxx | 18 ++++++++---------- libbuild2/test/init.cxx | 4 ++-- libbuild2/version/init.cxx | 18 +++++++----------- 9 files changed, 56 insertions(+), 78 deletions(-) diff --git a/build2/cli/init.cxx b/build2/cli/init.cxx index 89da97a..23ebd83 100644 --- a/build2/cli/init.cxx +++ b/build2/cli/init.cxx @@ -343,20 +343,18 @@ namespace build2 // Register our rules. // { - auto& r (bs.rules); - - auto reg = [&r] (meta_operation_id mid, operation_id oid) + auto reg = [&bs] (meta_operation_id mid, operation_id oid) { - r.insert (mid, oid, "cli.compile", compile_rule_); - r.insert (mid, oid, "cli.compile", compile_rule_); - r.insert (mid, oid, "cli.compile", compile_rule_); - r.insert (mid, oid, "cli.compile", compile_rule_); + bs.insert_rule (mid, oid, "cli.compile", compile_rule_); + bs.insert_rule (mid, oid, "cli.compile", compile_rule_); + bs.insert_rule (mid, oid, "cli.compile", compile_rule_); + bs.insert_rule (mid, oid, "cli.compile", compile_rule_); }; reg (perform_id, update_id); reg (perform_id, clean_id); - // Other rules (e.g., cxx::compile) may need to have the group members + // Other rules (e.g., cc::compile) may need to have the group members // resolved/linked up. Looks like a general pattern: groups should // resolve on *(update). // diff --git a/libbuild2/bash/init.cxx b/libbuild2/bash/init.cxx index dc1f8f6..ed84265 100644 --- a/libbuild2/bash/init.cxx +++ b/libbuild2/bash/init.cxx @@ -64,25 +64,21 @@ namespace build2 // Register rules. // - { - auto& r (bs.rules); - - r.insert (perform_update_id, "bash.in", in_rule_); - r.insert (perform_clean_id, "bash.in", in_rule_); - r.insert (configure_update_id, "bash.in", in_rule_); + bs.insert_rule (perform_update_id, "bash.in", in_rule_); + bs.insert_rule (perform_clean_id, "bash.in", in_rule_); + bs.insert_rule (configure_update_id, "bash.in", in_rule_); - r.insert (perform_update_id, "bash.in", in_rule_); - r.insert (perform_clean_id, "bash.in", in_rule_); - r.insert (configure_update_id, "bash.in", in_rule_); + bs.insert_rule (perform_update_id, "bash.in", in_rule_); + bs.insert_rule (perform_clean_id, "bash.in", in_rule_); + bs.insert_rule (configure_update_id, "bash.in", in_rule_); - if (install_loaded) - { - r.insert (perform_install_id, "bash.install", install_rule_); - r.insert (perform_uninstall_id, "bash.uninstall", install_rule_); + if (install_loaded) + { + bs.insert_rule (perform_install_id, "bash.install", install_rule_); + bs.insert_rule (perform_uninstall_id, "bash.uninstall", install_rule_); - r.insert (perform_install_id, "bash.install", install_rule_); - r.insert (perform_uninstall_id, "bash.uninstall", install_rule_); - } + bs.insert_rule (perform_install_id, "bash.install", install_rule_); + bs.insert_rule (perform_uninstall_id, "bash.uninstall", install_rule_); } return true; diff --git a/libbuild2/bin/init.cxx b/libbuild2/bin/init.cxx index c0681cc..a4d51e5 100644 --- a/libbuild2/bin/init.cxx +++ b/libbuild2/bin/init.cxx @@ -536,7 +536,7 @@ namespace build2 // //@@ outer - r.insert (perform_id, 0, "bin.lib", lib_); + r.insert (perform_id, 0, "bin.lib", lib_); r.insert (configure_id, 0, "bin.lib", lib_); // Treat as a see through group for install, test, and dist. @@ -545,7 +545,7 @@ namespace build2 { auto& gr (install::group_rule::instance); - r.insert (perform_install_id, "bin.lib", gr); + r.insert (perform_install_id, "bin.lib", gr); r.insert (perform_uninstall_id, "bin.lib", gr); } diff --git a/libbuild2/config/init.cxx b/libbuild2/config/init.cxx index d48e0a8..56aed15 100644 --- a/libbuild2/config/init.cxx +++ b/libbuild2/config/init.cxx @@ -279,22 +279,16 @@ namespace build2 // libraries imported from /usr/lib). We are registring it on the // global scope similar to builtin rules. // - { - auto& r (rs.global_scope ().rules); - r.insert ( - configure_id, 0, "config.file", file_rule::instance); - } - { - auto& r (rs.rules); + rs.global_scope ().insert_rule ( + configure_id, 0, "config.file", file_rule::instance); - //@@ outer - r.insert (configure_id, 0, "config.alias", alias_rule::instance); + //@@ outer + rs.insert_rule (configure_id, 0, "config.alias", alias_rule::instance); - // This allows a custom configure rule while doing nothing by default. - // - r.insert (configure_id, 0, "config", noop_rule::instance); - r.insert (configure_id, 0, "config.file", noop_rule::instance); - } + // This allows a custom configure rule while doing nothing by default. + // + rs.insert_rule (configure_id, 0, "config", noop_rule::instance); + rs.insert_rule (configure_id, 0, "config.file", noop_rule::instance); return true; } diff --git a/libbuild2/dist/init.cxx b/libbuild2/dist/init.cxx index bea8917..efbd5d7 100644 --- a/libbuild2/dist/init.cxx +++ b/libbuild2/dist/init.cxx @@ -106,8 +106,8 @@ namespace build2 // Register our wildcard rule. Do it explicitly for the alias to prevent // something like insert(dist_id, test_id) taking precedence. // - rs.rules.insert (dist_id, 0, "dist", rule_); - rs.rules.insert (dist_id, 0, "dist.alias", rule_); //@@ outer? + rs.insert_rule (dist_id, 0, "dist", rule_); + rs.insert_rule (dist_id, 0, "dist.alias", rule_); //@@ outer? // Configuration. // diff --git a/libbuild2/in/init.cxx b/libbuild2/in/init.cxx index 95bdb0a..80508b6 100644 --- a/libbuild2/in/init.cxx +++ b/libbuild2/in/init.cxx @@ -88,19 +88,15 @@ namespace build2 // Register rules. // - { - auto& r (bs.rules); - - // There are rules that are "derived" from this generic in rule in - // order to provide extended preprocessing functionality (see the - // version module for an example). To make sure they are tried first - // we register for path_target, not file, but in rule::match() we only - // match if the target is a file. A bit of a hack. - // - r.insert (perform_update_id, "in", rule_); - r.insert (perform_clean_id, "in", rule_); - r.insert (configure_update_id, "in", rule_); - } + // There are rules that are "derived" from this generic in rule in + // order to provide extended preprocessing functionality (see the + // version module for an example). To make sure they are tried first + // we register for path_target, not file, but in rule::match() we only + // match if the target is a file. A bit of a hack. + // + bs.insert_rule (perform_update_id, "in", rule_); + bs.insert_rule (perform_clean_id, "in", rule_); + bs.insert_rule (configure_update_id, "in", rule_); return true; } diff --git a/libbuild2/install/init.cxx b/libbuild2/install/init.cxx index 1054e83..98eec91 100644 --- a/libbuild2/install/init.cxx +++ b/libbuild2/install/init.cxx @@ -216,24 +216,22 @@ namespace build2 // Register our rules. // { - auto& r (bs.rules); - const auto& ar (alias_rule::instance); const auto& dr (fsdir_rule::instance); const auto& fr (file_rule::instance); const auto& gr (group_rule_); - r.insert (perform_install_id, "install.alias", ar); - r.insert (perform_uninstall_id, "uninstall.alias", ar); + bs.insert_rule (perform_install_id, "install.alias", ar); + bs.insert_rule (perform_uninstall_id, "uninstall.alias", ar); - r.insert (perform_install_id, "install.fsdir", dr); - r.insert (perform_uninstall_id, "install.fsdir", dr); + bs.insert_rule (perform_install_id, "install.fsdir", dr); + bs.insert_rule (perform_uninstall_id, "install.fsdir", dr); - r.insert (perform_install_id, "install.file", fr); - r.insert (perform_uninstall_id, "uninstall.file", fr); + bs.insert_rule (perform_install_id, "install.file", fr); + bs.insert_rule (perform_uninstall_id, "uninstall.file", fr); - r.insert (perform_install_id, "install.file", gr); - r.insert (perform_uninstall_id, "uninstall.file", gr); + bs.insert_rule (perform_install_id, "install.file", gr); + bs.insert_rule (perform_uninstall_id, "uninstall.file", gr); } // Configuration. diff --git a/libbuild2/test/init.cxx b/libbuild2/test/init.cxx index af112fb..3bcbe96 100644 --- a/libbuild2/test/init.cxx +++ b/libbuild2/test/init.cxx @@ -214,8 +214,8 @@ namespace build2 { default_rule& dr (m); - rs.rules.insert (perform_test_id, "test", dr); - rs.rules.insert (perform_test_id, "test", dr); + rs.insert_rule (perform_test_id, "test", dr); + rs.insert_rule (perform_test_id, "test", dr); } return true; diff --git a/libbuild2/version/init.cxx b/libbuild2/version/init.cxx index 3ab3621..ea4c71a 100644 --- a/libbuild2/version/init.cxx +++ b/libbuild2/version/init.cxx @@ -342,18 +342,14 @@ namespace build2 // Register rules. // - { - auto& r (rs.rules); - - r.insert (perform_update_id, "version.in", in_rule_); - r.insert (perform_clean_id, "version.in", in_rule_); - r.insert (configure_update_id, "version.in", in_rule_); + rs.insert_rule (perform_update_id, "version.in", in_rule_); + rs.insert_rule (perform_clean_id, "version.in", in_rule_); + rs.insert_rule (configure_update_id, "version.in", in_rule_); - if (cast_false (rs["install.booted"])) - { - r.insert ( - perform_install_id, "version.manifest", manifest_install_rule_); - } + if (cast_false (rs["install.booted"])) + { + rs.insert_rule ( + perform_install_id, "version.manifest", manifest_install_rule_); } return true; -- cgit v1.1