From 9f945606da5c2c4de048bafe7b3726e0fce196bc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wolfgang=20St=C3=B6ggl?= Date: Tue, 29 Jun 2021 21:16:53 +0200 Subject: [PATCH] Update Windows GitHub Actions - Update ci-workflow.yml and add GitHub Actions for Windows builds using MSVC and vcpkg. Both, x64 and x86 builds are part of the CI. The required vcpkg ports are installed and cached using lukka/run-vcpkg@v7 - Add release-windows.yml, which enables building Windows binaries of RRDtool. This GitHub action is run automatically upon new tags and can be triggered manually. The required .exe and .dll files are copied using collect_rrdtool_vcpkg_files.bat and deployed by actions/upload-artifact@v2 - Makefile_vcpkg.msc: Add include\harfbuzz, which is required for building pango. Fixes: pango-coverage.h(28): fatal error C1083: Cannot open include file: 'hb.h': No such file or directory --- .github/workflows/ci-workflow.yml | 64 +++++++++++++++++++++++-- .github/workflows/release-windows.yml | 69 +++++++++++++++++++++++++++ win32/Makefile_vcpkg.msc | 1 + win32/collect_rrdtool_vcpkg_files.bat | 67 ++++++++++++++++++++++++++ 4 files changed, 198 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/release-windows.yml create mode 100644 win32/collect_rrdtool_vcpkg_files.bat diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index 4b11aee5..63a21ae3 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -1,10 +1,19 @@ --- -name: Windows MSYS2 x86_64 +name: Windows CI + +# yamllint disable rule:line-length +# yamllint disable-line rule:truthy on: [push, pull_request] jobs: - build: - runs-on: windows-latest + msys2: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + # https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md + os: [windows-2019] + carch: [x86_64] defaults: run: shell: msys2 {0} @@ -26,3 +35,52 @@ jobs: # with: # name: test-suite.log # path: tests/test-suite.log + MSVC: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + # https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md + os: [windows-2019] + triplet: [x64-windows, x86-windows] + include: + - os: windows-2019 + triplet: x64-windows + # https://github.com/microsoft/vcpkg/commit/b361c2eefa3966cb7cec45275aff32e90430aaa6 + vcpkgCommitId: 'b361c2eefa3966cb7cec45275aff32e90430aaa6' + vcpkgPackages: 'cairo expat fontconfig freetype gettext glib libpng libxml2 pango pcre zlib' + configuration: 'x64' + nmake_configuration: 'USE_64BIT=1' + - os: windows-2019 + triplet: x86-windows + vcpkgCommitId: 'b361c2eefa3966cb7cec45275aff32e90430aaa6' + vcpkgPackages: 'cairo expat fontconfig freetype gettext glib libpng libxml2 pango pcre zlib' + configuration: 'x86' + nmake_configuration: '' + defaults: + run: + shell: cmd + env: + buildDir: '${{ github.workspace }}/build/' + steps: + - uses: actions/checkout@v1 + with: + submodules: true + + # Restore from cache the previously built ports. If cache-miss, download and build vcpkg (aka "bootstrap vcpkg"). + - name: Restore from cache and install vcpkg + # Download and build vcpkg. + uses: lukka/run-vcpkg@v7 + with: + setupOnly: false + # Location of vcpkg in the Git repository. + vcpkgDirectory: '${{ github.workspace }}/vcpkg' + vcpkgGitCommitId: '${{ matrix.vcpkgCommitId}}' + vcpkgTriplet: ${{ matrix.triplet }} + vcpkgArguments: '${{ matrix.vcpkgPackages }}' + # Ensure the vcpkg artifacts are cached, they are generated in the 'CMAKE_BINARY_DIR/vcpkg_installed' directory. + additionalCachedPaths: ${{ env.buildDir }}/vcpkg_installed + - name: Build ${{ matrix.configuration }} + run: | + call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.configuration }} + nmake -f win32\Makefile_vcpkg.msc ${{ matrix.nmake_configuration }} diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.yml new file mode 100644 index 00000000..8d9af3f6 --- /dev/null +++ b/.github/workflows/release-windows.yml @@ -0,0 +1,69 @@ +--- +name: Release Windows + +# yamllint disable rule:line-length +# yamllint disable-line rule:truthy +on: + push: + tags: + - '*' + workflow_dispatch: + +defaults: + run: + shell: cmd + +jobs: + MSVC: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + # https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md + os: [windows-2019] + triplet: [x64-windows, x86-windows] + include: + - os: windows-2019 + triplet: x64-windows + # https://github.com/microsoft/vcpkg/commit/b361c2eefa3966cb7cec45275aff32e90430aaa6 + vcpkgCommitId: 'b361c2eefa3966cb7cec45275aff32e90430aaa6' + vcpkgPackages: 'cairo expat fontconfig freetype gettext glib libpng libxml2 pango pcre zlib' + configuration: 'x64' + nmake_configuration: 'USE_64BIT=1' + - os: windows-2019 + triplet: x86-windows + vcpkgCommitId: 'b361c2eefa3966cb7cec45275aff32e90430aaa6' + vcpkgPackages: 'cairo expat fontconfig freetype gettext glib libpng libxml2 pango pcre zlib' + configuration: 'x86' + nmake_configuration: '' + env: + buildDir: '${{ github.workspace }}/build/' + steps: + - uses: actions/checkout@v1 + with: + submodules: true + + # Restore from cache the previously built ports. If cache-miss, download and build vcpkg (aka "bootstrap vcpkg"). + - name: Restore from cache and install vcpkg + # Download and build vcpkg. + uses: lukka/run-vcpkg@v7 + with: + setupOnly: false + # Location of vcpkg in the Git repository. + vcpkgDirectory: '${{ github.workspace }}/vcpkg' + vcpkgGitCommitId: '${{ matrix.vcpkgCommitId}}' + vcpkgTriplet: ${{ matrix.triplet }} + vcpkgArguments: '${{ matrix.vcpkgPackages }}' + # Ensure the vcpkg artifacts are cached, they are generated in the 'CMAKE_BINARY_DIR/vcpkg_installed' directory. + additionalCachedPaths: ${{ env.buildDir }}/vcpkg_installed + - name: Build ${{ matrix.configuration }} + run: | + call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.configuration }} + nmake -f win32\Makefile_vcpkg.msc ${{ matrix.nmake_configuration }} + - name: Collect files + run: | + win32\collect_rrdtool_vcpkg_files.bat ${{ matrix.configuration }} + - uses: actions/upload-artifact@v2 + with: + name: deploy-rrdtool-MSVC-${{ matrix.configuration }} + path: win32/nmake_release_${{ matrix.configuration }}_vcpkg/rrdtool-*-${{ matrix.configuration }}_vcpkg/ diff --git a/win32/Makefile_vcpkg.msc b/win32/Makefile_vcpkg.msc index cbd0a170..065420b9 100644 --- a/win32/Makefile_vcpkg.msc +++ b/win32/Makefile_vcpkg.msc @@ -27,6 +27,7 @@ CPPFLAGS = $(CPPFLAGS) /TC /EHsc /O2 /Zi /Fd$(TOP)/win32/vc.pdb \ /I $(ARCH_PATH)\include \ /I $(ARCH_PATH)\include\cairo \ /I $(ARCH_PATH)\include\pango-1.0 \ + /I $(ARCH_PATH)\include\harfbuzz \ /I $(ARCH_PATH)\include\glib-2.0 \ /I $(ARCH_PATH)\lib\glib-2.0\include \ /I $(ARCH_PATH)\include\libxml2 diff --git a/win32/collect_rrdtool_vcpkg_files.bat b/win32/collect_rrdtool_vcpkg_files.bat new file mode 100644 index 00000000..cdac9a88 --- /dev/null +++ b/win32/collect_rrdtool_vcpkg_files.bat @@ -0,0 +1,67 @@ +@ echo off +REM This script collects the built .exe and .dll files required for running RRDtool. +REM It is supposed to be run after an MSVC build using nmake and libraries from vcpkg. +REM Wolfgang Stöggl , 2017-2021. + +REM Run the batch file with command line parameter x64 or x86 +if "%1"=="" ( + echo Command line parameter required: x64 or x86 + echo e.g.: %~nx0 x64 + exit /b +) +echo configuration: %1 + +REM The script is located in the subdirectory win32 +echo %~dp0 +pushd %~dp0 +SET base_dir=.. + +REM Read current version of RRDtool +SET /p version=<%base_dir%\VERSION +echo RRDtool version: %version% + +SET release_dir=%base_dir%\win32\nmake_release_%1_vcpkg\rrdtool-%version%-%1_vcpkg\ +echo release_dir: %release_dir% + +if exist %base_dir%\win32\nmake_release_%1_vcpkg rmdir %base_dir%\win32\nmake_release_%1_vcpkg /s /q +mkdir %release_dir% + +REM use xcopy instead of copy. xcopy creates directories if necessary and outputs the copied file +REM /Y Suppresses prompting to confirm that you want to overwrite an existing destination file. +REM /D xcopy copies all Source files that are newer than existing Destination files + +xcopy /Y /D %base_dir%\win32\librrd-8.dll %release_dir% +xcopy /Y /D %base_dir%\win32\rrdcgi.exe %release_dir% +xcopy /Y /D %base_dir%\win32\rrdtool.exe %release_dir% +xcopy /Y /D %base_dir%\win32\rrdupdate.exe %release_dir% + +REM The following part needs to be checked and maintained after an update to a new vcpkg version +REM Names of dlls can change over time, which has happened in the past +REM e.g. glib-2.dll -> glib-2.0-0.dll, expat.dll -> libexpat.dll +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\brotlicommon.dll %release_dir% +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\brotlidec.dll %release_dir% +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\bz2.dll %release_dir% +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\cairo-2.dll %release_dir% +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\libexpat.dll %release_dir% +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\libffi.dll %release_dir% +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\fontconfig-1.dll %release_dir% +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\freetype.dll %release_dir% +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\fribidi-0.dll %release_dir% +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\gio-2.0-0.dll %release_dir% +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\glib-2.0-0.dll %release_dir% +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\gmodule-2.0-0.dll %release_dir% +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\gobject-2.0-0.dll %release_dir% +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\harfbuzz.dll %release_dir% +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\iconv-2.dll %release_dir% +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\intl-8.dll %release_dir% +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\libpng16.dll %release_dir% +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\libxml2.dll %release_dir% +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\lzma.dll %release_dir% +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\pango-1.0-0.dll %release_dir% +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\pangocairo-1.0-0.dll %release_dir% +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\pangoft2-1.0-0.dll %release_dir% +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\pangowin32-1.0-0.dll %release_dir% +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\pcre.dll %release_dir% +xcopy /Y /D %base_dir%\vcpkg\installed\%1-windows\bin\zlib1.dll %release_dir% + +popd -- 2.47.2