From eb00bd14df2072acf9f80912153476ea6e657b07 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 20 Jan 2023 14:45:45 +0100 Subject: Store PATH in env in configuration.cc for use in future reconfigure calls. --- src/configure.cc | 12 ++++++++++++ src/util.cc | 4 +--- src/util.h | 3 ++- 3 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/configure.cc b/src/configure.cc index b2639cb..68ce7eb 100644 --- a/src/configure.cc +++ b/src/configure.cc @@ -426,6 +426,12 @@ int regenerateCache(ctor::settings& settings, auto paths = get_paths(); + auto path_env = env.find("PATH"); + if(path_env != env.end()) + { + paths = get_paths(path_env->second); + } + // Host detection auto host_cc = locate(cc_prog, paths, host_arch_prefix); if(host_cc.empty()) @@ -695,6 +701,12 @@ int configure(const ctor::settings& global_settings, int argc, char* argv[]) env["LD"] = ld_env; } + auto path_env = getenv("PATH"); + if(path_env) + { + env["PATH"] = path_env; + } + auto ret = regenerateCache(settings, argv[0], args, env); if(ret != 0) { diff --git a/src/util.cc b/src/util.cc index db5a5f6..76d380b 100644 --- a/src/util.cc +++ b/src/util.cc @@ -168,12 +168,10 @@ std::string esc(const std::string& in) return out; } -std::vector get_paths() +std::vector get_paths(const std::string& path_env) { std::vector paths; - std::string path_env = std::getenv("PATH"); - #ifdef _WIN32 const char sep{';'}; #else diff --git a/src/util.h b/src/util.h index eeb3206..af5bbd6 100644 --- a/src/util.h +++ b/src/util.h @@ -7,6 +7,7 @@ #include #include +#include std::string to_lower(const std::string& str); @@ -23,7 +24,7 @@ void append(T& a, const T& b) std::string esc(const std::string& in); -std::vector get_paths(); +std::vector get_paths(const std::string& path_env = std::getenv("PATH")); std::string locate(const std::string& app, const std::vector& paths, -- cgit v1.2.3