Add build-windows.bat script for building on Windows

This commit is contained in:
Adam Honse 2025-07-20 01:54:50 -05:00
parent 2341457d1d
commit 5acd1e1215
3 changed files with 82 additions and 92 deletions

View file

@ -215,52 +215,8 @@ before_script:
- .shared_windows_runners - .shared_windows_runners
stage: build stage: build
script: script:
- $esc = "$([char]27)" - scripts\build-windows.bat 5.15.0 2019 32
- $count = 0 - mv "OpenRGBE131ReceiverPlugin Windows 32-Bit\OpenRGBE131ReceiverPlugin.dll" .
- 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_
artifacts: artifacts:
name: "${CI_PROJECT_NAME}_Windows_32_${CI_COMMIT_SHORT_SHA}" name: "${CI_PROJECT_NAME}_Windows_32_${CI_COMMIT_SHORT_SHA}"
paths: paths:
@ -275,52 +231,8 @@ before_script:
- .shared_windows_runners - .shared_windows_runners
stage: build stage: build
script: script:
- $esc = "$([char]27)" - scripts\build-windows.bat 5.15.0 2019 64
- $count = 0 - mv "OpenRGBE131ReceiverPlugin Windows 64-Bit\OpenRGBE131ReceiverPlugin.dll" .
- 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_
artifacts: artifacts:
name: "${CI_PROJECT_NAME}_Windows_64_${CI_COMMIT_SHORT_SHA}" name: "${CI_PROJECT_NAME}_Windows_64_${CI_COMMIT_SHORT_SHA}"
paths: paths:

View file

@ -132,6 +132,14 @@ RESOURCES +=
#-----------------------------------------------------------------------------------------------# #-----------------------------------------------------------------------------------------------#
win32:CONFIG += c++17 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) { win32:contains(QMAKE_TARGET.arch, x86_64) {
LIBS += \ LIBS += \
-lws2_32 \ -lws2_32 \

70
scripts/build-windows.bat Normal file
View file

@ -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"