Fixed MSVC2017 builds (#8594) #37
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/**' | |
branches-ignore: | |
- 'backport**' | |
pull_request: | |
paths-ignore: | |
- 'doc/**' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
jobs: | |
windows_build: | |
runs-on: windows-2022 | |
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')" | |
strategy: | |
matrix: | |
include: | |
- VS_VERSION: Visual Studio 17 | |
VS_VER: 2022 | |
SDK: release-1911 # gisinternals SDK version still to 2017 | |
MSVC_VER: 1920 | |
platform: x86 | |
PROJ_BRANCH: "7.2" | |
LIBWEBP_URL: "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.0.3-windows-x86.zip" | |
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" | |
env: | |
VS_VERSION: ${{ matrix.VS_VERSION }} | |
VS_VER: ${{ matrix.VS_VER }} | |
SDK: ${{ matrix.SDK }} | |
MSVC_VER: ${{ matrix.MSVC_VER }} | |
platform: ${{ matrix.platform }} | |
PROJ_BRANCH: "${{ matrix.PROJ_BRANCH }}" | |
LIBWEBP_URL: "${{ matrix.LIBWEBP_URL }}" | |
LIBZSTD_URL: "${{ matrix.LIBZSTD_URL }}" | |
LIBDEFLATE_URL: "${{ matrix.LIBDEFLATE_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@v4 | |
- 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 | |
# Install SWIG by Choco | |
exec { cinst -y --no-progress swig } | |
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:LIBWEBP_ZIP="libwebp.zip" | |
if(-Not (Test-Path -Path $env:LIBWEBP_ZIP -PathType Leaf)) { Invoke-WebRequest "$env:LIBWEBP_URL" -OutFile "$env:LIBWEBP_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:LIBWEBP_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 -DPROJ_TESTS=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:GITHUB_WORKSPACE\install-proj\bin;$env:SDK_BIN;$env:PATH" | |
exec { projinfo EPSG:4326 } | |
$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" | |
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 | |
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 } |