From 40db2bc8ec1a0e0715f408bf40962178e025d69c Mon Sep 17 00:00:00 2001 From: Magnus Gille Date: Sun, 1 Feb 2026 12:16:44 -0800 Subject: [PATCH] Standardize how the config is created for releases. (#4784) Build configuration for Windows was moved from appveyor.yml to appveyor/windows/before_build.ps1 and based on gcconfig.pri.in to match the other platforms, Python config is taken from PATH too. We could do the same with install and after_build too. Co-authored-by: Alejandro Martinez --- appveyor.yml | 37 ++---------- appveyor/windows/before_build.ps1 | 97 +++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+), 31 deletions(-) create mode 100644 appveyor/windows/before_build.ps1 diff --git a/appveyor.yml b/appveyor.yml index f0ce29296..a991ddfb7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -106,16 +106,12 @@ install: # GSL - cmd: vcpkg install gsl:x64-windows -# Get config -- cmd: copy qwt\qwtconfig.pri.in qwt\qwtconfig.pri -- cmd: copy c:\libs\gcconfig64Qt6-Release.appveyor.pri src\gcconfig.pri - # Get jom - cmd: if not exist jom_1_1_3.zip appveyor DownloadFile "https://download.qt.io/official_releases/jom/jom_1_1_3.zip" - cmd: 7z x -y jom_1_1_3.zip -oc:\jom\ - cmd: set PATH=%PATH%;c:\jom\; -# Get R and add to config +# Get R - ps: >- if ($isWindows -And -not (Test-Path 'C:\R')) { # Lets use 4.1 until 4.2 issues are fixed @@ -126,9 +122,8 @@ install: } - cmd: set PATH=%PATH%;c:\R\bin\; - cmd: R --version -- cmd: echo DEFINES+=GC_WANT_R >> src\gcconfig.pri -# Get Python and add to config +# Get Python - ps: >- if ($isWindows -And -not (Test-Path 'C:\Python')) { $pyurl = "https://www.python.org/ftp/python/3.11.9/python-3.11.9-embed-amd64.zip" @@ -142,40 +137,20 @@ install: } - cmd: set PATH=C:\Python311-x64\Scripts\;C:\Python311-x64\;%PATH% - cmd: python --version -- cmd: echo DEFINES+=GC_WANT_PYTHON >> src\gcconfig.pri -- cmd: echo PYTHONINCLUDES=Core c:\Python311-x64\include >> src\gcconfig.pri -- cmd: echo PYTHONLIBS=-L\"c:\Python311-x64\libs\" -lpython311 >> src\gcconfig.pri # Upgrade pip to ensure you have the latest version - cmd: python -m pip install --upgrade pip # Install your project's dependencies from a requirements.txt file - cmd: "python -m pip install --only-binary :all: -r src/Python/requirements.txt -t C:/Python/lib/site-packages" -# GSL -- cmd: echo GSL_INCLUDES=c:\tools\vcpkg\installed\x64-windows\include >> src\gcconfig.pri -- cmd: echo GSL_LIBS=-Lc:\tools\vcpkg\installed\x64-windows\lib -lgsl -lgslcblas >> src\gcconfig.pri # Linux / macOS - install dependencies first (including Python 3.11) - sh: bash appveyor/$OS_NAME/install.sh before_build: -# Windows -# Enable CloudDB -- cmd: echo CloudDB=active >> src\gcconfig.pri - -# Add Train Robot -- cmd: echo DEFINES+=GC_WANT_ROBOT >> src\gcconfig.pri - -# Enable TrainerDay Query API; pagesize depends on the keys remote configuration -- cmd: echo DEFINES+=GC_WANT_TRAINERDAY_API >> src\gcconfig.pri -- cmd: echo DEFINES+=GC_TRAINERDAY_API_PAGESIZE=25 >> src\gcconfig.pri - -# Avoid macro redefinition warnings -- cmd: echo DEFINES+=_MATH_DEFINES_DEFINED >> src\gcconfig.pri - -# Avoid conflicts between Windows.h min/max macros and limits.h -- cmd: echo DEFINES+=NOMINMAX >> src\gcconfig.pri - -# Linux / macOS +# Configure src/gcconfig.pri + # Windows +- ps: if ($isWindows) { appveyor\windows\before_build.ps1 } + # Linux / macOS - sh: bash appveyor/$OS_NAME/before_build.sh # For tagged builds, define GC version string diff --git a/appveyor/windows/before_build.ps1 b/appveyor/windows/before_build.ps1 new file mode 100644 index 000000000..202414334 --- /dev/null +++ b/appveyor/windows/before_build.ps1 @@ -0,0 +1,97 @@ +Copy-Item "qwt\qwtconfig.pri.in" "qwt\qwtconfig.pri" + +$gcconfig = "src\gcconfig.pri" +Copy-Item "src\gcconfig.pri.in" $gcconfig + +# Function to replace text in a file +function Replace-InFile { + param ( + [string]$File, + [string]$Pattern, + [string]$Replacement + ) + (Get-Content $File) -replace $Pattern, $Replacement | Set-Content $File +} + +# 1. App Name +Replace-InFile $gcconfig "#APP_NAME = " "APP_NAME = GoldenCheetah" + +# 2. Config Release +Replace-InFile $gcconfig "#CONFIG \+= release" "CONFIG += release" + +# 3. Disable strerror deprecation warning +Add-Content $gcconfig "`nDEFINES += _CRT_SECURE_NO_WARNINGS" + +# 4. lrelease +Replace-InFile $gcconfig "#QMAKE_LRELEASE = /usr/bin/lrelease" "QMAKE_LRELEASE = lrelease" + +# 5. Lex/Yacc +Replace-InFile $gcconfig "CONFIG \+= lex" "CONFIG += lex" +Replace-InFile $gcconfig "CONFIG \+= yacc" "CONFIG += yacc" +Replace-InFile $gcconfig "#QMAKE_LEX = win_flex --wincompat" "QMAKE_LEX = c:\libs\win_flex --wincompat" +Replace-InFile $gcconfig "#QMAKE_YACC = win_bison --file-prefix=y -t" "QMAKE_YACC = c:\libs\win_bison --file-prefix=y -t" + +# Add target_predeps for lex/yacc +Add-Content $gcconfig "lex.CONFIG += target_predeps" +Add-Content $gcconfig "yacc_impl.CONFIG += target_predeps" +Add-Content $gcconfig "yacc_decl.CONFIG += target_predeps" + +# 6. D2XX +Replace-InFile $gcconfig "#D2XX_INCLUDE =" "D2XX_INCLUDE = c:\libs\10_Precompiled_DLL\D2XX\CDM" +Replace-InFile $gcconfig "#D2XX_LIBS =" "D2XX_LIBS = -Lc:\libs\10_Precompiled_DLL\D2XX\CDM\Static\amd64 -lftd2xx" + +# 7. ICAL +Replace-InFile $gcconfig "#ICAL_INSTALL =" "ICAL_INSTALL = c:\libs\10_Precompiled_DLL\libical64" +Replace-InFile $gcconfig "#ICAL_INCLUDE =" "ICAL_INCLUDE = c:\libs\10_Precompiled_DLL\libical64\include" +Replace-InFile $gcconfig "#ICAL_LIBS =" "ICAL_LIBS = -Lc:\libs\10_Precompiled_DLL\libical64\lib-release -llibical-static" + +# 8. USBXPRESS +Replace-InFile $gcconfig "#USBXPRESS_INSTALL =" "USBXPRESS_INSTALL = c:\libs\10_Precompiled_DLL\usbexpress_3.5.1\USBXpress\USBXpress_API\Host" +Replace-InFile $gcconfig "#USBXPRESS_INCLUDE =" "USBXPRESS_INCLUDE = c:\libs\10_Precompiled_DLL\usbexpress_3.5.1\USBXpress\USBXpress_API\Host" +Replace-InFile $gcconfig "#USBXPRESS_LIBS =" "USBXPRESS_LIBS = -Lc:\libs\10_Precompiled_DLL\usbexpress_3.5.1\USBXpress\USBXpress_API\Host\x64 -lSiUSBXp" + +# 9. LIBUSB +Replace-InFile $gcconfig "#LIBUSB_INSTALL = /usr/local" "LIBUSB_INSTALL = c:\libs\10_Precompiled_DLL\libusb-win32-bin-1.2.6.0" +Replace-InFile $gcconfig "#LIBUSB_INCLUDE =" "LIBUSB_INCLUDE = c:\libs\10_Precompiled_DLL\libusb-win32-bin-1.2.6.0\include" +Replace-InFile $gcconfig "#LIBUSB_LIBS =" "LIBUSB_LIBS = -Lc:\libs\10_Precompiled_DLL\libusb-win32-bin-1.2.6.0\lib\msvc_x64 -llibusb" + +# 10. SAMPLERATE +Replace-InFile $gcconfig "#SAMPLERATE_INSTALL = /usr/local" "SAMPLERATE_INSTALL = c:\libs\10_Precompiled_DLL\libsamplerate64" +Replace-InFile $gcconfig "#SAMPLERATE_INCLUDE = /usr/local/include" "SAMPLERATE_INCLUDE = c:\libs\10_Precompiled_DLL\libsamplerate64\include" +Replace-InFile $gcconfig "#SAMPLERATE_LIBS = /usr/local/lib/libsamplerate.a" "SAMPLERATE_LIBS = -Lc:\libs\10_Precompiled_DLL\libsamplerate64\lib -llibsamplerate-0" + +# 11. HTPATH +Replace-InFile $gcconfig "#HTPATH = ../httpserver" "HTPATH = ../httpserver" + +# 12. Video +Replace-InFile $gcconfig "DEFINES \+= GC_VIDEO_NONE" "#DEFINES += GC_VIDEO_NONE" +Replace-InFile $gcconfig "#DEFINES \+= GC_VIDEO_QT6" "DEFINES += GC_VIDEO_QT6" + +# 13. R Support +Replace-InFile $gcconfig "#DEFINES \+= GC_WANT_R" "DEFINES += GC_WANT_R" + +# 14. Python Support +Replace-InFile $gcconfig "#DEFINES \+= GC_WANT_PYTHON" "DEFINES += GC_WANT_PYTHON" +Replace-InFile $gcconfig "#PYTHONINCLUDES =" "PYTHONINCLUDES = -ICore -I`"$(python -c "import sys; print(sys.prefix)")\include`"" +Replace-InFile $gcconfig "#PYTHONLIBS =" "PYTHONLIBS = -L`"$(python -c "import sys; print(sys.prefix)")\libs`" -lpython311" + +# 15. GSL Support +Replace-InFile $gcconfig "# GSL_INCLUDES = c:\\vcpkg\\installed\\x64-windows\\include" "GSL_INCLUDES = c:\tools\vcpkg\installed\x64-windows\include" +Replace-InFile $gcconfig "# GSL_LIBS = -LC:\\vcpkg\\installed\\x64-windows\\lib -lgsl -lgslcblas" "GSL_LIBS = -Lc:\tools\vcpkg\installed\x64-windows\lib -lgsl -lgslcblas" + +# 16. CloudDB +Replace-InFile $gcconfig "#CloudDB = active" "CloudDB = active" + +# 17. Train Robot +Replace-InFile $gcconfig "#DEFINES \+= GC_WANT_ROBOT" "DEFINES += GC_WANT_ROBOT" + +# 18. TrainerDay +Replace-InFile $gcconfig "#DEFINES \+= GC_WANT_TRAINERDAY_API" "DEFINES += GC_WANT_TRAINERDAY_API" +Replace-InFile $gcconfig "#DEFINES \+= GC_TRAINERDAY_API_PAGESIZE=25" "DEFINES += GC_TRAINERDAY_API_PAGESIZE=25" + +# 19. Math Defines and Nominmax +Add-Content $gcconfig "DEFINES += _MATH_DEFINES_DEFINED" +Replace-InFile $gcconfig "#DEFINES \+= NOMINMAX" "DEFINES += NOMINMAX" + +Add-Content $gcconfig "CONFIG += lex" +Add-Content $gcconfig "CONFIG += yacc"