aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-06-20 11:21:19 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-06-20 11:21:19 +0200
commitc014f125b4b91adffec0621f2c6647866735cf97 (patch)
tree46aeea88f38ad5c33b415979de94ae11af324e33
parent4dd4156c7126ff5735c65bdcc4e071e612a0681d (diff)
Add hack to allow executing build2-built ODB compiler in place on Windows
-rw-r--r--odb/odb.cxx30
1 files changed, 30 insertions, 0 deletions
diff --git a/odb/odb.cxx b/odb/odb.cxx
index a9385c0..98f9f5d 100644
--- a/odb/odb.cxx
+++ b/odb/odb.cxx
@@ -522,6 +522,36 @@ main (int argc, char* argv[])
if (plugin.empty ())
return 1; // Diagnostics has already been issued.
+#ifdef ODB_BUILD2
+#ifdef _WIN32
+ // Here is the problem: since the plugin is loaded by GCC (cc1plus.exe
+ // to be precise), the DLL assembly magic we have for executables won't
+ // help here.
+ //
+ // To allow executing the ODB compiler in-place we add the odb.exe.dll/
+ // directory to PATH. It is a bit of hack but then DLL assemblies for
+ // DLLs is whole new level of insanity that we are unlikely to ever
+ // touch.
+ //
+ {
+ path d (plugin.directory ());
+ d.complete ();
+ d.normalize ();
+ d /= path ("odb.exe.dll");
+
+ string s ("PATH=" + d.string ());
+
+ if (char const* p = getenv ("PATH"))
+ {
+ s += ';';
+ s += p;
+ }
+
+ _putenv (s.c_str ());
+ }
+#endif
+#endif
+
args[7] = "-fplugin=" + plugin.string ();
}