From e0c4d1dc2b6bc5ee238ea94cd0803855a337efdf Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 12 Apr 2016 15:36:24 +0200 Subject: Set common variables in pkg-* commands on the whole configuration This makes a difference, for example, in pkg-install where install.root is needed by prerequisites. --- bpkg/cfg-create.cxx | 2 +- bpkg/pkg-clean.cli | 4 ++-- bpkg/pkg-command.cxx | 19 ++++++++++--------- bpkg/pkg-configure.cxx | 2 +- bpkg/pkg-disfigure.cxx | 2 +- bpkg/pkg-install.cli | 7 ++++--- bpkg/pkg-test.cli | 4 ++-- bpkg/pkg-uninstall.cli | 6 +++--- bpkg/pkg-update.cli | 4 ++-- bpkg/utility | 10 ++++++---- bpkg/utility.cxx | 23 ++++++++++++++++++----- 11 files changed, 50 insertions(+), 33 deletions(-) diff --git a/bpkg/cfg-create.cxx b/bpkg/cfg-create.cxx index 0215e5d..e50da8d 100644 --- a/bpkg/cfg-create.cxx +++ b/bpkg/cfg-create.cxx @@ -136,7 +136,7 @@ namespace bpkg // Configure. // - run_b (o, "configure(" + c.string () + "/)", true, vars); // Run quiet. + run_b (o, c, "configure(" + c.string () + "/)", true, vars); // Run quiet. // Create the database. // diff --git a/bpkg/pkg-clean.cli b/bpkg/pkg-clean.cli index 1161b13..e03138e 100644 --- a/bpkg/pkg-clean.cli +++ b/bpkg/pkg-clean.cli @@ -25,8 +25,8 @@ namespace bpkg Additional command line variables (, normally \cb{config.*}) can be passed to the build system by either specifying them before the packages, - in which case they apply to all of them, or after a specific package, in - which case they apply only to this package." + in which case they apply to the whole configuration, or after a specific + package, in which case they apply only to this package." } class pkg_clean_options: configuration_options diff --git a/bpkg/pkg-command.cxx b/bpkg/pkg-command.cxx index ef473f0..57c3f53 100644 --- a/bpkg/pkg-command.cxx +++ b/bpkg/pkg-command.cxx @@ -31,16 +31,17 @@ namespace bpkg // string bspec; - auto run = [&trace, &o, &cvars, &bspec](const strings& vars = strings ()) + auto run = + [&trace, &c, &o, &cvars, &bspec] ( const strings& vars = strings ()) + { + if (!bspec.empty ()) { - if (!bspec.empty ()) - { - bspec += ')'; - l4 ([&]{trace << "buildspec: " << bspec;}); - run_b (o, bspec, false, cvars, vars); - bspec.clear (); - } - }; + bspec += ')'; + l4 ([&]{trace << "buildspec: " << bspec;}); + run_b (o, c, bspec, false, vars, cvars); + bspec.clear (); + } + }; for (const pkg_command_vars& pv: ps) { diff --git a/bpkg/pkg-configure.cxx b/bpkg/pkg-configure.cxx index 4206992..1dbf94b 100644 --- a/bpkg/pkg-configure.cxx +++ b/bpkg/pkg-configure.cxx @@ -116,7 +116,7 @@ namespace bpkg // try { - run_b (o, bspec, true, vars); // Run quiet. + run_b (o, c, bspec, true, vars); // Run quiet. } catch (const failed&) { diff --git a/bpkg/pkg-disfigure.cxx b/bpkg/pkg-disfigure.cxx index be2ed8b..282bc82 100644 --- a/bpkg/pkg-disfigure.cxx +++ b/bpkg/pkg-disfigure.cxx @@ -98,7 +98,7 @@ namespace bpkg try { if (exists (out_root)) - run_b (o, bspec, true); // Run quiet. + run_b (o, c, bspec, true); // Run quiet. // Make sure the out directory is gone unless it is the same as src. // diff --git a/bpkg/pkg-install.cli b/bpkg/pkg-install.cli index 24ccc43..c612d23 100644 --- a/bpkg/pkg-install.cli +++ b/bpkg/pkg-install.cli @@ -24,9 +24,10 @@ namespace bpkg Additional command line variables (, normally \cb{config.*}) can be passed to the build system by either specifying them before the packages, - in which case they apply to all of them, or after a specific package, in - which case they apply only to this package. Specifically, this mechanism - can be used to specify the installation directory, for example: + in which case they apply to the whole configuration, or after a specific + package, in which case they apply only to this package. In particular, + this mechanism can be used to specify the installation directory, for + example: \ bpkg install config.install.root=/usr/local \ diff --git a/bpkg/pkg-test.cli b/bpkg/pkg-test.cli index e04ba5f..574da31 100644 --- a/bpkg/pkg-test.cli +++ b/bpkg/pkg-test.cli @@ -25,8 +25,8 @@ namespace bpkg Additional command line variables (, normally \cb{config.*}) can be passed to the build system by either specifying them before the packages, - in which case they apply to all of them, or after a specific package, in - which case they apply only to this package." + in which case they apply to the whole configuration, or after a specific + package, in which case they apply only to this package." } class pkg_test_options: configuration_options diff --git a/bpkg/pkg-uninstall.cli b/bpkg/pkg-uninstall.cli index ba7f55a..ece8f1e 100644 --- a/bpkg/pkg-uninstall.cli +++ b/bpkg/pkg-uninstall.cli @@ -25,9 +25,9 @@ namespace bpkg Additional command line variables (, normally \cb{config.*}) can be passed to the build system by either specifying them before the packages, - in which case they apply to all of them, or after a specific package, in - which case they apply only to this package. See \l{bpkg-pkg-install(1)} - for some examples." + in which case they apply to the whole configuration, or after a specific + package, in which case they apply only to this package. See + \l{bpkg-pkg-install(1)} for some examples." } class pkg_uninstall_options: configuration_options diff --git a/bpkg/pkg-update.cli b/bpkg/pkg-update.cli index 6a387be..9383ad4 100644 --- a/bpkg/pkg-update.cli +++ b/bpkg/pkg-update.cli @@ -25,8 +25,8 @@ namespace bpkg Additional command line variables (, normally \cb{config.*}) can be passed to the build system by either specifying them before the packages, - in which case they apply to all of them, or after a specific package, in - which case they apply only to this package." + in which case they apply to the whole configuration, or after a specific + package, in which case they apply only to this package." } class pkg_update_options: configuration_options diff --git a/bpkg/utility b/bpkg/utility index 3b2a11f..009ef76 100644 --- a/bpkg/utility +++ b/bpkg/utility @@ -79,17 +79,19 @@ namespace bpkg inline void run (const cstrings& args) {run (args.data ());} - // Run build2, mapping verbosity levels. If quiet is true, then - // run build2 quiet if our verbosity level is 1. + // Run build2, mapping verbosity levels. If quiet is true, then run build2 + // quiet if our verbosity level is 1. Common vars (cvars) are set on the + // configuration scope. // class common_options; void run_b (const common_options&, + const dir_path& configuration, const string& buildspec, bool quiet = false, - const strings& vars1 = strings (), - const strings& vars2 = strings ()); + const strings& pvars = strings (), + const strings& cvars = strings ()); // Call a function if there is an exception. // diff --git a/bpkg/utility.cxx b/bpkg/utility.cxx index f6cbc45..57a299b 100644 --- a/bpkg/utility.cxx +++ b/bpkg/utility.cxx @@ -190,10 +190,11 @@ namespace bpkg void run_b (const common_options& co, + const dir_path& c, const string& bspec, bool quiet, - const strings& vars1, - const strings& vars2) + const strings& pvars, + const strings& cvars) { cstrings args {co.build ().string ().c_str ()}; @@ -220,10 +221,22 @@ namespace bpkg // Add config vars. // - for (const string& v: vars1) - args.push_back (v.c_str ()); + strings storage; + storage.reserve (cvars.size ()); + for (const string& v: cvars) + { + // Don't scope-qualify global variables. + // + if (v[0] != '!') + { + storage.push_back (c.string () + "/:" + v); + args.push_back (storage.back ().c_str ()); + } + else + args.push_back (v.c_str ()); + } - for (const string& v: vars2) + for (const string& v: pvars) args.push_back (v.c_str ()); // Add buildspec. -- cgit v1.1