Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #11051 from shuffle2/update-vcredist
WinUpdater: Check OS and VC++ Redist versions
- Loading branch information
Showing
13 changed files
with
435 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| find_program(POWERSHELL_EXE NAMES powershell) | ||
|
|
||
| INCLUDE(FindPackageHandleStandardArgs) | ||
| find_package_handle_standard_args(PowerShell DEFAULT_MSG POWERSHELL_EXE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // Indicate the minimum OS version required for the binary to run properly. | ||
| // Updater will fail the update if the user does not meet this requirement. | ||
| OSMinimumVersionWin10=10.0.15063.0 | ||
| OSMinimumVersionWin11=10.0.22000.0 | ||
| OSMinimumVersionMacOS=10.14 | ||
|
|
||
| // This is the runtime which was compiled against - providing a way for Updater to detect if update | ||
| // is needed before executing this binary. Note that, annoyingly, the version in environment | ||
| // variables does not match the "real" version. Consider: | ||
| // VersionInfo : File: C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Redist\MSVC\14.32.31326\vc_redist.x64.exe | ||
| // InternalName: setup | ||
| // OriginalFilename: VC_redist.x64.exe | ||
| // FileVersion: 14.32.31332.0 | ||
| // FileDescription: Microsoft Visual C++ 2015-2022 Redistributable (x64) - 14.32.31332 | ||
| // Product: Microsoft Visual C++ 2015-2022 Redistributable (x64) - 14.32.31332 | ||
| // ProductVersion: 14.32.31332.0 | ||
| // Whereas the environment variables look like: | ||
| // VCToolsInstallDir=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.33.31629\ | ||
| // VCToolsRedistDir=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Redist\MSVC\14.32.31326\ | ||
| // VCToolsVersion=14.33.31629 | ||
| // We're really looking for "14.32.31332.0" (because that's what will appear in the registry once | ||
| // installed), NOT the other values! | ||
| VCToolsVersion=${VC_TOOLS_VERSION} | ||
| VCToolsUpdateURL=https://aka.ms/vs/17/release/vc_redist.x64.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| // Copyright 2018 Dolphin Emulator Project | ||
| // SPDX-License-Identifier: GPL-2.0-or-later | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <map> | ||
| #include <optional> | ||
| #include <sstream> | ||
|
|
||
| #include "Common/CommonTypes.h" | ||
| #include "Common/StringUtil.h" | ||
|
|
||
| namespace Platform | ||
| { | ||
| struct BuildVersion | ||
| { | ||
| u32 major{}; | ||
| u32 minor{}; | ||
| u32 build{}; | ||
| auto operator<=>(BuildVersion const& rhs) const = default; | ||
| static std::optional<BuildVersion> from_string(const std::string& str) | ||
| { | ||
| auto components = SplitString(str, '.'); | ||
| // Allow variable number of components (truncating after "build"), but not | ||
| // empty. | ||
| if (components.size() == 0) | ||
| return {}; | ||
| BuildVersion version; | ||
| if (!TryParse(components[0], &version.major, 10)) | ||
| return {}; | ||
| if (components.size() > 1 && !TryParse(components[1], &version.minor, 10)) | ||
| return {}; | ||
| if (components.size() > 2 && !TryParse(components[2], &version.build, 10)) | ||
| return {}; | ||
| return version; | ||
| } | ||
| }; | ||
|
|
||
| enum class VersionCheckStatus | ||
| { | ||
| NothingToDo, | ||
| UpdateOptional, | ||
| UpdateRequired, | ||
| }; | ||
|
|
||
| struct VersionCheckResult | ||
| { | ||
| VersionCheckStatus status{VersionCheckStatus::NothingToDo}; | ||
| std::optional<BuildVersion> current_version{}; | ||
| std::optional<BuildVersion> target_version{}; | ||
| }; | ||
|
|
||
| class BuildInfo | ||
| { | ||
| using Map = std::map<std::string, std::string>; | ||
|
|
||
| public: | ||
| BuildInfo() = default; | ||
| BuildInfo(const std::string& content); | ||
|
|
||
| std::optional<std::string> GetString(const std::string& name) const | ||
| { | ||
| auto it = map.find(name); | ||
| if (it == map.end() || it->second.size() == 0) | ||
| return {}; | ||
| return it->second; | ||
| } | ||
|
|
||
| std::optional<BuildVersion> GetVersion(const std::string& name) const | ||
| { | ||
| auto str = GetString(name); | ||
| if (!str.has_value()) | ||
| return {}; | ||
| return BuildVersion::from_string(str.value()); | ||
| } | ||
|
|
||
| private: | ||
| void Parse(const std::string& content) | ||
| { | ||
| std::stringstream content_stream(content); | ||
| std::string line; | ||
| while (std::getline(content_stream, line)) | ||
| { | ||
| if (line.starts_with("//")) | ||
| continue; | ||
| const size_t equals_index = line.find('='); | ||
| if (equals_index == line.npos) | ||
| continue; | ||
| auto key = line.substr(0, equals_index); | ||
| auto key_it = map.find(key); | ||
| if (key_it == map.end()) | ||
| continue; | ||
| key_it->second = line.substr(equals_index + 1); | ||
| } | ||
| } | ||
| Map map; | ||
| }; | ||
|
|
||
| bool VersionCheck(const BuildInfo& this_build_info, const BuildInfo& next_build_info); | ||
| } // namespace Platform |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.