From dd3c35fd102018c51d31e75345c4cf8ecab75848 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 7 Mar 2022 21:58:40 +0300 Subject: Determine config.install.root differently for various primary package types --- bbot/worker/worker.cxx | 97 ++++++++++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 43 deletions(-) (limited to 'bbot') diff --git a/bbot/worker/worker.cxx b/bbot/worker/worker.cxx index 18546e4..f2a3994 100644 --- a/bbot/worker/worker.cxx +++ b/bbot/worker/worker.cxx @@ -195,7 +195,7 @@ enum class step_id bpkg_update, bpkg_test, - // Note that separate test packages are configures as part of the + // Note that separate test packages are configured as part of the // bpkg_configure_build step above with options taken from // bpkg_{target,host}_configure_build, depending on tests package type. // @@ -1075,35 +1075,6 @@ build (size_t argc, const char* argv[]) return r; }; - // Search for config.install.root variable. If it is present and has a - // non-empty value, then test the package installation and uninstall. Note - // that passing [null] value would be meaningless, so we don't recognize - // it as a special one. - // - dir_path install_root; - { - size_t n (19); - auto space = [] (char c) {return c == ' ' || c == '\t';}; - - for (const char* s: - reverse_iterate (step_args (config_args, step_id::bpkg_create))) - { - if (strncmp (s, "config.install.root", n) == 0 && - (s[n] == '=' || space (s[n]))) - { - while (space (s[n])) ++n; // Skip spaces. - if (s[n] == '=') ++n; // Skip the equal sign. - while (space (s[n])) ++n; // Skip spaces. - - // Note that the config.install.root variable value may - // potentially be quoted. - // - install_root = dir_path (unquote (s + n)); - break; - } - } - } - // bpkg-rep-fetch trust options. // cstrings trust_ops; @@ -1290,6 +1261,56 @@ build (size_t argc, const char* argv[]) bool host_pkg (!module_pkg && requirement ("host")); bool target_pkg (!module_pkg && !host_pkg); + // Search for config.install.root variable. If it is present and has a + // non-empty value, then test the package installation and uninstall. Note + // that passing [null] value would be meaningless, so we don't recognize + // it as a special one. + // + // Note that the host package can only be installed for a self-hosted + // configuration, using bpkg configuration of the target type. + // + // Also note that the module package is always installed for a self-hosted + // configuration (and never otherwise), using config.install.root + // specified for ~build2 configuration. + // + // If present, indicates that the install, test installed, and uninstall + // operations need to be tested. + // + optional install_root; + + if (target_pkg || selfhost) + { + if (!module_pkg) + { + step_id s (step_id::bpkg_target_create); + step_id f1 (step_id::b_create); + step_id f2 (step_id::bpkg_create); + + size_t n (19); + auto space = [] (char c) {return c == ' ' || c == '\t';}; + + for (const char* a: + reverse_iterate (step_args (config_args, s, f1, f2))) + { + if (strncmp (a, "config.install.root", n) == 0 && + (a[n] == '=' || space (a[n]))) + { + while (space (a[n])) ++n; // Skip spaces. + if (a[n] == '=') ++n; // Skip the equal sign. + while (space (a[n])) ++n; // Skip spaces. + + // Note that the config.install.root variable value may potentially + // be quoted. + // + install_root = dir_path (unquote (a + n)); + break; + } + } + } + else + install_root = dir_path (); + } + // Split external test packages into the runtime and build-time lists. // // Note that runtime and build-time test packages are always configured in @@ -1379,7 +1400,7 @@ build (size_t argc, const char* argv[]) // Create the configuration for installing the main package of the host or // module type, unless it's not supposed to be installed. // - bool create_install (!target_pkg && !install_root.empty () && selfhost); + bool create_install (!target_pkg && install_root); // Root configuration through which we will be configuring the cluster // (note: does not necessarily match the main package type). @@ -2466,17 +2487,7 @@ build (size_t argc, const char* argv[]) // Install the package, optionally test the installation and uninstall // afterwards. // - // These operations are triggered by presence of config.install.root - // configuration variable having a non-empty value for - // bpkg.configure.create step. - // - if (install_root.empty ()) - break; - - // If this is not a self-hosted configuration, then skip installing host - // and module packages. - // - if (!target_pkg && !selfhost) + if (!install_root) break; // Now the overall plan is as follows: @@ -2577,7 +2588,7 @@ build (size_t argc, const char* argv[]) // beginning of the PATH environment variable value, so the installed // executables are found first. // - string paths ("PATH=" + (install_root / "bin").string ()); + string paths ("PATH=" + (*install_root / "bin").string ()); if (optional s = getenv ("PATH")) { -- cgit v1.1