From 2b6ae9f528504897bc24803d95bbb6da61a2a85b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 8 Dec 2015 11:01:26 +0200 Subject: Add support for --build, --build-option common options --- bpkg/build.cxx | 6 +++--- bpkg/cfg-create.cxx | 2 +- bpkg/common-options.cli | 18 ++++++++++++++++++ bpkg/drop.cxx | 2 +- bpkg/pkg-command | 1 + bpkg/pkg-command.cxx | 5 +++-- bpkg/pkg-configure | 1 + bpkg/pkg-configure.cxx | 7 ++++--- bpkg/pkg-disfigure | 1 + bpkg/pkg-disfigure.cxx | 5 +++-- bpkg/pkg-update | 3 ++- bpkg/utility | 4 +++- bpkg/utility.cxx | 12 ++++++++++-- 13 files changed, 51 insertions(+), 16 deletions(-) diff --git a/bpkg/build.cxx b/bpkg/build.cxx index 86219dd..3cb96f4 100644 --- a/bpkg/build.cxx +++ b/bpkg/build.cxx @@ -1057,7 +1057,7 @@ namespace bpkg // always leave the configuration in a valid state. // transaction t (db.begin ()); - pkg_disfigure (c, t, sp); // Commits the transaction. + pkg_disfigure (c, o, t, sp); // Commits the transaction. assert (sp->state == package_state::unpacked); if (verb) @@ -1158,7 +1158,7 @@ namespace bpkg continue; transaction t (db.begin ()); - pkg_configure (c, t, sp, strings ()); // Commits the transaction. + pkg_configure (c, o, t, sp, strings ()); // Commits the transaction. assert (sp->state == package_state::configured); if (verb) @@ -1213,7 +1213,7 @@ namespace bpkg if (find (names.begin (), names.end (), sp->name) == names.end ()) continue; - pkg_update (c, sp); + pkg_update (c, o, sp); if (verb) text << "updated " << sp->name << " " << sp->version; diff --git a/bpkg/cfg-create.cxx b/bpkg/cfg-create.cxx index c98dd28..b25100b 100644 --- a/bpkg/cfg-create.cxx +++ b/bpkg/cfg-create.cxx @@ -113,7 +113,7 @@ namespace bpkg // Configure. // - run_b ("configure(" + c.string () + "/)", true, vars); // Run quiet. + run_b (o, "configure(" + c.string () + "/)", true, vars); // Run quiet. // Create the database. // diff --git a/bpkg/common-options.cli b/bpkg/common-options.cli index ab4d5fa..02cc605 100644 --- a/bpkg/common-options.cli +++ b/bpkg/common-options.cli @@ -72,6 +72,24 @@ namespace bpkg \li|even more detailed information||" } + path --build = "b" + { + "", + "The build program to be used to build packages. This should be the path + to the build2 \cb{b} executable. You can also specify additional options + that should be passed to the build program with \cb{--build-option}. If + the build program is not explicitly specified, then \cb{bpkg} will use + \cb{b} by default." + } + + strings --build-option + { + "", + "Additional option to be passed to the build program. See \cb{--build} + for more information on the build program. Repeat this option to specify + multiple build options." + } + path --fetch { "", diff --git a/bpkg/drop.cxx b/bpkg/drop.cxx index 6728d09..87c475d 100644 --- a/bpkg/drop.cxx +++ b/bpkg/drop.cxx @@ -476,7 +476,7 @@ namespace bpkg // always leave the configuration in a valid state. // transaction t (db.begin ()); - pkg_disfigure (c, t, p); // Commits the transaction. + pkg_disfigure (c, o, t, p); // Commits the transaction. assert (p->state == package_state::unpacked); if (verb) diff --git a/bpkg/pkg-command b/bpkg/pkg-command index 724caa8..4acbdf4 100644 --- a/bpkg/pkg-command +++ b/bpkg/pkg-command @@ -21,6 +21,7 @@ namespace bpkg void pkg_command (const string& cmd, const dir_path& configuration, + const common_options&, const shared_ptr&); } diff --git a/bpkg/pkg-command.cxx b/bpkg/pkg-command.cxx index 253ee66..281b326 100644 --- a/bpkg/pkg-command.cxx +++ b/bpkg/pkg-command.cxx @@ -19,6 +19,7 @@ namespace bpkg void pkg_command (const string& cmd, const dir_path& c, + const common_options& o, const shared_ptr& p) { tracer trace ("pkg_command"); @@ -36,7 +37,7 @@ namespace bpkg string bspec (cmd + "(" + out_root.string () + "/)"); level4 ([&]{trace << "buildspec: " << bspec;}); - run_b (bspec); + run_b (o, bspec); } int @@ -70,7 +71,7 @@ namespace bpkg level4 ([&]{trace << p->name << " " << p->version;}); - pkg_command (cmd, c, p); + pkg_command (cmd, c, o, p); if (verb) text << cmd << (cmd.back () != 'e' ? "ed " : "d ") diff --git a/bpkg/pkg-configure b/bpkg/pkg-configure index df2fc40..eebad85 100644 --- a/bpkg/pkg-configure +++ b/bpkg/pkg-configure @@ -18,6 +18,7 @@ namespace bpkg // void pkg_configure (const dir_path& configuration, + const common_options&, transaction&, const shared_ptr&, const strings& config_vars); diff --git a/bpkg/pkg-configure.cxx b/bpkg/pkg-configure.cxx index 9e478c8..7a808e2 100644 --- a/bpkg/pkg-configure.cxx +++ b/bpkg/pkg-configure.cxx @@ -22,6 +22,7 @@ namespace bpkg { void pkg_configure (const dir_path& c, + const common_options& o, transaction& t, const shared_ptr& p, const strings& vars) @@ -117,7 +118,7 @@ namespace bpkg // try { - run_b (bspec, true, vars); // Run quiet. + run_b (o, bspec, true, vars); // Run quiet. } catch (const failed&) { @@ -133,7 +134,7 @@ namespace bpkg p->out_root = out_root.leaf (); p->state = package_state::broken; - pkg_disfigure (c, t, p); // Commits the transaction. + pkg_disfigure (c, o, t, p); // Commits the transaction. throw; } @@ -188,7 +189,7 @@ namespace bpkg level4 ([&]{trace << p->name << " " << p->version;}); - pkg_configure (c, t, p, vars); // Commits the transaction. + pkg_configure (c, o, t, p, vars); // Commits the transaction. if (verb) text << "configured " << p->name << " " << p->version; diff --git a/bpkg/pkg-disfigure b/bpkg/pkg-disfigure index 2833522..782f81d 100644 --- a/bpkg/pkg-disfigure +++ b/bpkg/pkg-disfigure @@ -22,6 +22,7 @@ namespace bpkg // void pkg_disfigure (const dir_path& configuration, + const common_options&, transaction&, const shared_ptr&); } diff --git a/bpkg/pkg-disfigure.cxx b/bpkg/pkg-disfigure.cxx index 465213b..a8ca60f 100644 --- a/bpkg/pkg-disfigure.cxx +++ b/bpkg/pkg-disfigure.cxx @@ -18,6 +18,7 @@ namespace bpkg { void pkg_disfigure (const dir_path& c, + const common_options& o, transaction& t, const shared_ptr& p) { @@ -99,7 +100,7 @@ namespace bpkg try { if (exists (out_root)) - run_b (bspec, true); // Run quiet. + run_b (o, bspec, true); // Run quiet. // Make sure the out directory is gone unless it is the same as src. // @@ -155,7 +156,7 @@ namespace bpkg level4 ([&]{trace << p->name << " " << p->version;}); - pkg_disfigure (c, t, p); // Commits the transaction. + pkg_disfigure (c, o, t, p); // Commits the transaction. if (verb) text << "disfigured " << p->name << " " << p->version; diff --git a/bpkg/pkg-update b/bpkg/pkg-update index a266da3..f755964 100644 --- a/bpkg/pkg-update +++ b/bpkg/pkg-update @@ -20,9 +20,10 @@ namespace bpkg inline void pkg_update (const dir_path& configuration, + const common_options& o, const shared_ptr& p) { - pkg_command ("update", configuration, p); + pkg_command ("update", configuration, o, p); } } diff --git a/bpkg/utility b/bpkg/utility index 3e11bc4..b29d066 100644 --- a/bpkg/utility +++ b/bpkg/utility @@ -13,6 +13,7 @@ #include #include +#include namespace bpkg { @@ -69,7 +70,8 @@ namespace bpkg // run build2 quiet if our verbosity level is 1. // void - run_b (const string& buildspec, + run_b (const common_options&, + const string& buildspec, bool quiet = false, const strings& vars = strings ()); diff --git a/bpkg/utility.cxx b/bpkg/utility.cxx index 9954067..099b56d 100644 --- a/bpkg/utility.cxx +++ b/bpkg/utility.cxx @@ -190,9 +190,12 @@ namespace bpkg } void - run_b (const string& bspec, bool quiet, const strings& vars) + run_b (const common_options& co, + const string& bspec, + bool quiet, + const strings& vars) { - cstrings args {"b"}; + cstrings args {co.build ().string ().c_str ()}; // Map verbosity level. If we are running quiet or at level 1, // then run build2 quiet. Otherwise, run it at the same level @@ -210,6 +213,11 @@ namespace bpkg args.push_back (vl.c_str ()); } + // Add user options. + // + for (const string& o: co.build_option ()) + args.push_back (o.c_str ()); + // Add config vars. // for (const string& v: vars) -- cgit v1.1