From 48e2e4140b8e5aacdfd107a1215f21c9632c81c8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 22 Aug 2016 12:55:21 +0200 Subject: Cache process_path, use fallback search directory for binutils --- build2/utility | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 3 deletions(-) (limited to 'build2/utility') diff --git a/build2/utility b/build2/utility index ee12545..3fb47b7 100644 --- a/build2/utility +++ b/build2/utility @@ -84,11 +84,23 @@ namespace build2 // diagnostics from the child process). Issue diagnostics and throw failed // in case of an error. // + process_path + run_search (const char*& args0); + + process_path + run_search (const path&, bool init, const dir_path& fallback = dir_path ()); + process - start_run (const char* args[], bool error); + run_start (const process_path&, const char* args[], bool error); + + inline process + run_start (const char* args[], bool error) + { + return run_start (run_search (args[0]), args, error); + } bool - finish_run (const char* args[], bool error, process&, const string&); + run_finish (const char* args[], bool error, process&, const string&); // 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 @@ -106,7 +118,8 @@ namespace build2 // template T - run (const char* args[], + run (const process_path&, + const char* args[], T (*) (string&), bool error = true, bool ignore_exit = false, @@ -114,6 +127,19 @@ namespace build2 template inline T + run (const char* args[], + T (*f) (string&), + bool error = true, + bool ignore_exit = false, + sha256* checksum = nullptr) + { + return run (run_search (args[0]), args, f, error, ignore_exit, checksum); + } + + // run + // + template + inline T run (const path& prog, T (*f) (string&), bool error = true, @@ -126,6 +152,20 @@ namespace build2 template inline T + run (const process_path& pp, + T (*f) (string&), + bool error = true, + bool ignore_exit = false, + sha256* checksum = nullptr) + { + const char* args[] = {pp.recall_string (), nullptr}; + return run (pp, args, f, error, ignore_exit, checksum); + } + + // run + // + template + inline T run (const path& prog, const char* arg, T (*f) (string&), @@ -137,6 +177,19 @@ namespace build2 return run (args, f, error, ignore_exit, checksum); } + template + inline T + run (const process_path& pp, + const char* arg, + T (*f) (string&), + bool error = true, + bool ignore_exit = false, + sha256* checksum = nullptr) + { + const char* args[] = {pp.recall_string (), arg, nullptr}; + return run (pp, args, f, error, ignore_exit, checksum); + } + // Empty string and path. // extern const std::string empty_string; -- cgit v1.1