diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2023-01-20 14:45:45 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2023-01-20 14:45:45 +0100 |
commit | eb00bd14df2072acf9f80912153476ea6e657b07 (patch) | |
tree | afdbf7b2bbc5d4d52d0b0e672d618bfab96642ff | |
parent | a5585150f0ff8d27ddd22792f521f1374a3eedd8 (diff) |
Store PATH in env in configuration.cc for use in future reconfigure calls.
-rw-r--r-- | src/configure.cc | 12 | ||||
-rw-r--r-- | src/util.cc | 4 | ||||
-rw-r--r-- | src/util.h | 3 |
3 files changed, 15 insertions, 4 deletions
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<std::string> get_paths() +std::vector<std::string> get_paths(const std::string& path_env) { std::vector<std::string> paths; - std::string path_env = std::getenv("PATH"); - #ifdef _WIN32 const char sep{';'}; #else @@ -7,6 +7,7 @@ #include <string> #include <filesystem> +#include <cstdlib> 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<std::string> get_paths(); +std::vector<std::string> get_paths(const std::string& path_env = std::getenv("PATH")); std::string locate(const std::string& app, const std::vector<std::string>& paths, |