Find all VS toolchains and whether MFC is available

feature/quick-start-py
kaetemi 3 years ago
parent 234a0ced42
commit a41156c708
No known key found for this signature in database
GPG Key ID: 9873C4D40BB479BC

@ -15,12 +15,24 @@ VSVersions[9] = 2008
VSVersions[10] = 2010
VSVersions[11] = 2012
VSVersions[12] = 2013
VSVersions[13] = 2014
#VSVersions[13] = 2014
VSVersions[14] = 2015
#VSVersions[15] = 2017
#VSVersions[16] = 2019
#VSVersions[17] = 2022
VSMajor = {}
#VSMajor[2005] = 8
#VSMajor[2008] = 9
#VSMajor[2010] = 10
#VSMajor[2012] = 11
#VSMajor[2013] = 12
#VSMajor[2014] = 13
#VSMajor[2015] = 14
VSMajor["2017"] = 15
VSMajor["2019"] = 16
VSMajor["2022"] = 17
# "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\atlmfc\include\afx.h"
# "C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.16.27023\atlmfc\include\afx.h"
# "C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\*\atlmfc\include\afx.h"
@ -51,37 +63,51 @@ def HasMFC(dir):
for majorVersion in range(8, 15):
folderA = "C:\\Program Files (x86)\\Microsoft Visual Studio " + str(majorVersion)
folderB = folderA + ".0"
if os.path.isfile(os.path.join(folderA, "Common7\IDE\VCExpress.exe")):
FoundVisualStudio += [ { "DisplayName": "Visual C++ " + str(VSVersions[majorVersion]) + " Express", "Path": folderA, "HasMFC": HasMFC(folderB) } ]
if os.path.isfile(os.path.join(folderB, "Common7\IDE\VCExpress.exe")):
FoundVisualStudio += [ { "DisplayName": "Visual C++ " + str(VSVersions[majorVersion]) + " Express", "Path": folderB, "HasMFC": HasMFC(folderB) } ]
if os.path.isfile(os.path.join(folderA, "Common7\IDE\devenv.exe")):
FoundVisualStudio += [ { "DisplayName": "Visual Studio " + str(VSVersions[majorVersion]), "Path": folderA, "HasMFC": HasMFC(folderB) } ]
if os.path.isfile(os.path.join(folderB, "Common7\IDE\devenv.exe")):
FoundVisualStudio += [ { "DisplayName": "Visual Studio " + str(VSVersions[majorVersion]), "Path": folderB, "HasMFC": HasMFC(folderB) } ]
if os.path.isfile(os.path.join(folderA, "Common7\\IDE\\VCExpress.exe")):
FoundVisualStudio += [ { "Name": "Visual Studio " + str(majorVersion) + " " + str(VSVersions[majorVersion]), "DisplayName": "Visual C++ " + str(VSVersions[majorVersion]) + " Express", "Path": folderA, "Version": majorVersion, "Toolchain": "v" + str(majorVersion) + "0", "HasMFC": HasMFC(folderB) } ]
if os.path.isfile(os.path.join(folderB, "Common7\\IDE\VCExpress.exe")):
FoundVisualStudio += [ { "Name": "Visual Studio " + str(majorVersion) + " " + str(VSVersions[majorVersion]), "DisplayName": "Visual C++ " + str(VSVersions[majorVersion]) + " Express", "Path": folderB, "Version": majorVersion, "Toolchain": "v" + str(majorVersion) + "0", "HasMFC": HasMFC(folderB) } ]
if os.path.isfile(os.path.join(folderA, "Common7\\IDE\\devenv.exe")):
FoundVisualStudio += [ { "Name": "Visual Studio " + str(majorVersion) + " " + str(VSVersions[majorVersion]), "DisplayName": "Visual Studio " + str(VSVersions[majorVersion]), "Path": folderA, "Version": majorVersion, "Toolchain": "v" + str(majorVersion) + "0", "HasMFC": HasMFC(folderB) } ]
if os.path.isfile(os.path.join(folderB, "Common7\\IDE\\devenv.exe")):
FoundVisualStudio += [ { "Name": "Visual Studio " + str(majorVersion) + " " + str(VSVersions[majorVersion]), "DisplayName": "Visual Studio " + str(VSVersions[majorVersion]), "Path": folderB, "Version": majorVersion, "Toolchain": "v" + str(majorVersion) + "0", "HasMFC": HasMFC(folderB) } ]
del folderA
del folderB
# Scan all folders 2017 to 2022
for yearVersion in os.listdir("C:\\Program Files (x86)\\Microsoft Visual Studio"):
if yearVersion.startswith("."):
continue
yearPath = os.path.join("C:\\Program Files (x86)\\Microsoft Visual Studio", yearVersion)
def ProcessYearPath(yearVersion, yearPath):
global FoundVisualStudio
if os.path.isdir(yearPath):
for edition in os.listdir(yearPath):
if edition.startswith("."):
continue
editionPath = os.path.join(yearPath, edition)
if os.path.isdir(editionPath) and os.path.isfile(os.path.join(editionPath, "Common7\IDE\devenv.exe")):
FoundVisualStudio += [ { "DisplayName": "Visual Studio " + yearVersion + " " + edition, "Path": editionPath, "HasMFC": HasMFC(editionPath) } ]
if os.path.isdir(editionPath) and os.path.isfile(os.path.join(editionPath, "Common7\\IDE\\devenv.exe")):
auxBuildPath = os.path.join(editionPath, "VC\\Auxiliary\\Build")
for buildProps in os.listdir(auxBuildPath):
if buildProps.startswith("Microsoft.VCToolsVersion.") and buildProps.endswith(".default.txt"):
toolchain = buildProps.split(".")[2]
if toolchain != "default":
fi = open(os.path.join(auxBuildPath, buildProps))
toolsVersion = fi.read().strip()
fi.close()
del fi
mfcPath = os.path.join(editionPath, "VC\\Tools\\MSVC\\" + toolsVersion + "\\atlmfc\\include\\afx.h")
hasMFC = os.path.isfile(mfcPath)
FoundVisualStudio += [ { "Name": "Visual Studio " + str(VSMajor[yearVersion]) + " " + yearVersion, "DisplayName": "Visual Studio " + yearVersion + " " + edition, "Path": editionPath, "Version": VSMajor[yearVersion], "Toolchain": toolchain, "HasMFC": hasMFC } ]
for yearVersion in os.listdir("C:\\Program Files (x86)\\Microsoft Visual Studio"):
if yearVersion.startswith("."):
continue
yearPath = os.path.join("C:\\Program Files (x86)\\Microsoft Visual Studio", yearVersion)
ProcessYearPath(yearVersion, yearPath)
del yearPath
for yearVersion in os.listdir("C:\\Program Files\\Microsoft Visual Studio"):
if yearVersion.startswith("."):
continue
yearPath = os.path.join("C:\\Program Files\\Microsoft Visual Studio", yearVersion)
if os.path.isdir(yearPath):
for edition in os.listdir(yearPath):
if edition.startswith("."):
continue
editionPath = os.path.join(yearPath, edition)
if os.path.isdir(editionPath) and os.path.isfile(os.path.join(editionPath, "Common7\IDE\devenv.exe")):
FoundVisualStudio += [ { "DisplayName": "Visual Studio " + yearVersion + " " + edition, "Path": editionPath, "HasMFC": HasMFC(editionPath) } ]
ProcessYearPath(yearVersion, yearPath)
del yearPath
del ProcessYearPath
# print(FoundVisualStudio)
print(FoundVisualStudio)

Loading…
Cancel
Save