diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-08-22 18:24:21 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-08-22 18:24:21 +0200 |
commit | 2f505c143d969b87c532bb4852d275c8eb9a5dae (patch) | |
tree | ed1b195a7d396f4936bae1b961b70bb0906b7b31 | |
parent | e35961d3b980d2201699276a4e68de8a5f987480 (diff) |
Add workaround for Windows baseutils /bin search issue
-rw-r--r-- | build2/b.cxx | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/build2/b.cxx b/build2/b.cxx index ca7af1c..cd69342 100644 --- a/build2/b.cxx +++ b/build2/b.cxx @@ -4,7 +4,7 @@ #include <time.h> // tzset() #include <string.h> // strerror() -#include <stdlib.h> // getenv() +#include <stdlib.h> // getenv() _putenv()(_WIN32) #include <sstream> #include <cstring> // strcmp(), strchr() @@ -53,6 +53,30 @@ using namespace build2; int main (int argc, char* argv[]) { + // This is a little hack to make out baseutils for Windows work when called + // with absolute path. In a nutshell, MSYS2's exec*p() doesn't search in the + // parent's executable directory, only in PATH. And since we are running + // without a shell (that would read /etc/profile which sets PATH to some + // sensible values), we are only getting Win32 PATH values. And MSYS2 /bin + // is not one of them. So what we are going to do is add /bin at the end of + // PATH (which will be passed as is by the MSYS2 machinery). This will make + // MSYS2 search in /bin (where our baseutils live). And for everyone else + // this should be harmless since it is not a valid Win32 path. + // +#ifdef _WIN32 + { + string mp ("PATH="); + if (const char* p = getenv ("PATH")) + { + mp += p; + mp += ';'; + } + mp += "/bin"; + + _putenv (mp.c_str ()); + } +#endif + try { tracer trace ("main"); |