summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/configure.cc12
-rw-r--r--src/util.cc4
-rw-r--r--src/util.h3
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
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 <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,