From abffe46d8bb6b3eeb175998ad511ad5f183b6a14 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Fri, 18 Apr 2025 16:52:15 -0500 Subject: [PATCH] Add build-windows.bat file for managing the Windows builds and update CI to use it --- .gitlab-ci.yml | 112 +------------------------------------- scripts/build-windows.bat | 81 +++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 110 deletions(-) create mode 100644 scripts/build-windows.bat diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a34fba0d..ac709aca 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -411,61 +411,7 @@ before_script: - .shared_windows_runners stage: build script: - - $esc = "$([char]27)" - - $count = 0 - - function _unix_tmsec_ { [int64](([datetime]::UtcNow)-(get-date "1/1/1970")).TotalSeconds } - - function _fold_start_ { param( [string]$TEXT_TAG ) $t=_unix_tmsec_; $global:count += 1; Write-Host -NoNewLine "`r`n`r`nsection_start:${t}:sect_${count}`r${esc}[0K${esc}[33m${TEXT_TAG}${esc}[39m`r`n"; } - - function _fold_final_ { $t=_unix_tmsec_; Write-Host -NoNewLine "`r`n`r`nsection_end:${t}:sect_${count}`r${esc}[0K`r`n" ; } - - - - _fold_start_ 'configuring the msvc environment variables' - - Push-Location "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Auxiliary/Build" - - '& cmd.exe /C "vcvarsall.bat x86 & set" | Foreach-Object { if ($_ -match "(.*?)=(.*)") { Set-Item -force -path "Env:\$($matches[1])" -value "$($matches[2])" } }' - - Pop-Location - - _fold_final_ - - - _fold_start_ 'downloading precompiled versions of qtbase, qttools (for windeployqt) and jom (for a more parallel nmake)' - - mkdir _qt - - mkdir _qt_download - - Push-Location _qt_download - - curl.exe -LJ -o qt-base.7z 'https://gitlab.com/OpenRGBDevelopers/openrgb-linux-ci-deb-builder/-/package_files/55610076/download' - - curl.exe -LJ -o qt-tools.7z 'https://gitlab.com/OpenRGBDevelopers/openrgb-linux-ci-deb-builder/-/package_files/55610097/download' - - curl.exe -LJ -o qt-jom.zip 'https://gitlab.com/OpenRGBDevelopers/openrgb-linux-ci-deb-builder/-/package_files/55610138/download' - - _fold_final_ - - - _fold_start_ 'extracting the downloaded qt binaries' - - 7z x qt-base.7z '-o../_qt' -y - - 7z x qt-tools.7z '-o../_qt' -y - - 7z x qt-jom.zip '-o../_qt' -y - - _fold_final_ - - - _fold_start_ 'turn the qt install from enterprise to foss; remove the licensing checks' - - ${qconfig-pri-folder} = '..\_qt\5.15.0\msvc2019\mkspecs\qconfig.pri' - - (Get-Content ${qconfig-pri-folder}).replace('QT_EDITION = Enterprise', 'QT_EDITION = OpenSource') | Set-Content ${qconfig-pri-folder} - - (Get-Content ${qconfig-pri-folder}).replace('QT_LICHECK = licheck.exe', '') | Set-Content ${qconfig-pri-folder} - - Pop-Location - - _fold_final_ - - - _fold_start_ 'run qmake and generate the msvc nmake makefile' - - mkdir _build; cd _build - - ..\_qt\5.15.0\msvc2019\bin\qmake ..\OpenRGB.pro - - _fold_final_ - - - _fold_start_ 'start the actual build with jom instead of nmake; for speed' - - ..\_qt\jom - - _fold_final_ - - - _fold_start_ 'run windeployqt to automatically copy the needed dll files' - - ..\_qt\5.15.0\msvc2019\bin\windeployqt --no-angle --no-translations --no-opengl-sw --no-system-d3d-compiler --no-compiler-runtime --no-webkit2 .\release\ - - _fold_final_ - - - _fold_start_ 'Moving results for upload' - - mv release ../'OpenRGB Windows 32-bit' - - _fold_final_ -# cache: -# key: same-key -# paths: -# - C:\vcpkg\installed\ + - scripts\build-windows.bat 6.8.3 2022 32 artifacts: name: "${CI_PROJECT_NAME}_Windows_32_${CI_COMMIT_SHORT_SHA}" paths: @@ -485,61 +431,7 @@ before_script: - .shared_windows_runners stage: build script: - - $esc = "$([char]27)" - - $count = 0 - - function _unix_tmsec_ { [int64](([datetime]::UtcNow)-(get-date "1/1/1970")).TotalSeconds } - - function _fold_start_ { param( [string]$TEXT_TAG ) $t=_unix_tmsec_; $global:count += 1; Write-Host -NoNewLine "`r`n`r`nsection_start:${t}:sect_${count}`r${esc}[0K${esc}[33m${TEXT_TAG}${esc}[39m`r`n"; } - - function _fold_final_ { $t=_unix_tmsec_; Write-Host -NoNewLine "`r`n`r`nsection_end:${t}:sect_${count}`r${esc}[0K`r`n" ; } - - - - _fold_start_ 'configuring the msvc environment variables' - - Push-Location "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Auxiliary/Build" - - '& cmd.exe /C "vcvarsall.bat x64 & set" | Foreach-Object { if ($_ -match "(.*?)=(.*)") { Set-Item -force -path "Env:\$($matches[1])" -value "$($matches[2])" } }' - - Pop-Location - - _fold_final_ - - - _fold_start_ 'downloading precompiled versions of qtbase, qttools (for windeployqt) and jom (for a more parallel nmake)' - - mkdir _qt - - mkdir _qt_download - - Push-Location _qt_download - - curl.exe -LJ -o qt-base.7z 'https://gitlab.com/OpenRGBDevelopers/openrgb-linux-ci-deb-builder/-/package_files/55610116/download' - - curl.exe -LJ -o qt-tools.7z 'https://gitlab.com/OpenRGBDevelopers/openrgb-linux-ci-deb-builder/-/package_files/55610131/download' - - curl.exe -LJ -o qt-jom.zip 'https://gitlab.com/OpenRGBDevelopers/openrgb-linux-ci-deb-builder/-/package_files/55610138/download' - - _fold_final_ - - - _fold_start_ 'extracting the downloaded qt binaries' - - 7z x qt-base.7z '-o../_qt' -y - - 7z x qt-tools.7z '-o../_qt' -y - - 7z x qt-jom.zip '-o../_qt' -y - - _fold_final_ - - - _fold_start_ 'turn the qt install from enterprise to foss; remove the licensing checks' - - ${qconfig-pri-folder} = '..\_qt\5.15.0\msvc2019_64\mkspecs\qconfig.pri' - - (Get-Content ${qconfig-pri-folder}).replace('QT_EDITION = Enterprise', 'QT_EDITION = OpenSource') | Set-Content ${qconfig-pri-folder} - - (Get-Content ${qconfig-pri-folder}).replace('QT_LICHECK = licheck.exe', '') | Set-Content ${qconfig-pri-folder} - - Pop-Location - - _fold_final_ - - - _fold_start_ 'run qmake and generate the msvc nmake makefile' - - mkdir _build; cd _build - - ..\_qt\5.15.0\msvc2019_64\bin\qmake ..\OpenRGB.pro - - _fold_final_ - - - _fold_start_ 'start the actual build with jom instead of nmake; for speed' - - ..\_qt\jom - - _fold_final_ - - - _fold_start_ 'run windeployqt to automatically copy the needed dll files' - - ..\_qt\5.15.0\msvc2019_64\bin\windeployqt --no-angle --no-translations --no-opengl-sw --no-system-d3d-compiler --no-compiler-runtime --no-webkit2 .\release\ - - _fold_final_ - - - _fold_start_ 'Moving results for upload' - - mv release ../'OpenRGB Windows 64-bit' - - _fold_final_ -# cache: -# key: same-key -# paths: -# - C:\vcpkg\installed\ + - scripts\build-windows.bat 6.8.3 2022 64 artifacts: name: "${CI_PROJECT_NAME}_Windows_64_${CI_COMMIT_SHORT_SHA}" paths: diff --git a/scripts/build-windows.bat b/scripts/build-windows.bat new file mode 100644 index 00000000..e8ccb898 --- /dev/null +++ b/scripts/build-windows.bat @@ -0,0 +1,81 @@ +::---------------------------------------------------------:: +:: OpenRGB Windows Build Script :: +:: :: +:: Sets up build environment for desired Qt version and :: +:: build architecture, then builds OpenRGB :: +:: :: +:: Prerequisites: :: +:: * Microsoft Visual Studio Build Tools :: +:: * OpenRGB Qt Packages :: +:: :: +:: Adam Honse (calcprogrammer1@gmail.com) 18 Apr 2025 :: +::---------------------------------------------------------:: + +::---------------------------------------------------------:: +:: Parse arguments :: +:: Format: build-windows.bat QT_VER MSVC_VER BITS :: +:: Example: build-windows.bat 6.3.8 2022 64 :: +::---------------------------------------------------------:: +@SET QT_VER=%1 +@SET MSVC_VER=%2 +@SET BITS=%3 + +::---------------------------------------------------------:: +:: Set variables based on bits value :: +::---------------------------------------------------------:: +@if %BITS% == 32 goto bits_32 +@if %BITS% == 64 goto bits_64 + +:bits_32 +@SET MSVC_ARCH=x86 +@SET QT_PATH= +goto bits_done + +:bits_64 +@SET MSVC_ARCH=x64 +@SET QT_PATH=_64 +goto bits_done + +:bits_done + +::---------------------------------------------------------:: +:: Add desired Qt version to PATH :: +::---------------------------------------------------------:: +@SET "PATH=%PATH%;C:\Qt\%QT_VER%\msvc%MSVC_VER%%QT_PATH%\bin" + +::---------------------------------------------------------:: +:: Add jom to PATH :: +::---------------------------------------------------------:: +@SET "PATH=%PATH%;C:\Qt\jom" + +::---------------------------------------------------------:: +:: Run vcvarsall :: +::---------------------------------------------------------:: +@call "C:\Program Files (x86)\Microsoft Visual Studio\%MSVC_VER%\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" %MSVC_ARCH% + +::---------------------------------------------------------:: +:: Re-create build directory and cd into it :: +::---------------------------------------------------------:: +::rm -r build +::mkdir build +::cd build + +::---------------------------------------------------------:: +:: Run qmake to configure the build :: +::---------------------------------------------------------:: +qmake OpenRGB.pro CONFIG-=debug_and_release CONFIG+=release + +::---------------------------------------------------------:: +:: Run jom to execute the build :: +::---------------------------------------------------------:: +jom + +::---------------------------------------------------------:: +:: Run windeployqt to copy the Qt dll files :: +::---------------------------------------------------------:: +windeployqt --no-system-d3d-compiler --no-compiler-runtime .\release\ + +::---------------------------------------------------------:: +:: Rename the release folder :: +::---------------------------------------------------------:: +move "release" "OpenRGB Windows %BITS%-bit"