aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-09-17 13:52:35 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-09-17 13:52:35 +0200
commit01a3fda266073b58a4de6dd61417bb2d0e3ecf9e (patch)
tree39f0b573a5b18fa6375805857d08bac6118cf70e
parent5de2e18ab39d52818554ea344eacd6e0c4b72aa3 (diff)
Add run_b() function to run build2
-rw-r--r--bpkg/cfg-create.cxx33
-rw-r--r--bpkg/utility5
-rw-r--r--bpkg/utility.cxx34
3 files changed, 40 insertions, 32 deletions
diff --git a/bpkg/cfg-create.cxx b/bpkg/cfg-create.cxx
index 2fa001c..f56754a 100644
--- a/bpkg/cfg-create.cxx
+++ b/bpkg/cfg-create.cxx
@@ -112,38 +112,7 @@ namespace bpkg
// Configure.
//
- {
- cstrings args {"b"};
-
- // Map verbosity level. If we are running quiet or at level 1,
- // then run build2 quiet. Otherwise, run it at the same level
- // as us.
- //
- string vl;
- if (verb <= 1)
- args.push_back ("-q");
- else if (verb == 2)
- args.push_back ("-v");
- else
- {
- vl = to_string (verb);
- args.push_back ("--verbose");
- args.push_back (vl.c_str ());
- }
-
- // Add config vars.
- //
- for (const string& v: vars)
- args.push_back (v.c_str ());
-
- // Add buildspec.
- //
- string bspec ("configure(" + d.string () + "/)");
- args.push_back (bspec.c_str ());
-
- args.push_back (nullptr);
- run (args);
- }
+ run_b ("configure(" + d.string () + "/)", vars);
// Create the database.
//
diff --git a/bpkg/utility b/bpkg/utility
index d1aebb1..ffe5b94 100644
--- a/bpkg/utility
+++ b/bpkg/utility
@@ -48,6 +48,11 @@ namespace bpkg
inline void
run (const cstrings& args) {run (args.data ());}
+ // Run build2, mapping verbosity levels.
+ //
+ void
+ run_b (const string& buildspec, const strings& vars = strings ());
+
// Call a function if there is an exception.
//
diff --git a/bpkg/utility.cxx b/bpkg/utility.cxx
index d9e0413..b122545 100644
--- a/bpkg/utility.cxx
+++ b/bpkg/utility.cxx
@@ -150,5 +150,39 @@ namespace bpkg
}
}
+ void
+ run_b (const string& bspec, const strings& vars)
+ {
+ cstrings args {"b"};
+
+ // Map verbosity level. If we are running quiet or at level 1,
+ // then run build2 quiet. Otherwise, run it at the same level
+ // as us.
+ //
+ string vl;
+ if (verb <= 1)
+ args.push_back ("-q");
+ else if (verb == 2)
+ args.push_back ("-v");
+ else
+ {
+ vl = to_string (verb);
+ args.push_back ("--verbose");
+ args.push_back (vl.c_str ());
+ }
+
+ // Add config vars.
+ //
+ for (const string& v: vars)
+ args.push_back (v.c_str ());
+
+ // Add buildspec.
+ //
+ args.push_back (bspec.c_str ());
+
+ args.push_back (nullptr);
+ run (args);
+ }
+
bool exception_unwinding_dtor = false;
}