Merge topic 'vs-flag-tables' into release-3.21

b0f830ced6 VS: Do not apply any '/external:*' flag table mapping on VS < 16.10
3fd65f5ca6 VS: Compare VS instance versions as strings

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6241
This commit is contained in:
Brad King
2021-06-18 13:38:20 +00:00
committed by Kitware Robot
7 changed files with 36 additions and 30 deletions

View File

@@ -1361,10 +1361,8 @@ static unsigned int cmLoadFlagTableSpecial(Json::Value entry,
namespace {
unsigned long long const vsVer16_10_0 = 4503644629696790;
cmIDEFlagTable const* cmLoadFlagTableJson(
std::string const& flagJsonPath, cm::optional<unsigned long long> vsver)
cmIDEFlagTable const* cmLoadFlagTableJson(std::string const& flagJsonPath,
cm::optional<std::string> vsVer)
{
cmIDEFlagTable* ret = nullptr;
auto savedFlagIterator = loadedFlagJsonFiles.find(flagJsonPath);
@@ -1380,17 +1378,22 @@ cmIDEFlagTable const* cmLoadFlagTableJson(
if (reader.parse(stream, flags, false) && flags.isArray()) {
std::vector<cmIDEFlagTable> flagTable;
for (auto const& flag : flags) {
Json::Value const& vsminJson = flag["vsmin"];
if (vsminJson.isString()) {
std::string const& vsmin = vsminJson.asString();
if (!vsmin.empty()) {
if (!vsVer ||
cmSystemTools::VersionCompareGreater(vsmin, *vsVer)) {
continue;
}
}
}
cmIDEFlagTable flagEntry;
flagEntry.IDEName = cmLoadFlagTableString(flag, "name");
flagEntry.commandFlag = cmLoadFlagTableString(flag, "switch");
flagEntry.comment = cmLoadFlagTableString(flag, "comment");
flagEntry.value = cmLoadFlagTableString(flag, "value");
flagEntry.special = cmLoadFlagTableSpecial(flag, "flags");
// FIXME: Port this version check to a Json field.
if (vsver && *vsver < vsVer16_10_0 &&
flagEntry.IDEName == "ExternalWarningLevel") {
continue;
}
flagTable.push_back(flagEntry);
}
cmIDEFlagTable endFlag{ "", "", "", "", 0 };
@@ -1466,8 +1469,8 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable(
}
}
cm::optional<unsigned long long> vsver = this->GetVSInstanceVersion();
if (cmIDEFlagTable const* ret = cmLoadFlagTableJson(filename, vsver)) {
cm::optional<std::string> vsVer = this->GetVSInstanceVersion();
if (cmIDEFlagTable const* ret = cmLoadFlagTableJson(filename, vsVer)) {
return ret;
}

View File

@@ -128,10 +128,7 @@ public:
std::string Encoding() override;
const char* GetToolsVersion() const;
virtual cm::optional<unsigned long long> GetVSInstanceVersion() const
{
return {};
}
virtual cm::optional<std::string> GetVSInstanceVersion() const { return {}; }
bool GetSupportsUnityBuilds() const { return this->SupportsUnityBuilds; }

View File

@@ -391,11 +391,11 @@ bool cmGlobalVisualStudioVersionedGenerator::GetVSInstance(
return vsSetupAPIHelper.GetVSInstanceInfo(dir);
}
cm::optional<unsigned long long>
cm::optional<std::string>
cmGlobalVisualStudioVersionedGenerator::GetVSInstanceVersion() const
{
cm::optional<unsigned long long> result;
unsigned long long vsInstanceVersion;
cm::optional<std::string> result;
std::string vsInstanceVersion;
if (vsSetupAPIHelper.GetVSInstanceVersion(vsInstanceVersion)) {
result = vsInstanceVersion;
}
@@ -411,10 +411,10 @@ bool cmGlobalVisualStudioVersionedGenerator::IsStdOutEncodingSupported() const
if (this->Version < cmGlobalVisualStudioGenerator::VSVersion::VS16) {
return false;
}
unsigned long long const vsInstanceVersion16_7_P2 = 4503631666610212;
cm::optional<unsigned long long> vsInstanceVersion =
this->GetVSInstanceVersion();
return (vsInstanceVersion && *vsInstanceVersion > vsInstanceVersion16_7_P2);
static std::string const vsVer16_7_P2 = "16.7.30128.36";
cm::optional<std::string> vsVer = this->GetVSInstanceVersion();
return (vsVer &&
cmSystemTools::VersionCompareGreaterEq(*vsVer, vsVer16_7_P2));
}
const char*

View File

@@ -28,7 +28,7 @@ public:
bool GetVSInstance(std::string& dir) const;
cm::optional<unsigned long long> GetVSInstanceVersion() const override;
cm::optional<std::string> GetVSInstanceVersion() const override;
AuxToolset FindAuxToolset(std::string& version,
std::string& props) const override;

View File

@@ -258,15 +258,13 @@ bool cmVSSetupAPIHelper::GetVSInstanceInfo(std::string& vsInstallLocation)
return isInstalled;
}
bool cmVSSetupAPIHelper::GetVSInstanceVersion(
unsigned long long& vsInstanceVersion)
bool cmVSSetupAPIHelper::GetVSInstanceVersion(std::string& vsInstanceVersion)
{
vsInstanceVersion = 0;
vsInstanceVersion.clear();
bool isInstalled = this->EnumerateAndChooseVSInstance();
if (isInstalled) {
vsInstanceVersion =
static_cast<unsigned long long>(chosenInstanceInfo.ullVersion);
vsInstanceVersion = cmsys::Encoding::ToNarrow(chosenInstanceInfo.Version);
}
return isInstalled;

View File

@@ -88,7 +88,7 @@ struct VSInstanceInfo
std::wstring VSInstallLocation;
std::wstring Version;
std::string VCToolsetVersion;
ULONGLONG ullVersion = 0;
ULONGLONG ullVersion = 0; // A.B.C.D = (A<<48)|(B<<32)|(C<<16)|D
bool IsWin10SDKInstalled = false;
bool IsWin81SDKInstalled = false;
@@ -105,7 +105,7 @@ public:
bool IsVSInstalled();
bool GetVSInstanceInfo(std::string& vsInstallLocation);
bool GetVSInstanceVersion(unsigned long long& vsInstanceVersion);
bool GetVSInstanceVersion(std::string& vsInstanceVersion);
bool GetVCToolsetVersion(std::string& vsToolsetVersion);
bool IsWin10SDKInstalled();
bool IsWin81SDKInstalled();

View File

@@ -572,6 +572,7 @@
"switch": "external:W0",
"comment": "Turn Off All Warnings",
"value": "TurnOffAllWarnings",
"vsmin": "16.10.31321.278",
"flags": []
},
{
@@ -579,6 +580,7 @@
"switch": "external:W1",
"comment": "Level1",
"value": "Level1",
"vsmin": "16.10.31321.278",
"flags": []
},
{
@@ -586,6 +588,7 @@
"switch": "external:W2",
"comment": "Level2",
"value": "Level2",
"vsmin": "16.10.31321.278",
"flags": []
},
{
@@ -593,6 +596,7 @@
"switch": "external:W3",
"comment": "Level3",
"value": "Level3",
"vsmin": "16.10.31321.278",
"flags": []
},
{
@@ -600,6 +604,7 @@
"switch": "external:W4",
"comment": "Level4",
"value": "Level4",
"vsmin": "16.10.31321.278",
"flags": []
},
{
@@ -1141,6 +1146,7 @@
"switch": "external:anglebrackets",
"comment": "Treat Files Included with Angle Brackets as External",
"value": "true",
"vsmin": "16.10.31321.278",
"flags": []
},
{
@@ -1148,6 +1154,7 @@
"switch": "external:templates-",
"comment": "Template Diagnostics in External Headers",
"value": "true",
"vsmin": "16.10.31321.278",
"flags": []
},
{
@@ -1277,6 +1284,7 @@
"switch": "external:env:",
"comment": "External Directories Environment Variables",
"value": "",
"vsmin": "16.10.31321.278",
"flags": [
"UserValue",
"SemicolonAppendable"