From 5acd1e12154052063cad8ff077f1ed53049f3e10 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Sun, 20 Jul 2025 01:54:50 -0500 Subject: [PATCH] Add build-windows.bat script for building on Windows --- .gitlab-ci.yml | 96 ++--------------------------------- OpenRGBE131ReceiverPlugin.pro | 8 +++ scripts/build-windows.bat | 70 +++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 92 deletions(-) create mode 100644 scripts/build-windows.bat diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 186e7c9..7e5a9a4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -215,52 +215,8 @@ 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/56183447/download' - - curl.exe -LJ -o qt-tools.7z 'https://gitlab.com/OpenRGBDevelopers/openrgb-linux-ci-deb-builder/-/package_files/56183451/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 - - _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 ..\OpenRGBE131ReceiverPlugin.pro - - _fold_final_ - - - _fold_start_ 'start the actual build with jom instead of nmake; for speed' - - nmake - - _fold_final_ - - - _fold_start_ 'Preparing artifact' - - mv release/OpenRGBE131ReceiverPlugin.dll ../ - - _fold_final_ - + - scripts\build-windows.bat 5.15.0 2019 32 + - mv "OpenRGBE131ReceiverPlugin Windows 32-Bit\OpenRGBE131ReceiverPlugin.dll" . artifacts: name: "${CI_PROJECT_NAME}_Windows_32_${CI_COMMIT_SHORT_SHA}" paths: @@ -275,52 +231,8 @@ 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/56183457/download' - - curl.exe -LJ -o qt-tools.7z 'https://gitlab.com/OpenRGBDevelopers/openrgb-linux-ci-deb-builder/-/package_files/56183464/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 - - _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 ..\OpenRGBE131ReceiverPlugin.pro - - _fold_final_ - - - _fold_start_ 'start the actual build with jom instead of nmake; for speed' - - nmake - - _fold_final_ - - - _fold_start_ 'Preparing artifact' - - mv release/OpenRGBE131ReceiverPlugin.dll ../ - - _fold_final_ - + - scripts\build-windows.bat 5.15.0 2019 64 + - mv "OpenRGBE131ReceiverPlugin Windows 64-Bit\OpenRGBE131ReceiverPlugin.dll" . artifacts: name: "${CI_PROJECT_NAME}_Windows_64_${CI_COMMIT_SHORT_SHA}" paths: diff --git a/OpenRGBE131ReceiverPlugin.pro b/OpenRGBE131ReceiverPlugin.pro index 8381d69..ee28784 100644 --- a/OpenRGBE131ReceiverPlugin.pro +++ b/OpenRGBE131ReceiverPlugin.pro @@ -132,6 +132,14 @@ RESOURCES += #-----------------------------------------------------------------------------------------------# win32:CONFIG += c++17 +win32:CONFIG(debug, debug|release) { + win32:DESTDIR = debug +} + +win32:CONFIG(release, debug|release) { + win32:DESTDIR = release +} + win32:contains(QMAKE_TARGET.arch, x86_64) { LIBS += \ -lws2_32 \ diff --git a/scripts/build-windows.bat b/scripts/build-windows.bat new file mode 100644 index 0000000..6188f07 --- /dev/null +++ b/scripts/build-windows.bat @@ -0,0 +1,70 @@ +::---------------------------------------------------------:: +:: OpenRGB E.131 Receiver Plugin Windows Build Script :: +:: :: +:: Sets up build environment for desired Qt version and :: +:: build architecture, then builds OpenRGB E1.31 Receiver :: +:: Plugin :: +:: :: +:: Prerequisites: :: +:: * Microsoft Visual Studio Build Tools :: +:: * OpenRGB Qt Packages :: +:: :: +:: Adam Honse (calcprogrammer1@gmail.com) 20 Jul 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% + +::---------------------------------------------------------:: +:: Run qmake to configure the build :: +::---------------------------------------------------------:: +qmake OpenRGBE131ReceiverPlugin.pro CONFIG-=debug_and_release CONFIG+=release + +::---------------------------------------------------------:: +:: Run jom to execute the build :: +::---------------------------------------------------------:: +jom + +::---------------------------------------------------------:: +:: Rename the release folder :: +::---------------------------------------------------------:: +move "release" "OpenRGBE131ReceiverPlugin Windows %BITS%-bit"