2 # Network UPS Tools: AppVeyor CI build recipe: NUT for Windows with MSYS2/MinGW x64
4 # https://www.msys2.org/docs/ci/
5 # https://www.appveyor.com/docs/appveyor-yml/
6 # https://www.appveyor.com/docs/build-configuration/
7 # https://www.appveyor.com/docs/windows-images-software/
9 version: 2.8.2.{build}-{branch}
12 image: Visual Studio 2022
23 # https://www.appveyor.com/docs/build-cache/
25 APPVEYOR_SAVE_CACHE_ON_ERROR: true
26 APPVEYOR_CACHE_ENTRY_ZIP_ARGS: -t7z -m0=lzma -mx=6
27 CCACHE_DIR: /home/appveyor/.ccache
29 # https://github.com/networkupstools/nut/blob/Windows-v2.8.0-1/docs/config-prereqs.txt#L951
30 # or look for the chapter in nearby lines in later (current) revisions.
31 # Note: not using `time` in scripts currently - they did upset
32 # AppVeyor console log scanner with a /^sys.*/ match (apparently)
35 REM Do not give pacman cause for complaints:
36 C:\msys64\usr\bin\bash -lc "mkdir -p /var/cache/pacman/pkg; ls -la /"
37 REM FIXME: Since Jan 2025, normal update below fails with the message:
38 REM installing mingw-w64-i686-gdb (16.1-1) breaks dependency
39 REM 'mingw-w64-i686-gdb=15.2' required by mingw-w64-i686-gdb-multiarch
40 REM Currently we sweep it away by removing the conflicting package:
41 C:\msys64\usr\bin\bash -lc "date -u; pacman --noconfirm -R mingw-w64-i686-gdb-multiarch || true"
43 REM Core update (in case any core packages are outdated):
44 C:\msys64\usr\bin\bash -lc "date -u; pacman --noconfirm -Syuu"
46 REM Normal update (same command again):
47 C:\msys64\usr\bin\bash -lc "date -u; pacman --noconfirm -Syuu"
49 REM Prerequisites for NUT per https://github.com/networkupstools/nut/blob/master/docs/config-prereqs.txt :
50 C:\msys64\usr\bin\bash -lc "date -u; pacman --noconfirm -S --needed base-devel mingw-w64-x86_64-toolchain autoconf-wrapper automake-wrapper libtool mingw-w64-x86_64-libltdl gcc ccache mingw-w64-x86_64-ccache git aspell aspell-en python mingw-w64-x86_64-python-pygments mingw-w64-x86_64-winpthreads-git mingw-w64-x86_64-libusb mingw-w64-x86_64-libusb-compat-git mingw-w64-x86_64-neon libneon-devel mingw-w64-x86_64-libgd mingw-w64-x86_64-cppunit"
51 REM SKIP mingw-w64-x86_64-libmodbus-git : we custom-build one with USB support
53 REM Assorted stats after package processing:
54 C:\msys64\usr\bin\bash -lc "date -u; ls -la / ; du -ksx / ; date -u; du -ks /var/cache/pacman/pkg; date -u"
55 REM Preserve the current working directory:
56 set CHERE_INVOKING=yes
57 REM Start a 64 bit Mingw environment:
59 C:\msys64\usr\bin\bash -lc 'PATH="/mingw64/bin:$PATH" ; export PATH ; pwd ; ccache -sv || echo "SKIP: Could not query ccache stats" ; ccache -o sloppiness=file_macro || true ; ccache -o compression=true || true '
64 REM Ensure we have a net-snmp to build against
65 REM Adapted from scripts/Windows/README.adoc document.
66 REM Here we hope to build it once, then use the
67 REM stashed version across Appveyor rebuilds.
68 REM Preserve the current working directory:
69 set CHERE_INVOKING=yes
70 REM Start a 64 bit Mingw environment:
72 C:\msys64\usr\bin\bash -lc 'date -u; export MSYS2_PATH ; PATH="/mingw64/lib/ccache/bin:/mingw64/bin:$PATH" bash ./scripts/Windows/build-mingw-prereqs.sh'
77 REM Preserve the current working directory:
78 set CHERE_INVOKING=yes
79 REM Start a 64 bit Mingw environment:
81 C:\msys64\usr\bin\bash -lc 'date -u; PATH="/mingw64/bin:$PATH" CI_SKIP_CHECK=true CANBUILD_WITH_LIBMODBUS_USB=yes ./ci_build.sh'
86 REM Preserve the current working directory:
87 set CHERE_INVOKING=yes
88 REM Start a 64 bit Mingw environment:
90 C:\msys64\usr\bin\bash -lc 'date -u; PATH="/mingw64/bin:$PATH" ; export PATH ; ccache -sv || ccache -s || echo "SKIP: Could not query ccache stats"'
95 REM Preserve the current working directory:
96 set CHERE_INVOKING=yes
97 REM Start a 64 bit Mingw environment:
99 REM Start Mingw-based integration and unit checks:
100 C:\msys64\usr\bin\bash -lc 'date -u; NUT_STATEPATH="C:\\Users\\appveyor\\AppData\\Local\\Temp\\nut-test"; mkdir -p "${NUT_STATEPATH}"; export NUT_STATEPATH; PATH="/mingw64/lib/ccache/bin:/mingw64/bin:$PATH" make -s check || bash -lc "for F in tests/*.log tests/*.trs ; do echo \"===---=== $F :\"; cat \"$F\"; done; exit 1;" '
101 REM Start a Mingw-based documentation spellcheck (note that "make check" above could cover some documents in path of artifact delivery, but maybe not all that we have):
102 C:\msys64\usr\bin\bash -lc 'date -u; PATH="/mingw64/lib/ccache/bin:/mingw64/bin:$PATH" make -s -j 8 spellcheck'
107 REM Preserve the current working directory:
108 set CHERE_INVOKING=yes
109 REM Start a 64 bit Mingw environment:
111 REM Oh the joys of shell scripting with strings passed through CMD:
112 REM Note: currently Python installation path with MSYS is buggy [#1584]
113 C:\msys64\usr\bin\bash -lc 'date -u; set -e ; if ! rm -rf ".inst" ; then echo "WARNING: Failed to clean away .inst" ; fi ; PATH="/mingw64/lib/ccache/bin:/mingw64/bin:$PATH" make -s install-win-bundle DESTDIR="`pwd`/.inst/NUT-for-Windows-x86_64-SNAPSHOT-%APPVEYOR_BUILD_VERSION%" ; ln -fs "NUT-for-Windows-x86_64-SNAPSHOT-%APPVEYOR_BUILD_VERSION%" ./.inst/NUT-for-Windows-x86_64-SNAPSHOT ; ( cd .inst/NUT-for-Windows-x86_64-SNAPSHOT ; find . -ls ; ) ; date -u'
115 7z a ../NUT-for-Windows-x86_64-SNAPSHOT-%APPVEYOR_BUILD_VERSION%.7z NUT*
117 REM Preserve the current working directory:
118 set CHERE_INVOKING=yes
119 REM Start a 64 bit Mingw environment:
121 C:\msys64\usr\bin\bash -lc 'date -u; PATH="/mingw64/bin:$PATH" ; export PATH ; ccache -sv || ccache -s || echo "SKIP: Could not query ccache stats"'
122 C:\msys64\usr\bin\bash -lc 'date -u; PATH="/mingw64/bin:$PATH" ; export PATH ; ccache -x || echo "SKIP: Could not query ccache compression stats"'
126 - path: 'NUT-for-Windows*.7z'
127 name: Bundle of binary files and FOSS dependencies of NUT for Windows
130 name: config.log of recent build of NUT for Windows
132 - path: config.nut_report_feature.log
133 name: config.nut_report_feature.log of recent build of NUT for Windows
135 # Example optional cache (depends on file change):
136 # - C:\msys64 -> appveyor.yml
138 - C:\msys64\home\appveyor\.ccache
139 - C:\msys64\home\appveyor\ccache # likely missing, no problem - but the name is reported in ccache status
140 - C:\Users\appveyor\AppData\Local\ccache # may be default in newer versions
141 - C:\Users\appveyor\AppData\Local\.ccache # may be missing, but for completeness like above
142 - C:\msys64\var\cache\pacman\pkg
143 - C:\msys64\home\appveyor\nut-win-deps
145 # Below we tried to stash binaries of MSYS2 environment
146 # so VM deployment is faster on subsequent builds
147 # (update/install "from scratch" costs about 3 min),
148 # but unstashing the archive takes comparable time
149 # and often leads to conflicts in pacman book-keeping,
150 # while creating/updating the archive costs ~10 min.
151 #- C:\msys64\var\lib\pacman
158 #- C:\msys64\clangarm64
163 #- C:\msys64\installerResources