Merge pull request #11247 from rouault/fix_11246 #19026
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Windows builds | |
on: | |
push: | |
paths-ignore: | |
- 'doc/**' | |
- 'docker/**' | |
branches-ignore: | |
- 'backport**' | |
- 'dependabot**' | |
pull_request: | |
paths-ignore: | |
- 'doc/**' | |
- 'docker/**' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
jobs: | |
windows_build: | |
runs-on: windows-2022 | |
strategy: | |
matrix: | |
include: | |
- VS_VERSION: Visual Studio 17 | |
VS_VER: 2022 | |
SDK: release-1930 | |
platform: x86 | |
PROJ_BRANCH: "9.3" | |
LIBZSTD_URL: "https://github.com/facebook/zstd/releases/download/v1.4.5/zstd-v1.4.5-win32.zip" | |
LIBDEFLATE_URL: "https://github.com/ebiggers/libdeflate/releases/download/v1.6/libdeflate-1.6-windows-i686-bin.zip" | |
SWIG_URL: "https://freefr.dl.sourceforge.net/project/swig/swigwin/swigwin-4.1.1/swigwin-4.1.1.zip" | |
env: | |
VS_VERSION: ${{ matrix.VS_VERSION }} | |
VS_VER: ${{ matrix.VS_VER }} | |
SDK: ${{ matrix.SDK }} | |
platform: ${{ matrix.platform }} | |
PROJ_BRANCH: "${{ matrix.PROJ_BRANCH }}" | |
LIBZSTD_URL: "${{ matrix.LIBZSTD_URL }}" | |
LIBDEFLATE_URL: "${{ matrix.LIBDEFLATE_URL }}" | |
SWIG_URL: "${{ matrix.SWIG_URL }}" | |
APPVEYOR: true # to skip some tests | |
PYTHON_VERSION: "3.10.5" | |
steps: | |
# To avoid git clone to mess with the line endings of GDAL autotest data | |
# files that look like text, but should be handled as binary content | |
- name: Set git core.autocrlf to false | |
run: | | |
git config --global core.autocrlf false | |
- name: Checkout | |
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 | |
- name: Set environment | |
shell: pwsh | |
run: | | |
$env:PATH="C:\hostedtoolcache\windows\Python\$env:PYTHON_VERSION\$env:platform;C:\hostedtoolcache\windows\Python\$env:PYTHON_VERSION\$env:platform\Scripts;$env:PATH" | |
if($env:platform -eq "x86") | |
{ | |
$env:ARCHITECTURE="x86" | |
$env:WIN64_ARG="" | |
$env:CMAKE_ARCHITECTURE="Win32" | |
} | |
else | |
{ | |
$env:ARCHITECTURE="amd64" | |
$env:WIN64_ARG="WIN64=YES" | |
$env:CMAKE_ARCHITECTURE="x64" | |
} | |
echo "PATH=$env:PATH" >> $env:GITHUB_ENV | |
echo "ARCHITECTURE=$env:ARCHITECTURE" >> $env:GITHUB_ENV | |
echo "WIN64_ARG=$env:WIN64_ARG" >> $env:GITHUB_ENV | |
echo "CMAKE_ARCHITECTURE=$env:CMAKE_ARCHITECTURE" >> $env:GITHUB_ENV | |
- name: Set compiler environment | |
shell: cmd | |
run: | | |
if "%VS_VER%" == "2022" CALL "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=%ARCHITECTURE% | |
echo PATH=%PATH%>> %GITHUB_ENV% | |
echo INCLUDE=%INCLUDE%>> %GITHUB_ENV% | |
echo LIB=%LIB%>> %GITHUB_ENV% | |
echo LIBPATH=%LIBPATH%>> %GITHUB_ENV% | |
- name: Remove conflicting libraries | |
shell: bash -l {0} | |
run: | | |
rm -rf C:/Strawberry || /bin/true | |
- name: Detect AVX2 | |
shell: bash | |
run: | | |
set -e | |
cl .github/workflows/detect-avx2.c | |
if ./detect-avx2.exe; then | |
echo "AVX2 available on CPU" | |
echo "ARCH_FLAGS=/arch:AVX2" >> $GITHUB_ENV | |
else | |
echo "AVX2 not available on CPU." | |
echo "ARCH_FLAGS=" >> $GITHUB_ENV | |
fi | |
- name: Build | |
shell: pwsh | |
run: | | |
$ErrorActionPreference = 'continue' | |
function exec | |
{ | |
param ( [ScriptBlock] $ScriptBlock ) | |
& $ScriptBlock 2>&1 | ForEach-Object -Process { "$_" } | |
if ($LastExitCode -ne 0) { exit $LastExitCode } | |
} | |
echo "ARCH_FLAGS = $env:ARCH_FLAGS" | |
exec { git clone --depth=1 -b $env:PROJ_BRANCH https://github.com/OSGeo/PROJ proj } | |
Import-PackageProvider NuGet -Force | |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | |
Install-Module Pscx -AllowClobber | |
Install-Module VSSetup -Scope CurrentUser | |
exec { pip install numpy } | |
$env:SDK_ZIP="$env:SDK"+"-dev.zip" | |
$env:SDK_URL="http://download.gisinternals.com/sdk/downloads/$env:SDK_ZIP" | |
if(-Not (Test-Path -Path downloads)) { mkdir downloads } | |
cd downloads | |
if(-Not (Test-Path -Path $env:SDK_ZIP )) { Invoke-WebRequest "$env:SDK_URL" -OutFile "$env:SDK_ZIP" } | |
$env:LIBZSTD_ZIP="libzstd.zip" | |
if(-Not (Test-Path -Path $env:LIBZSTD_ZIP -PathType Leaf)) { Invoke-WebRequest "$env:LIBZSTD_URL" -OutFile "$env:LIBZSTD_ZIP" } | |
$env:SWIG_ZIP="swigwin-4.1.1.zip" | |
if(-Not (Test-Path -Path $env:SWIG_ZIP -PathType Leaf)) { Invoke-WebRequest "$env:SWIG_URL" -OutFile "$env:SWIG_ZIP" } | |
# $env:LIBDEFLATE_ZIP="libdeflate.zip" | |
# if(-Not (Test-Path -Path $env:LIBDEFLATE_ZIP -PathType Leaf)) { Invoke-WebRequest "$env:LIBDEFLATE_URL" -OutFile "$env:LIBDEFLATE_ZIP" } | |
cd .. | |
mkdir sdk | |
cd sdk | |
exec { 7z x ..\downloads\$env:SDK_ZIP } | |
cd $env:SDK | |
#exec { 7z x ..\..\downloads\$env:LIBZSTD_ZIP } | |
exec { 7z x ..\..\downloads\$env:SWIG_ZIP } | |
# exec { 7z x -y ..\..\downloads\$env:LIBDEFLATE_ZIP } | |
cd .. | |
$env:SDK_PREFIX="$env:GITHUB_WORKSPACE\sdk\$env:SDK" | |
$env:SDK_LIB="$env:SDK_PREFIX\lib" | |
cd $env:GITHUB_WORKSPACE | |
cd proj | |
mkdir build | |
cd build | |
$env:VCPKG_PLATFORM="$env:platform"+"-windows" | |
exec { vcpkg install sqlite3:$env:VCPKG_PLATFORM } | |
Invoke-WebRequest "https://sqlite.org/2018/sqlite-tools-win32-x86-3250100.zip" -OutFile "sqlite-tools-win32-x86-3250100.zip" | |
7z x sqlite-tools-win32-x86-3250100.zip | |
copy sqlite-tools-win32-x86-3250100/sqlite3.exe $env:GITHUB_WORKSPACE | |
$env:PATH="$env:GITHUB_WORKSPACE;$env:PATH" | |
$env:PROJ_INSTALL_DIR="$env:GITHUB_WORKSPACE"+"\install-proj" | |
$env:CMAKE_INSTALL_PREFIX="-DCMAKE_INSTALL_PREFIX=" + $env:PROJ_INSTALL_DIR | |
cmake -G $env:VS_VERSION -A $env:CMAKE_ARCHITECTURE .. $env:CMAKE_INSTALL_PREFIX -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_LIBPROJ_SHARED=ON -DCMAKE_TOOLCHAIN_FILE=c:/vcpkg/scripts/buildsystems/vcpkg.cmake -DBUILD_SHARED_LIBS=ON -DENABLE_CURL=OFF -DENABLE_TIFF=OFF -DBUILD_PROJSYNC=OFF | |
exec { cmake --build . --config Release --target install } | |
# | |
cd $env:GITHUB_WORKSPACE | |
mkdir build | |
cd build | |
$env:SDK_BIN="$env:SDK_PREFIX\bin" | |
$env:PATH="$env:SDK_BIN;$env:SDK\swigwin-4.1.1;$env:PATH" | |
$env:GDAL_INSTALL_DIR="$env:GITHUB_WORKSPACE"+"\install-gdal" | |
$env:CMAKE_INSTALL_PREFIX="-DCMAKE_INSTALL_PREFIX=" + $env:GDAL_INSTALL_DIR | |
$env:PROJ_ROOT="-DPROJ_ROOT=" + $env:PROJ_INSTALL_DIR | |
$env:CMAKE_PREFIX_PATH="-DCMAKE_PREFIX_PATH=" + $env:SDK_PREFIX | |
$env:MYSQL_LIBRARY="-DMYSQL_LIBRARY=" + $env:SDK_LIB + "\libmysql.lib" | |
$env:POPPLER_EXTRA_LIBRARIES="-DPOPPLER_EXTRA_LIBRARIES=" + $env:SDK_LIB + "\freetype.lib;" + $env:SDK_LIB + "\harfbuzz.lib" | |
# We disable Spatialite and external geotiff as they link to gisinternals proj9 and we have the following linking error | |
# referring to a file from the gisinternals build machine... | |
# LINK : fatal error LNK1181: cannot open input file 'E:\buildsystem\release-1930\lib\proj9.lib' [D:\a\gdal\gdal\build\GDAL.vcxproj] | |
# Disabling HDF4 (and netCDF) for similar reason: LINK : fatal error LNK1181: cannot open input file 'E:\buildsystem\release-1930\lib\mfhdf.lib' | |
# Disabling KEA because of "keadataset.obj : error LNK2019: unresolved external symbol "public: static class H5::FileAccPropList const & const H5::FileAccPropList::DEFAULT" | |
cmake -G $env:VS_VERSION -A $env:CMAKE_ARCHITECTURE .. $env:CMAKE_INSTALL_PREFIX -DCMAKE_BUILD_TYPE=Release $env:CMAKE_PREFIX_PATH -DCMAKE_C_FLAGS=" /WX $env:ARCH_FLAGS" -DCMAKE_CXX_FLAGS=" /WX $env:ARCH_FLAGS" -DGDAL_USE_DEFLATE=OFF $env:PROJ_ROOT $env:MYSQL_LIBRARY $env:POPPLER_EXTRA_LIBRARIES -DGDAL_USE_ZLIB_INTERNAL=ON -DECW_INTERFACE_COMPILE_DEFINITIONS="_MBCS;_UNICODE;UNICODE;_WINDOWS;LIBECWJ2;WIN32;_WINDLL;NO_X86_MMI" -DBUILD_CSHARP_BINDINGS=OFF -DBUILD_JAVA_BINDINGS=OFF -DOGR_ENABLE_DRIVER_LIBKML=OFF -DGDAL_USE_SPATIALITE=OFF -DGDAL_USE_GEOTIFF_INTERNAL=ON -DGDAL_USE_HDF4=OFF -DGDAL_USE_NETCDF=OFF -DGDAL_USE_WEBP=OFF -DGDAL_USE_KEA=OFF | |
exec { cmake --build . --config Release --target install } | |
- name: Run tests | |
shell: pwsh | |
run: | | |
$ErrorActionPreference = 'continue' | |
function exec | |
{ | |
param ( [ScriptBlock] $ScriptBlock ) | |
& $ScriptBlock 2>&1 | ForEach-Object -Process { "$_" } | |
if ($LastExitCode -ne 0) { exit $LastExitCode } | |
} | |
$env:SDK_PREFIX="$env:GITHUB_WORKSPACE\sdk\$env:SDK" | |
$env:SDK_BIN="$env:SDK_PREFIX\bin" | |
$env:PATH="$env:GITHUB_WORKSPACE\build\Release;$env:GITHUB_WORKSPACE\build\apps\Release;$env:GITHUB_WORKSPACE\install-proj\bin;$env:SDK_BIN;$env:PATH" | |
$env:GDAL_DATA="$env:GITHUB_WORKSPACE\data" | |
$env:DO_NOT_FAIL_ON_RECODE_ERRORS="YES" | |
$env:MDB_ODBC_DRIVER_INSTALLED="YES" | |
# The ca-bundle.crt file which we could point to is invalid in the current SDK | |
# See https://github.com/gisinternals/buildsystem/issues/104 | |
$env:GDAL_HTTP_UNSAFESSL="YES" | |
cd $env:GITHUB_WORKSPACE\autotest | |
python3 -m pip install -Ur requirements.txt | |
# For some reason I can't debug remotely, gdal.dll can'be loaded. Probably something missing in the path | |
# exec { ctest --test-dir $env:GITHUB_WORKSPACE\build -C Release -V -j 3 -R autotest } |