From c6b1d1dd870b3370d0a09fb4600e3a6b03326f35 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 23 Nov 2022 08:57:45 +0200 Subject: Rework diag_buffer interface to facilitate correct destruction order --- libbuild2/utility.hxx | 153 ++++---------------------------------------------- 1 file changed, 11 insertions(+), 142 deletions(-) (limited to 'libbuild2/utility.hxx') diff --git a/libbuild2/utility.hxx b/libbuild2/utility.hxx index 5fffc8c..c12fae7 100644 --- a/libbuild2/utility.hxx +++ b/libbuild2/utility.hxx @@ -276,7 +276,7 @@ namespace build2 const char* const* args, int in = 0, int out = 1, - process::pipe = {-1, 2}, + int err = 2, const location& = {}); inline process @@ -285,10 +285,10 @@ namespace build2 const cstrings& args, int in = 0, int out = 1, - process::pipe err = {-1, 2}, + int err = 2, const location& l = {}) { - return run_start (verbosity, pe, args.data (), in, out, move (err), l); + return run_start (verbosity, pe, args.data (), in, out, err, l); } inline process @@ -296,10 +296,10 @@ namespace build2 const char* const* args, int in = 0, int out = 1, - process::pipe err = {-1, 2}, + int err = 2, const location& l = {}) { - return run_start (verb_never, pe, args, in, out, move (err), l); + return run_start (verb_never, pe, args, in, out, err, l); } inline process @@ -307,10 +307,10 @@ namespace build2 const cstrings& args, int in = 0, int out = 1, - process::pipe err = {-1, 2}, + int err = 2, const location& l = {}) { - return run_start (pe, args.data (), in, out, move (err), l); + return run_start (pe, args.data (), in, out, err, l); } // As above, but search for the process (including updating args[0]) and @@ -321,7 +321,7 @@ namespace build2 const char* args[], int in = 0, int out = 1, - process::pipe err = {-1, 2}, + int err = 2, const char* const* env = nullptr, const dir_path& cwd = {}, const location& l = {}) @@ -329,7 +329,7 @@ namespace build2 process_path pp (run_search (args[0], l)); return run_start (verbosity, process_env (pp, cwd, env), args, - in, out, move (err), + in, out, err, l); } @@ -338,15 +338,12 @@ namespace build2 cstrings& args, int in = 0, int out = 1, - process::pipe err = {-1, 2}, + int err = 2, const char* const* env = nullptr, const dir_path& cwd = {}, const location& l = {}) { - return run_start (verbosity, - args.data (), - in, out, move (err), - env, cwd, l); + return run_start (verbosity, args.data (), in, out, err, env, cwd, l); } // Wait for process termination returning true if the process exited @@ -485,12 +482,6 @@ namespace build2 const char* const* args, uint16_t finish_verbosity); - LIBBUILD2_SYMEXPORT void - run (diag_buffer&, - const process_env& pe, - const char* const* args, - uint16_t finish_verbosity); - inline void run (context& ctx, const process_env& pe, @@ -500,15 +491,6 @@ namespace build2 run (ctx, pe, args.data (), finish_verbosity); } - inline void - run (diag_buffer& dbuf, - const process_env& pe, - const cstrings& args, - uint16_t finish_verbosity) - { - run (dbuf, pe, args.data (), finish_verbosity); - } - // As above but pass cwd/env vars as arguments rather than as part of // process_env. // @@ -524,17 +506,6 @@ namespace build2 } inline void - run (diag_buffer& dbuf, - const process_path& p, - const char* const* args, - uint16_t finish_verbosity, - const char* const* env, - const dir_path& cwd = {}) - { - run (dbuf, process_env (p, cwd, env), args, finish_verbosity); - } - - inline void run (context& ctx, const process_path& p, const cstrings& args, @@ -545,17 +516,6 @@ namespace build2 run (ctx, p, args.data (), finish_verbosity, env, cwd); } - inline void - run (diag_buffer& dbuf, - const process_path& p, - const cstrings& args, - uint16_t finish_verbosity, - const char* const* env, - const dir_path& cwd = {}) - { - run (dbuf, p, args.data (), finish_verbosity, env, cwd); - } - // Start the process as above and then call the specified function on each // trimmed line of the output until it returns a non-empty object T (tested // with T::empty()) which is then returned to the caller. @@ -611,31 +571,6 @@ namespace build2 } template - T - run (diag_buffer&, - uint16_t verbosity, - const process_env&, - const char* const* args, - F&&, - sha256* checksum = nullptr); - - template - inline T - run (diag_buffer& dbuf, - uint16_t verbosity, - const process_env& pe, - const cstrings& args, - F&& f, - sha256* checksum = nullptr) - { - return run (dbuf, - verbosity, - pe, args.data (), - forward (f), - checksum); - } - - template inline T run (context&, const process_env&, @@ -666,31 +601,6 @@ namespace build2 template inline T - run (diag_buffer&, - const process_env&, - const char* const* args, - uint16_t finish_verbosity, - F&&, - sha256* checksum = nullptr); - - template - inline T - run (diag_buffer& dbuf, - const process_env& pe, - const cstrings& args, - uint16_t finish_verbosity, - F&& f, - sha256* checksum = nullptr) - { - return run (dbuf, - pe, args.data (), - finish_verbosity, - forward (f), - checksum); - } - - template - inline T run (context& ctx, uint16_t verbosity, const char* args[], @@ -724,37 +634,6 @@ namespace build2 error, ignore_exit, checksum); } - template - inline T - run (diag_buffer& dbuf, - uint16_t verbosity, - const char* args[], - F&& f, - sha256* checksum = nullptr) - { - process_path pp (run_search (args[0])); - return run (dbuf, - verbosity, - pp, args, - forward (f), - checksum); - } - - template - inline T - run (diag_buffer& dbuf, - uint16_t verbosity, - cstrings& args, - F&& f, - sha256* checksum = nullptr) - { - return run (dbuf, - verbosity, - args.data (), - forward (f), - checksum); - } - // As above but run a program without any arguments or with one argument. // // run @@ -862,16 +741,6 @@ namespace build2 bool ignore_exit = false, sha256* checksum = nullptr); - LIBBUILD2_SYMEXPORT void - run (diag_buffer& dbuf, - uint16_t verbosity, - const process_env&, - const char* const* args, - uint16_t finish_verbosity, - const function&, - bool trim = true, - sha256* checksum = nullptr); - // Concatenate the program path and arguments into a shallow NULL-terminated // vector of C-strings. // -- cgit v1.1