diff --git a/.CI/build-installer.ps1 b/.CI/build-installer.ps1 index 756a1503f..b60145d82 100644 --- a/.CI/build-installer.ps1 +++ b/.CI/build-installer.ps1 @@ -42,7 +42,7 @@ $VCRTVersion = (Get-Item "$Env:VCToolsRedistDir\vc_redist.x64.exe").VersionInfo; ISCC ` /DWORKING_DIR="$($pwd.Path)\" ` /DINSTALLER_BASE_NAME="$installerBaseName" ` - /DSHIPPED_VCRT_BUILD="$($VCRTVersion.FileBuildPart)" ` + /DSHIPPED_VCRT_MINOR="$($VCRTVersion.FileMinorPart)" ` /DSHIPPED_VCRT_VERSION="$($VCRTVersion.FileDescription)" ` $defines ` /O. ` diff --git a/.CI/chatterino-installer.iss b/.CI/chatterino-installer.iss index 1f9816a29..5068a3c29 100644 --- a/.CI/chatterino-installer.iss +++ b/.CI/chatterino-installer.iss @@ -120,15 +120,15 @@ begin Result := VCRTVersion + ' is installed'; end; -// Checks if a new VCRT is needed by comparing the builds. +// Checks if a new VCRT is needed by comparing the minor version (the major one is locked at 14). function NeedsNewVCRT(): Boolean; var VCRTBuild: Cardinal; begin Result := True; - if RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64', 'Bld', VCRTBuild) then + if RegQueryDWordValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64', 'Minor', VCRTBuild) then begin - if VCRTBuild >= {#SHIPPED_VCRT_BUILD} then + if VCRTBuild >= {#SHIPPED_VCRT_MINOR} then Result := False; end; end; diff --git a/.CI/deploy-crt.ps1 b/.CI/deploy-crt.ps1 new file mode 100644 index 000000000..cab12693e --- /dev/null +++ b/.CI/deploy-crt.ps1 @@ -0,0 +1,30 @@ +param ( + [string] $InstallDir = "Chatterino2" +) + +if ($null -eq $Env:VCToolsRedistDir) { + Write-Error "VCToolsRedistDir is not set. Forgot to set Visual Studio environment variables?"; + exit 1 +} + +# A path to the runtime libraries (e.g. "$Env:VCToolsRedistDir\onecore\x64\Microsoft.VC143.CRT") +$vclibs = (Get-ChildItem "$Env:VCToolsRedistDir\onecore\x64" -Filter '*.CRT')[0].FullName; + +# All executables and libraries in the installation directory +$targets = Get-ChildItem -Recurse -Include '*.dll', '*.exe' $InstallDir; +# All dependencies of the targets (with duplicates) +$all_deps = $targets | ForEach-Object { (dumpbin /DEPENDENTS $_.FullName) -match '^(?!Dump of).+\.dll$' } | ForEach-Object { $_.Trim() }; +# All dependencies without duplicates +$dependencies = $all_deps | Sort-Object -Unique; + +$n_deployed = 0; +foreach ($dll in $dependencies) { + Write-Output "Checking for $dll"; + if (Test-Path -PathType Leaf "$vclibs\$dll") { + Write-Output "Deploying $dll"; + Copy-Item "$vclibs\$dll" "$InstallDir\$dll" -Force; + $n_deployed++; + } +} + +Write-Output "Deployed $n_deployed libraries"; diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c45b0165b..a28072ddd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -251,6 +251,7 @@ jobs: cd build windeployqt bin/chatterino.exe --release --no-compiler-runtime --no-translations --no-opengl-sw --dir Chatterino2/ cp bin/chatterino.exe Chatterino2/ + ..\.CI\deploy-crt.ps1 Chatterino2 echo nightly > Chatterino2/modes - name: Package (windows) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40ac9b928..77753dbaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ - Dev: Removed unused timegate settings. (#5361) - Dev: All Lua globals now show in the `c2` global in the LuaLS metadata. (#5385) - Dev: Images are now loaded in worker threads. (#5431) +- Dev: The MSVC CRT is now bundled with Chatterino as it depends on having a recent version installed. (#5447) ## 2.5.1 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 15806aae1..72fa4851a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -865,6 +865,7 @@ if (BUILD_APP) endif() get_filename_component(QT_BIN_DIR ${QT_CORE_LOC} DIRECTORY) + # This assumes the installed CRT is up-to-date (see .CI/deploy-crt.ps1) set(WINDEPLOYQT_COMMAND_ARGV "${WINDEPLOYQT_PATH}" "$" ${WINDEPLOYQT_MODE} --no-compiler-runtime --no-translations --no-opengl-sw) string(REPLACE ";" " " WINDEPLOYQT_COMMAND "${WINDEPLOYQT_COMMAND_ARGV}")