From acde650d74c2d7f41328fa94dd130ca144fd5487 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 16 Aug 2021 17:04:49 +0300 Subject: Add b_info() overload that returns information for multiple projects --- libbutl/b.mxx | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) (limited to 'libbutl/b.mxx') diff --git a/libbutl/b.mxx b/libbutl/b.mxx index 97dcf0c..cca9696 100644 --- a/libbutl/b.mxx +++ b/libbutl/b.mxx @@ -10,6 +10,7 @@ #ifndef __cpp_lib_modules_ts #include #include +#include // move() #include // size_tu #include // uint16_t #include // runtime_error @@ -64,8 +65,12 @@ LIBBUTL_MODEXPORT namespace butl b_error (const std::string& description, optional = nullopt); }; - // Run `b info: ` command and parse and return the build2 - // project information it prints to stdout. Throw b_error on error. + // Run `b info: ...` command and parse and return (via argument + // to allow appending and for error position; see below) the build2 projects + // information it prints to stdout. Return the empty list if the specified + // project list is empty. Throw b_error on error. Note that the size of the + // 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, @@ -76,8 +81,8 @@ LIBBUTL_MODEXPORT namespace butl // (see process_run_callback() for details), build program search details, // and additional options. // - // Note that version_string is only parsed to standard_version if the - // project uses the version module. Otherwise, standard_version is empty. + // Note that version_string is only parsed to standard_version if a project + // uses the version module. Otherwise, standard_version is empty. // struct b_project_info { @@ -110,12 +115,37 @@ LIBBUTL_MODEXPORT namespace butl using b_callback = void (const char* const args[], std::size_t n); - LIBBUTL_SYMEXPORT b_project_info - b_info (const dir_path& project, + LIBBUTL_SYMEXPORT void + b_info (std::vector& result, + const std::vector& projects, bool ext_mods, std::uint16_t verb = 1, const std::function& cmd_callback = {}, const path& program = path ("b"), const dir_path& search_fallback = {}, const std::vector& options = {}); + + // As above but retrieve information for a single project. + // + inline b_project_info + b_info (const dir_path& project, + bool ext_mods, + std::uint16_t verb = 1, + const std::function& cmd_callback = {}, + const path& program = path ("b"), + const dir_path& search_fallback = {}, + const std::vector& options = {}) + { + std::vector r; + b_info (r, + std::vector ({project}), + ext_mods, + verb, + cmd_callback, + program, + search_fallback, + options); + + return std::move (r[0]); + } } -- cgit v1.1