Windows: Match UCRT Version from build environment if possible.
Signed-off-by: Vassil Vassilev <vvasilev@cern.ch>
This commit is contained in:
parent
3acc9e577d
commit
182954b87f
@ -127,7 +127,8 @@ inline namespace windows {
|
||||
///
|
||||
/// \param [out] Path - Path to VisualStudio
|
||||
/// \param [out] WindSDK - Store the path to the Windows SDK here
|
||||
/// \param [out] UniversalSDK - Store the path to the Universal SDK here
|
||||
/// \param [in/out] UniversalSDK - Universal SDK version to match, or empty to
|
||||
/// match the highest version. On ouput the path to the Universal SDK.
|
||||
/// \param [in] Verbose - Log progress
|
||||
///
|
||||
bool GetVisualStudioDirs(std::string& Path,
|
||||
|
@ -166,8 +166,9 @@ namespace {
|
||||
}
|
||||
|
||||
// When built with access to the proper Windows APIs, try to actually find
|
||||
// the correct include paths first.
|
||||
std::string VSDir, WinSDK, UnivSDK;
|
||||
// the correct include paths first. Init for UnivSDK.empty check below.
|
||||
std::string VSDir, WinSDK,
|
||||
UnivSDK(opts.NoBuiltinInc ? "" : CLING_UCRT_VERSION);
|
||||
if (platform::GetVisualStudioDirs(VSDir,
|
||||
opts.NoBuiltinInc ? nullptr : &WinSDK,
|
||||
opts.NoBuiltinInc ? nullptr : &UnivSDK,
|
||||
|
@ -316,6 +316,7 @@ else()
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cling-compiledata.h.in
|
||||
"
|
||||
#define CLING_INCLUDE_PATHS \"${CLING_INCLUDE_PATHS}\"
|
||||
#define CLING_UCRT_VERSION \"$ENV{UCRTVersion}\"
|
||||
")
|
||||
endif()
|
||||
|
||||
|
@ -196,7 +196,9 @@ static bool getVisualStudioVer(int VSVersion, std::string& Path,
|
||||
// So we compare entry names lexicographically to find the greatest one.
|
||||
static bool getWindows10SDKVersion(std::string& SDKPath,
|
||||
std::string& SDKVersion) {
|
||||
SDKVersion.clear();
|
||||
// Save input SDKVersion to match, and clear SDKVersion for > comparsion
|
||||
std::string UcrtCompiledVers;
|
||||
UcrtCompiledVers.swap(SDKVersion);
|
||||
|
||||
std::error_code EC;
|
||||
llvm::SmallString<MAX_PATHC> IncludePath(SDKPath);
|
||||
@ -205,15 +207,15 @@ static bool getWindows10SDKVersion(std::string& SDKPath,
|
||||
DirIt != DirEnd && !EC; DirIt.increment(EC)) {
|
||||
if (!llvm::sys::fs::is_directory(DirIt->path()))
|
||||
continue;
|
||||
llvm::StringRef CandidateName = llvm::sys::path::filename(DirIt->path());
|
||||
// If WDK is installed, there could be subfolders like "wdf" in the
|
||||
// "Include" directory.
|
||||
// Allow only directories which names start with "10.".
|
||||
if (!CandidateName.startswith("10."))
|
||||
continue;
|
||||
if (CandidateName > SDKVersion) {
|
||||
llvm::StringRef Candidate = llvm::sys::path::filename(DirIt->path());
|
||||
// There could be subfolders like "wdf" in the "Include" directory, so only
|
||||
// test names that start with "10." or match input.
|
||||
const bool Match = Candidate == UcrtCompiledVers;
|
||||
if (Match || (Candidate.startswith("10.") && Candidate > SDKVersion)) {
|
||||
SDKPath = DirIt->path();
|
||||
SDKVersion = CandidateName;
|
||||
Candidate.str().swap(SDKVersion);
|
||||
if (Match)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return !SDKVersion.empty();
|
||||
@ -392,7 +394,9 @@ bool GetVisualStudioDirs(std::string& Path, std::string* WinSDK,
|
||||
}
|
||||
|
||||
if (UniversalSDK) {
|
||||
// On input UniversalSDK is the best version to match
|
||||
std::string UCRTVersion;
|
||||
UniversalSDK->swap(UCRTVersion);
|
||||
if (!getUniversalCRTSdkDir(*UniversalSDK, UCRTVersion)) {
|
||||
UniversalSDK->clear();
|
||||
if (Verbose)
|
||||
|
Loading…
x
Reference in New Issue
Block a user