mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Improved VS detection
This commit is contained in:
parent
d82aab3b3f
commit
b94f69b976
3 changed files with 76 additions and 11 deletions
|
@ -22,9 +22,11 @@ namespace IDE
|
||||||
public String mBin64Path = new .() ~ delete _;
|
public String mBin64Path = new .() ~ delete _;
|
||||||
public List<String> mLib32Paths = new .() ~ DeleteContainerAndItems!(_);
|
public List<String> mLib32Paths = new .() ~ DeleteContainerAndItems!(_);
|
||||||
public List<String> mLib64Paths = new .() ~ DeleteContainerAndItems!(_);
|
public List<String> mLib64Paths = new .() ~ DeleteContainerAndItems!(_);
|
||||||
|
public bool mManuallySet;
|
||||||
|
|
||||||
public void Serialize(StructuredData sd)
|
public void Serialize(StructuredData sd)
|
||||||
{
|
{
|
||||||
|
sd.Add("ManuallySet", mManuallySet);
|
||||||
sd.Add("Bin32Path", mBin32Path);
|
sd.Add("Bin32Path", mBin32Path);
|
||||||
sd.Add("Bin64Path", mBin64Path);
|
sd.Add("Bin64Path", mBin64Path);
|
||||||
using (sd.CreateArray("Lib32Paths"))
|
using (sd.CreateArray("Lib32Paths"))
|
||||||
|
@ -41,6 +43,10 @@ namespace IDE
|
||||||
|
|
||||||
public void Deserialize(StructuredData sd)
|
public void Deserialize(StructuredData sd)
|
||||||
{
|
{
|
||||||
|
mManuallySet = sd.GetBool("ManuallySet");
|
||||||
|
if ((!mManuallySet) && (!mBin64Path.IsEmpty))
|
||||||
|
return;
|
||||||
|
|
||||||
sd.GetString("Bin32Path", mBin32Path);
|
sd.GetString("Bin32Path", mBin32Path);
|
||||||
sd.GetString("Bin64Path", mBin64Path);
|
sd.GetString("Bin64Path", mBin64Path);
|
||||||
|
|
||||||
|
@ -85,6 +91,7 @@ namespace IDE
|
||||||
|
|
||||||
public void SetDefaults()
|
public void SetDefaults()
|
||||||
{
|
{
|
||||||
|
mManuallySet = false;
|
||||||
#if BF_PLATFORM_WINDOWS
|
#if BF_PLATFORM_WINDOWS
|
||||||
StringView vsInfo = .(VSSupport_Find());
|
StringView vsInfo = .(VSSupport_Find());
|
||||||
|
|
||||||
|
@ -111,6 +118,25 @@ namespace IDE
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Equals(List<String> lhs, List<String> rhs)
|
||||||
|
{
|
||||||
|
if (lhs.Count != rhs.Count)
|
||||||
|
return false;
|
||||||
|
for (int idx < lhs.Count)
|
||||||
|
if (lhs[idx] != rhs[idx])
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Equals(VSSettings vsSettings)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
(Equals(mLib32Paths, vsSettings.mLib32Paths)) &&
|
||||||
|
(Equals(mLib64Paths, vsSettings.mLib64Paths)) &&
|
||||||
|
(mBin32Path == vsSettings.mBin32Path) &&
|
||||||
|
(mBin64Path == vsSettings.mBin64Path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DebuggerSettings
|
public class DebuggerSettings
|
||||||
|
|
|
@ -395,7 +395,18 @@ namespace IDE.ui
|
||||||
{
|
{
|
||||||
if (propPage == null)
|
if (propPage == null)
|
||||||
continue;
|
continue;
|
||||||
ApplyChanges(propPage, ref hadChanges);
|
bool pageHadChanges = false;
|
||||||
|
ApplyChanges(propPage, ref pageHadChanges);
|
||||||
|
if (pageHadChanges)
|
||||||
|
{
|
||||||
|
hadChanges = true;
|
||||||
|
if ((CategoryType)@propPage == .VisualStudio)
|
||||||
|
{
|
||||||
|
Settings.VSSettings defaultSettings = scope .();
|
||||||
|
defaultSettings.SetDefaults();
|
||||||
|
gApp.mSettings.mVSSettings.mManuallySet = !defaultSettings.Equals(gApp.mSettings.mVSSettings);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hadChanges)
|
if (hadChanges)
|
||||||
|
|
|
@ -58,6 +58,7 @@ struct Find_Result {
|
||||||
|
|
||||||
wchar_t *windows_sdk_root = NULL;
|
wchar_t *windows_sdk_root = NULL;
|
||||||
|
|
||||||
|
wchar_t* vs_version = NULL;
|
||||||
wchar_t *vs_exe32_path = NULL;
|
wchar_t *vs_exe32_path = NULL;
|
||||||
wchar_t *vs_exe64_path = NULL;
|
wchar_t *vs_exe64_path = NULL;
|
||||||
wchar_t *vs_library32_path = NULL;
|
wchar_t *vs_library32_path = NULL;
|
||||||
|
@ -68,6 +69,7 @@ Find_Result find_visual_studio_and_windows_sdk();
|
||||||
|
|
||||||
void free_resources(Find_Result *result) {
|
void free_resources(Find_Result *result) {
|
||||||
free(result->windows_sdk_root);
|
free(result->windows_sdk_root);
|
||||||
|
free(result->vs_version);
|
||||||
free(result->vs_exe32_path);
|
free(result->vs_exe32_path);
|
||||||
free(result->vs_exe64_path);
|
free(result->vs_exe64_path);
|
||||||
free(result->vs_library32_path);
|
free(result->vs_library32_path);
|
||||||
|
@ -448,7 +450,6 @@ void find_visual_studio_by_fighting_through_microsoft_craziness(Find_Result *res
|
||||||
|
|
||||||
auto version_bytes = (tools_file_size.QuadPart + 1) * 2; // Warning: This multiplication by 2 presumes there is no variable-length encoding in the wchars (wacky characters in the file could betray this expectation).
|
auto version_bytes = (tools_file_size.QuadPart + 1) * 2; // Warning: This multiplication by 2 presumes there is no variable-length encoding in the wchars (wacky characters in the file could betray this expectation).
|
||||||
wchar_t *version = (wchar_t *)malloc(version_bytes);
|
wchar_t *version = (wchar_t *)malloc(version_bytes);
|
||||||
defer{ free(version); };
|
|
||||||
|
|
||||||
auto read_result = fgetws(version, (int)version_bytes, f);
|
auto read_result = fgetws(version, (int)version_bytes, f);
|
||||||
if (!read_result) continue;
|
if (!read_result) continue;
|
||||||
|
@ -459,17 +460,41 @@ void find_visual_studio_by_fighting_through_microsoft_craziness(Find_Result *res
|
||||||
auto library32_path = concat(bstr_inst_path, L"\\VC\\Tools\\MSVC\\", version, L"\\lib\\x86");
|
auto library32_path = concat(bstr_inst_path, L"\\VC\\Tools\\MSVC\\", version, L"\\lib\\x86");
|
||||||
auto library64_path = concat(bstr_inst_path, L"\\VC\\Tools\\MSVC\\", version, L"\\lib\\x64");
|
auto library64_path = concat(bstr_inst_path, L"\\VC\\Tools\\MSVC\\", version, L"\\lib\\x64");
|
||||||
auto library_file = concat(library32_path, L"\\vcruntime.lib"); // @Speed: Could have library_path point to this string, with a smaller count, to save on memory flailing!
|
auto library_file = concat(library32_path, L"\\vcruntime.lib"); // @Speed: Could have library_path point to this string, with a smaller count, to save on memory flailing!
|
||||||
|
auto vs_exe64_path = concat(bstr_inst_path, L"\\VC\\Tools\\MSVC\\", version, L"\\bin\\Hostx64\\x64");
|
||||||
|
auto vs_exe64_link_path = concat(vs_exe64_path, L"\\link.exe");
|
||||||
|
|
||||||
if (os_file_exists(library_file)) {
|
bool use = false;
|
||||||
result->vs_exe32_path = concat(bstr_inst_path, L"\\VC\\Tools\\MSVC\\", version, L"\\bin\\Hostx86\\x86");
|
if ((os_file_exists(library_file)) && (os_file_exists(vs_exe64_link_path)))
|
||||||
result->vs_exe64_path = concat(bstr_inst_path, L"\\VC\\Tools\\MSVC\\", version, L"\\bin\\Hostx64\\x64");
|
{
|
||||||
result->vs_library32_path = library32_path;
|
if (result->vs_version == NULL)
|
||||||
result->vs_library64_path = library64_path;
|
{
|
||||||
return;
|
use = true;
|
||||||
|
}
|
||||||
|
else if (wcscmp(version, result->vs_version) > 0)
|
||||||
|
{
|
||||||
|
use = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (use)
|
||||||
|
{
|
||||||
|
result->vs_version = version;
|
||||||
|
result->vs_exe64_path = vs_exe64_path;
|
||||||
|
result->vs_exe32_path = concat(bstr_inst_path, L"\\VC\\Tools\\MSVC\\", version, L"\\bin\\Hostx86\\x86");
|
||||||
|
|
||||||
|
result->vs_library32_path = library32_path;
|
||||||
|
result->vs_library64_path = library64_path;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
free(version);
|
||||||
|
free(vs_exe64_path);
|
||||||
free(library32_path);
|
free(library32_path);
|
||||||
free(library64_path);
|
free(library64_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(library_file);
|
||||||
|
free(vs_exe64_link_path);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Ryan Saunderson said:
|
Ryan Saunderson said:
|
||||||
|
@ -480,6 +505,9 @@ void find_visual_studio_by_fighting_through_microsoft_craziness(Find_Result *res
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result->vs_exe64_path != NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
// If we get here, we didn't find Visual Studio 2017. Try earlier versions.
|
// If we get here, we didn't find Visual Studio 2017. Try earlier versions.
|
||||||
|
|
||||||
HKEY vs7_key;
|
HKEY vs7_key;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue