r211458 - Make WindowsToolChain portable
Alp Toker
alp at nuanti.com
Sat Jun 21 20:27:46 PDT 2014
Author: alp
Date: Sat Jun 21 22:27:45 2014
New Revision: 211458
URL: http://llvm.org/viewvc/llvm-project?rev=211458&view=rev
Log:
Make WindowsToolChain portable
De-conditionalize as much as possible so we can start to fix this code.
No change in functionality.
Modified:
cfe/trunk/lib/Driver/WindowsToolChain.cpp
Modified: cfe/trunk/lib/Driver/WindowsToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/WindowsToolChain.cpp?rev=211458&r1=211457&r2=211458&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/WindowsToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/WindowsToolChain.cpp Sat Jun 21 22:27:45 2014
@@ -21,7 +21,12 @@
// Include the necessary headers to interface with the Windows registry and
// environment.
-#ifdef _MSC_VER
+// TODO: Investigate enabling this with __MINGW32__.
+#if defined(_MSC_VER)
+#define USE_WIN32
+#endif
+
+#ifdef USE_WIN32
#define WIN32_LEAN_AND_MEAN
#define NOGDI
#define NOMINMAX
@@ -69,9 +74,6 @@ bool Windows::isPICDefaultForced() const
return getArch() == llvm::Triple::x86_64;
}
-// FIXME: This probably should goto to some platform utils place.
-#ifdef _MSC_VER
-
/// \brief Read registry string.
/// This also supports a means to look for high-versioned keys by use
/// of a $VERSION placeholder in the key path.
@@ -82,6 +84,9 @@ bool Windows::isPICDefaultForced() const
/// characters are compared.
static bool getSystemRegistryString(const char *keyPath, const char *valueName,
char *value, size_t maxLength) {
+#ifndef USE_WIN32
+ return false;
+#else
HKEY hRootKey = NULL;
HKEY hKey = NULL;
const char* subKey = NULL;
@@ -183,6 +188,7 @@ static bool getSystemRegistryString(cons
}
}
return returnValue;
+#endif // USE_WIN32
}
/// \brief Get Windows SDK installation directory.
@@ -202,7 +208,7 @@ static bool getWindowsSDKDir(std::string
return false;
}
- // Get Visual Studio installation directory.
+// Get Visual Studio installation directory.
static bool getVisualStudioDir(std::string &path) {
// First check the environment variables that vsvars32.bat sets.
const char* vcinstalldir = getenv("VCINSTALLDIR");
@@ -244,7 +250,8 @@ static bool getVisualStudioDir(std::stri
const char *vs100comntools = getenv("VS100COMNTOOLS");
const char *vs90comntools = getenv("VS90COMNTOOLS");
const char *vs80comntools = getenv("VS80COMNTOOLS");
- const char *vscomntools = NULL;
+
+ const char *vscomntools = nullptr;
// Try to find the version that we were compiled with
if(false) {}
@@ -277,8 +284,6 @@ static bool getVisualStudioDir(std::stri
return false;
}
-#endif // _MSC_VER
-
void Windows::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
if (DriverArgs.hasArg(options::OPT_nostdinc))
@@ -293,7 +298,11 @@ void Windows::AddClangSystemIncludeArgs(
if (DriverArgs.hasArg(options::OPT_nostdlibinc))
return;
-#ifdef _MSC_VER
+// TODO: This code path is portable. Conditionalize on LLVM_ON_WIN32 instead?
+#ifndef USE_WIN32
+ return;
+#endif
+
// Honor %INCLUDE%. It should know essential search paths with vcvarsall.bat.
if (const char *cl_include_dir = getenv("INCLUDE")) {
SmallVector<StringRef, 8> Dirs;
@@ -328,6 +337,7 @@ void Windows::AddClangSystemIncludeArgs(
}
// As a fallback, select default install paths.
+ // FIXME: Don't guess drives and paths like this on Windows.
const StringRef Paths[] = {
"C:/Program Files/Microsoft Visual Studio 10.0/VC/include",
"C:/Program Files/Microsoft Visual Studio 9.0/VC/include",
@@ -336,7 +346,6 @@ void Windows::AddClangSystemIncludeArgs(
"C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include"
};
addSystemIncludes(DriverArgs, CC1Args, Paths);
-#endif // _MSC_VER
}
void Windows::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
More information about the cfe-commits
mailing list