From ec6be98098b1be030e4512f4f6ea53420e8c53c7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 4 Mar 2017 18:59:01 +0200 Subject: Only set install variables if install module has been loaded While generally a good idea, failing to do this trips up our load generation protection. --- build2/bin/init.cxx | 53 +++++++++++++++++++++++++++++----------------------- build2/cc/module.cxx | 34 +++++++++++++++++++-------------- 2 files changed, 50 insertions(+), 37 deletions(-) diff --git a/build2/bin/init.cxx b/build2/bin/init.cxx index cfad414..9d08b62 100644 --- a/build2/bin/init.cxx +++ b/build2/bin/init.cxx @@ -328,8 +328,8 @@ namespace build2 } bool - init (scope& r, - scope& b, + init (scope& rs, + scope& bs, const location& loc, unique_ptr&, bool, @@ -337,23 +337,25 @@ namespace build2 const variable_map& hints) { tracer trace ("bin::init"); - l5 ([&]{trace << "for " << b.out_path ();}); + l5 ([&]{trace << "for " << bs.out_path ();}); // Load bin.config. // - if (!cast_false (b["bin.config.loaded"])) - load_module (r, b, "bin.config", loc, false, hints); + if (!cast_false (bs["bin.config.loaded"])) + load_module (rs, bs, "bin.config", loc, false, hints); // Cache some config values we will be needing below. // - const string& tclass (cast (r["bin.target.class"])); + const string& tclass (cast (rs["bin.target.class"])); // Register target types and configure their default "installability". // - using namespace install; + bool install_loaded (cast_false (rs["install.loaded"])); { - auto& t (b.target_types); + using namespace install; + + auto& t (bs.target_types); t.insert (); t.insert (); @@ -364,8 +366,11 @@ namespace build2 t.insert (); t.insert (); - install_path (b, dir_path ("lib")); // Install into install.lib. - install_mode (b, "644"); + if (install_loaded) + { + install_path (bs, dir_path ("lib")); // Install in install.lib. + install_mode (bs, "644"); + } // Should shared libraries have the executable bit? That depends on // who you ask. In Debian, for example, it should not unless, it @@ -386,7 +391,9 @@ namespace build2 // Everyone is happy then? On Windows libs{} is the DLL and goes to // bin/, not lib/. // - install_path (b, dir_path (tclass == "windows" ? "bin" : "lib")); + if (install_loaded) + install_path (bs, + dir_path (tclass == "windows" ? "bin" : "lib")); // Create additional target types for certain targets. // @@ -395,15 +402,19 @@ namespace build2 // Import library. // t.insert (); - install_path (b, dir_path ("lib")); - install_mode (b, "644"); + + if (install_loaded) + { + install_path (bs, dir_path ("lib")); + install_mode (bs, "644"); + } } } // Register rules. // { - auto& r (b.rules); + auto& r (bs.rules); r.insert (perform_update_id, "bin.obj", obj_); r.insert (perform_clean_id, "bin.obj", obj_); @@ -415,15 +426,11 @@ namespace build2 // r.insert (configure_update_id, "bin.lib", lib_); - //@@ Should we check if the install module was loaded - // (by checking if install operation is registered - // for this project)? If we do that, then install - // will have to be loaded before bin. Perhaps we - // should enforce loading of all operation-defining - // modules before all others? - // - r.insert (perform_install_id, "bin.lib", lib_); - r.insert (perform_uninstall_id, "bin.lib", lib_); + if (install_loaded) + { + r.insert (perform_install_id, "bin.lib", lib_); + r.insert (perform_uninstall_id, "bin.lib", lib_); + } } return true; diff --git a/build2/cc/module.cxx b/build2/cc/module.cxx index e4fb6d2..7df71ba 100644 --- a/build2/cc/module.cxx +++ b/build2/cc/module.cxx @@ -337,6 +337,8 @@ namespace build2 // Register target types and configure their "installability". // + bool install_loaded (cast_false (rs["install.loaded"])); + { using namespace install; @@ -344,12 +346,14 @@ namespace build2 t.insert (x_src); - // Install headers into install.include. - // for (const target_type* const* ht (x_hdr); *ht != nullptr; ++ht) { t.insert (**ht); - install_path (rs, **ht, dir_path ("include")); + + // Install headers into install.include. + // + if (install_loaded) + install_path (rs, **ht, dir_path ("include")); } } @@ -363,11 +367,8 @@ namespace build2 // We register for configure so that we detect unresolved imports // during configuration rather that later, e.g., during update. // - // @@ Should we check if install module was loaded (see bin)? - // const compile& cr (*this); const link& lr (*this); - const install& ir (*this); r.insert (perform_update_id, x_compile, cr); r.insert (perform_clean_id, x_compile, cr); @@ -377,9 +378,6 @@ namespace build2 r.insert (perform_clean_id, x_link, lr); r.insert (configure_update_id, x_link, lr); - r.insert (perform_install_id, x_install, ir); - r.insert (perform_uninstall_id, x_uninstall, ir); - r.insert (perform_update_id, x_compile, cr); r.insert (perform_clean_id, x_compile, cr); r.insert (configure_update_id, x_compile, cr); @@ -388,9 +386,6 @@ namespace build2 r.insert (perform_clean_id, x_link, lr); r.insert (configure_update_id, x_link, lr); - r.insert (perform_install_id, x_install, ir); - r.insert (perform_uninstall_id, x_uninstall, ir); - r.insert (perform_update_id, x_compile, cr); r.insert (perform_clean_id, x_compile, cr); r.insert (configure_update_id, x_compile, cr); @@ -399,8 +394,19 @@ namespace build2 r.insert (perform_clean_id, x_link, lr); r.insert (configure_update_id, x_link, lr); - r.insert (perform_install_id, x_install, ir); - r.insert (perform_uninstall_id, x_uninstall, ir); + if (install_loaded) + { + const install& ir (*this); + + r.insert (perform_install_id, x_install, ir); + r.insert (perform_uninstall_id, x_uninstall, ir); + + r.insert (perform_install_id, x_install, ir); + r.insert (perform_uninstall_id, x_uninstall, ir); + + r.insert (perform_install_id, x_install, ir); + r.insert (perform_uninstall_id, x_uninstall, ir); + } } } } -- cgit v1.1