aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbutl/b.cxx27
-rw-r--r--libbutl/b.hxx36
-rw-r--r--libbutl/b.ixx31
-rw-r--r--libbutl/filesystem.ixx26
-rw-r--r--libbutl/path-pattern.ixx26
-rw-r--r--tests/b-info/driver.cxx15
6 files changed, 111 insertions, 50 deletions
diff --git a/libbutl/b.cxx b/libbutl/b.cxx
index ee5c8a5..3d78803 100644
--- a/libbutl/b.cxx
+++ b/libbutl/b.cxx
@@ -35,7 +35,7 @@ namespace butl
void
b_info (std::vector<b_project_info>& r,
const vector<dir_path>& projects,
- bool ext_mods,
+ b_info_flags fl,
uint16_t verb,
const function<b_callback>& cmd_callback,
const path& program,
@@ -81,13 +81,20 @@ namespace butl
else
vops.push_back ("-q");
- vector<string> ps;
- ps.reserve (projects.size ());
+ string spec ("info(");
- // Note that quoting is essential here.
- //
- for (const dir_path& p: projects)
- ps.push_back ('\'' + p.representation () + '\'');
+ for (size_t i (0); i != projects.size(); ++i)
+ {
+ if (i != 0)
+ spec += ' ';
+
+ spec += '\'' + projects[i].representation () + '\'';
+ }
+
+ if ((fl & b_info_flags::subprojects) == b_info_flags::none)
+ spec += ",no_subprojects";
+
+ spec += ')';
pr = process_start_callback (
cmd_callback ? cmd_callback : [] (const char* const*, size_t) {},
@@ -96,10 +103,12 @@ namespace butl
2 /* stderr */,
pp,
vops,
- ext_mods ? nullptr : "--no-external-modules",
+ ((fl & b_info_flags::ext_mods) == b_info_flags::none
+ ? "--no-external-modules"
+ : nullptr),
"-s",
ops,
- "info:", ps);
+ spec);
pipe.out.close ();
ifdstream is (move (pipe.in), fdstream_mode::skip, ifdstream::badbit);
diff --git a/libbutl/b.hxx b/libbutl/b.hxx
index cc3a309..d3fd2bf 100644
--- a/libbutl/b.hxx
+++ b/libbutl/b.hxx
@@ -51,11 +51,6 @@ namespace butl
// result vector can be used to determine which project information caused
// the error.
//
- // Unless you need information that may come from external modules
- // (operations, meta-operations, etc), pass false as the ext_mods argument,
- // which results in passing --no-external-modules to the build2 program and
- // speeds up its execution.
- //
// You can also specify the build2 verbosity level, command line callback
// (see process_run_callback() for details), build program search details,
// and additional options.
@@ -92,12 +87,35 @@ namespace butl
std::vector<std::string> modules;
};
+ enum class b_info_flags: std::uint16_t
+ {
+ // Retrieve information that may come from external modules (operations,
+ // meta-operations, etc). Omitting this flag results in passing
+ // --no-external-modules to the build2 program and speeds up its
+ // execution.
+ //
+ ext_mods = 0x1,
+
+ // Discover subprojects. Omitting this flag results in passing
+ // no_subprojects info meta-operation parameter to the build2 program and
+ // speeds up its execution.
+ //
+ subprojects = 0x2,
+
+ none = 0
+ };
+
+ inline b_info_flags operator& (b_info_flags, b_info_flags);
+ inline b_info_flags operator| (b_info_flags, b_info_flags);
+ inline b_info_flags operator&= (b_info_flags&, b_info_flags);
+ inline b_info_flags operator|= (b_info_flags&, b_info_flags);
+
using b_callback = void (const char* const args[], std::size_t n);
LIBBUTL_SYMEXPORT void
b_info (std::vector<b_project_info>& result,
const std::vector<dir_path>& projects,
- bool ext_mods,
+ b_info_flags,
std::uint16_t verb = 1,
const std::function<b_callback>& cmd_callback = {},
const path& program = path ("b"),
@@ -108,7 +126,7 @@ namespace butl
//
inline b_project_info
b_info (const dir_path& project,
- bool ext_mods,
+ b_info_flags fl,
std::uint16_t verb = 1,
const std::function<b_callback>& cmd_callback = {},
const path& program = path ("b"),
@@ -118,7 +136,7 @@ namespace butl
std::vector<b_project_info> r;
b_info (r,
std::vector<dir_path> ({project}),
- ext_mods,
+ fl,
verb,
cmd_callback,
program,
@@ -128,3 +146,5 @@ namespace butl
return std::move (r[0]);
}
}
+
+#include <libbutl/b.ixx>
diff --git a/libbutl/b.ixx b/libbutl/b.ixx
new file mode 100644
index 0000000..1667101
--- /dev/null
+++ b/libbutl/b.ixx
@@ -0,0 +1,31 @@
+// file : libbutl/b.ixx -*- C++ -*-
+// license : MIT; see accompanying LICENSE file
+
+namespace butl
+{
+ // b_info_flags
+ //
+ inline b_info_flags operator& (b_info_flags x, b_info_flags y)
+ {
+ return x &= y;
+ }
+
+ inline b_info_flags operator| (b_info_flags x, b_info_flags y)
+ {
+ return x |= y;
+ }
+
+ inline b_info_flags operator&= (b_info_flags& x, b_info_flags y)
+ {
+ return x = static_cast<b_info_flags> (
+ static_cast<std::uint16_t> (x) &
+ static_cast<std::uint16_t> (y));
+ }
+
+ inline b_info_flags operator|= (b_info_flags& x, b_info_flags y)
+ {
+ return x = static_cast<b_info_flags> (
+ static_cast<std::uint16_t> (x) |
+ static_cast<std::uint16_t> (y));
+ }
+}
diff --git a/libbutl/filesystem.ixx b/libbutl/filesystem.ixx
index 193eae9..79607d7 100644
--- a/libbutl/filesystem.ixx
+++ b/libbutl/filesystem.ixx
@@ -137,32 +137,6 @@ namespace butl
static_cast<std::uint16_t> (y));
}
- // path_match_flags
- //
- inline path_match_flags operator& (path_match_flags x, path_match_flags y)
- {
- return x &= y;
- }
-
- inline path_match_flags operator| (path_match_flags x, path_match_flags y)
- {
- return x |= y;
- }
-
- inline path_match_flags operator&= (path_match_flags& x, path_match_flags y)
- {
- return x = static_cast<path_match_flags> (
- static_cast<std::uint16_t> (x) &
- static_cast<std::uint16_t> (y));
- }
-
- inline path_match_flags operator|= (path_match_flags& x, path_match_flags y)
- {
- return x = static_cast<path_match_flags> (
- static_cast<std::uint16_t> (x) |
- static_cast<std::uint16_t> (y));
- }
-
// dir_entry
//
inline entry_type dir_entry::
diff --git a/libbutl/path-pattern.ixx b/libbutl/path-pattern.ixx
index 71f125c..6fee31e 100644
--- a/libbutl/path-pattern.ixx
+++ b/libbutl/path-pattern.ixx
@@ -3,6 +3,32 @@
namespace butl
{
+ // path_match_flags
+ //
+ inline path_match_flags operator& (path_match_flags x, path_match_flags y)
+ {
+ return x &= y;
+ }
+
+ inline path_match_flags operator| (path_match_flags x, path_match_flags y)
+ {
+ return x |= y;
+ }
+
+ inline path_match_flags operator&= (path_match_flags& x, path_match_flags y)
+ {
+ return x = static_cast<path_match_flags> (
+ static_cast<std::uint16_t> (x) &
+ static_cast<std::uint16_t> (y));
+ }
+
+ inline path_match_flags operator|= (path_match_flags& x, path_match_flags y)
+ {
+ return x = static_cast<path_match_flags> (
+ static_cast<std::uint16_t> (x) |
+ static_cast<std::uint16_t> (y));
+ }
+
// path_pattern_iterator
//
inline path_pattern_iterator::
diff --git a/tests/b-info/driver.cxx b/tests/b-info/driver.cxx
index 6832aaa..5691221 100644
--- a/tests/b-info/driver.cxx
+++ b/tests/b-info/driver.cxx
@@ -49,13 +49,14 @@ try
cout.exceptions (ios::failbit | ios::badbit);
- b_project_info pi (b_info (project,
- true /* ext_mods */,
- 1 /* verb */,
- {} /* cmd_callback */,
- b,
- {} /* search_fallback */,
- {"--no-default-options"}));
+ b_project_info pi (
+ b_info (project,
+ b_info_flags::ext_mods | b_info_flags::subprojects,
+ 1 /* verb */,
+ {} /* cmd_callback */,
+ b,
+ {} /* search_fallback */,
+ {"--no-default-options"}));
cout << "project: " << pi.project << endl
<< "version: " << pi.version << endl