Skip to content

Commit 48eea4d

Browse files
authored
Merge 0e73863 into a456b00
2 parents a456b00 + 0e73863 commit 48eea4d

File tree

6 files changed

+199
-18
lines changed

6 files changed

+199
-18
lines changed

.circleci/config.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ jobs:
5353
#type: string
5454
#default: "/opt/homebrew" # since July 2024 CircleCI only serves Apple Silicon instances
5555
#default: "/usr/local" # was when CircleCI builders had x86
56+
DO_CLEAN_AUTOCONF_CACHE:
57+
type: string
58+
default: "no"
59+
DO_USE_AUTOCONF_CACHE:
60+
type: string
61+
default: "yes"
5662

5763
environment:
5864
CC: << parameters.CC >>
@@ -64,6 +70,8 @@ jobs:
6470
CI_BUILDDIR: << parameters.CI_BUILDDIR >>
6571
BREW_MORE: << parameters.BREW_MORE >>
6672
#HOMEBREW_PREFIX: << parameters.HOMEBREW_PREFIX >>
73+
DO_CLEAN_AUTOCONF_CACHE: << parameters.DO_CLEAN_AUTOCONF_CACHE >>
74+
DO_USE_AUTOCONF_CACHE: << parameters.DO_USE_AUTOCONF_CACHE >>
6775

6876
# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
6977
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
@@ -126,6 +134,7 @@ jobs:
126134
keys:
127135
- ccache-{{ .Branch }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}
128136
- ccache-master-{{ arch }}-{{ .Environment.CIRCLE_JOB }}
137+
- config-cache-{{ .Branch }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}
129138

130139
# Help SEMVER look right (optionally)
131140
- run:
@@ -194,10 +203,17 @@ jobs:
194203
# be beneficial to instead share the cache between jobs; more so
195204
# while we are on free CircleCI tier and run them sequentially.
196205
- save_cache:
206+
name: Save .ccache for later runs
197207
paths:
198208
- ~/.ccache
199209
key: ccache-{{ .Branch }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}
200210

211+
- save_cache:
212+
name: Save config.cache for later runs
213+
paths:
214+
- config.cache
215+
key: config-cache-{{ .Branch }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}
216+
201217
- store_artifacts:
202218
path: config.log
203219

NEWS.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ https://github.com/networkupstools/nut/milestone/12
150150
syntax is not supported everywhere (or the `!` operator generally).
151151
[#3099, #1660]
152152

153+
- Introduced `ci_build.sh` settings and respective CI workflow settings
154+
to optionally re-use a `config.cache` file from older runs. [#3108]
155+
153156

154157
Release notes for NUT 2.8.4 - what's new since 2.8.3
155158
----------------------------------------------------

appveyor.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ environment:
2727
APPVEYOR_SAVE_CACHE_ON_ERROR: true
2828
APPVEYOR_CACHE_ENTRY_ZIP_ARGS: -t7z -m0=lzma -mx=6
2929
CCACHE_DIR: /home/appveyor/.ccache
30+
DO_CLEAN_AUTOCONF_CACHE: no
31+
DO_USE_AUTOCONF_CACHE: yes
3032

3133
# https://github.com/networkupstools/nut/blob/Windows-v2.8.0-1/docs/config-prereqs.txt#L951
3234
# or look for the chapter in nearby lines in later (current) revisions.
@@ -163,6 +165,7 @@ artifacts:
163165
# Example optional cache (depends on file change):
164166
# - C:\msys64 -> appveyor.yml
165167
cache:
168+
- C:\projects\nut\config.cache
166169
- C:\msys64\home\appveyor\nut-win-deps
167170
- C:\msys64\home\appveyor\.ccache
168171
- C:\msys64\home\appveyor\ccache # likely missing, no problem - but the name is reported in ccache status

ci_build.sh

Lines changed: 165 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ case "$BUILD_TYPE" in
5555
echo "SKIPPING BUILD_TYPE=fightwarn-clang: compiler not found" >&2
5656
fi
5757
if $TRIED_BUILD ; then true
58-
else
58+
else
5959
echo "FAILED to run: no default-named compilers were found" >&2
6060
exit 1
6161
fi
@@ -1151,6 +1151,16 @@ configure_nut() {
11511151
echo "=== CONFIGURING NUT: $CONFIGURE_SCRIPT ${CONFIG_OPTS_STR}"
11521152
echo "=== CC='$CC' CXX='$CXX' CPP='$CPP'"
11531153
[ -z "${CI_SHELL_IS_FLAKY-}" ] || echo "=== CI_SHELL_IS_FLAKY='$CI_SHELL_IS_FLAKY'"
1154+
if [ x"${DO_USE_AUTOCONF_CACHE}" = xyes ] && [ -s config.cache ]; then
1155+
echo "$0: using existing config.cache" >&2
1156+
else
1157+
if [ x"${DO_USE_AUTOCONF_CACHE}" = xyes ]; then
1158+
echo "$0: NOT using config.cache because it did not exist" >&2
1159+
else if [ -s config.cache ]; then
1160+
echo "$0: NOT using existing config.cache because DO_USE_AUTOCONF_CACHE=$DO_USE_AUTOCONF_CACHE" >&2
1161+
fi; fi
1162+
fi
1163+
11541164
$CI_TIME $CONFIGURE_SCRIPT "${CONFIG_OPTS[@]}" \
11551165
&& echo "$0: configure phase complete (0)" >&2 \
11561166
&& return 0 \
@@ -1283,6 +1293,9 @@ check_gitignore() {
12831293
[ -n "${FILE_GLOB-}" ] || FILE_GLOB="'*'"
12841294
# Always filter these names away:
12851295
FILE_GLOB_EXCLUDE="':!.ci*.log*' ':!VERSION_DEFAULT' ':!VERSION_FORCED*'"
1296+
if [ x"${DO_CLEAN_AUTOCONF_CACHE}" = xno ] ; then
1297+
FILE_GLOB_EXCLUDE="$FILE_GLOB_EXCLUDE ':!config.cache*'"
1298+
fi
12861299
[ -n "${GIT_ARGS-}" ] || GIT_ARGS='' # e.g. GIT_ARGS="--ignored"
12871300
# Display contents of the diff?
12881301
# (Helps copy-paste from CI logs to source to amend quickly)
@@ -1349,12 +1362,20 @@ consider_cleanup_shortcut() {
13491362
fi
13501363
fi
13511364
1365+
if [ x"${DO_CLEAN_AUTOCONF_CACHE}" = xyes ]; then
1366+
rm -f config.cache*
1367+
fi
1368+
13521369
# When iterating configure.ac or m4 sources, we can end up with an
13531370
# existing but useless script file - nuke it and restart from scratch!
13541371
if [ -s "${CI_BUILDDIR}"/configure ] ; then
13551372
# FIXME: Consider CONFIG_SHELL, maybe from script shebang,
13561373
# here - like autogen.sh does
1357-
if sh -n "${CI_BUILDDIR}"/configure 2>/dev/null ; then
1374+
USE_CONFIG_SHELL=sh
1375+
if [ -n "${CONFIG_SHELL-}" ]; then
1376+
USE_CONFIG_SHELL="${CONFIG_SHELL}"
1377+
fi
1378+
if ${USE_CONFIG_SHELL} -n "${CI_BUILDDIR}"/configure 2>/dev/null ; then
13581379
true
13591380
else
13601381
echo "=== Starting initial clean-up (from old build products): TAKING SHORTCUT because current configure script syntax is broken"
@@ -1399,15 +1420,30 @@ optional_maintainer_clean_check() {
13991420
else
14001421
[ -z "$CI_TIME" ] || echo "`date`: Starting maintainer-clean check of currently tested project..."
14011422
1423+
rm -f config.cache.tmp || true
1424+
if [ x"${DO_CLEAN_AUTOCONF_CACHE}" = xno ] && [ -s config.cache ]; then
1425+
echo "=== Keeping old config.cache as asked by BUILD_TYPE default or caller request"
1426+
cp -f config.cache config.cache.tmp
1427+
fi
1428+
14021429
# Note: currently Makefile.am has just a dummy "distcleancheck" rule
1430+
MAKE_RES=0
14031431
case "$MAKE_FLAGS $DISTCHECK_FLAGS $PARMAKE_FLAGS $MAKE_FLAGS_CLEAN" in
14041432
*V=0*)
1405-
$CI_TIME $MAKE DISTCHECK_FLAGS="$DISTCHECK_FLAGS" $PARMAKE_FLAGS $MAKE_FLAGS_CLEAN maintainer-clean > /dev/null || return
1433+
$CI_TIME $MAKE DISTCHECK_FLAGS="$DISTCHECK_FLAGS" $PARMAKE_FLAGS $MAKE_FLAGS_CLEAN maintainer-clean > /dev/null || MAKE_RES=$?
14061434
;;
14071435
*)
1408-
$CI_TIME $MAKE DISTCHECK_FLAGS="$DISTCHECK_FLAGS" $PARMAKE_FLAGS $MAKE_FLAGS_CLEAN maintainer-clean || return
1436+
$CI_TIME $MAKE DISTCHECK_FLAGS="$DISTCHECK_FLAGS" $PARMAKE_FLAGS $MAKE_FLAGS_CLEAN maintainer-clean || MAKE_RES=$?
14091437
esac
14101438
1439+
if [ x"${DO_CLEAN_AUTOCONF_CACHE}" = xno ] && [ -s config.cache.tmp ]; then
1440+
mv -f config.cache.tmp config.cache || true
1441+
fi
1442+
1443+
if [ x"$MAKE_RES" != x0 ]; then
1444+
return $MAKE_RES
1445+
fi
1446+
14111447
GIT_ARGS="--ignored" check_gitignore "maintainer-clean" || return
14121448
fi
14131449
@@ -1434,8 +1470,23 @@ optional_dist_clean_check() {
14341470
else
14351471
[ -z "$CI_TIME" ] || echo "`date`: Starting dist-clean check of currently tested project..."
14361472
1473+
rm -f config.cache.tmp || true
1474+
if [ x"${DO_CLEAN_AUTOCONF_CACHE}" = xno ] && [ -s config.cache ]; then
1475+
echo "=== Keeping old config.cache as asked by BUILD_TYPE default or caller request"
1476+
cp -f config.cache config.cache.tmp
1477+
fi
1478+
14371479
# Note: currently Makefile.am has just a dummy "distcleancheck" rule
1438-
$CI_TIME $MAKE DISTCHECK_FLAGS="$DISTCHECK_FLAGS" $PARMAKE_FLAGS $MAKE_FLAGS_CLEAN distclean || return
1480+
MAKE_RES=0
1481+
$CI_TIME $MAKE DISTCHECK_FLAGS="$DISTCHECK_FLAGS" $PARMAKE_FLAGS $MAKE_FLAGS_CLEAN distclean || MAKE_RES=$?
1482+
1483+
if [ x"${DO_CLEAN_AUTOCONF_CACHE}" = xno ] && [ -s config.cache.tmp ]; then
1484+
mv -f config.cache.tmp config.cache || true
1485+
fi
1486+
1487+
if [ x"$MAKE_RES" != x0 ]; then
1488+
return $MAKE_RES
1489+
fi
14391490
14401491
check_gitignore "distclean" || return
14411492
fi
@@ -1508,13 +1559,70 @@ if [ -z "$BUILD_TYPE" ] ; then
15081559
fi
15091560
;;
15101561
1511-
*) echo "WARNING: Command-line argument '$1' wsa not recognized as a BUILD_TYPE alias" >&2 ;;
1562+
*) echo "WARNING: Command-line argument '$1' was not recognized as a BUILD_TYPE alias" >&2 ;;
15121563
esac
15131564
fi
15141565
15151566
# Default follows autotools:
15161567
[ -n "${DISTCHECK_TGT-}" ] || DISTCHECK_TGT="distcheck"
15171568
1569+
# https://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Cache-Files.html
1570+
# By default, we clean up the config.cache between jobs (before start,
1571+
# after finish), but do want to use (and retain) it between loop runs
1572+
# of BUILD_TYPE="default-all-errors*".
1573+
# FIXME: Currently disabled for the loops; we want to only cache the
1574+
# common system findings but forget the details we vary (implementations
1575+
# of libusb, ssl...) because this knowledge about "lack" of some methods
1576+
# breaks those very re-runs. The approach can still be used for runs of
1577+
# same configurations from one iteration to another on CI systems though.
1578+
# Note that autotools automatically removes such file name during the
1579+
# "make distclean" and stronger goals, so on our side we can only
1580+
# stash and restore the file around such operations.
1581+
[ -n "$DO_CLEAN_AUTOCONF_CACHE" ] || DO_CLEAN_AUTOCONF_CACHE="auto"
1582+
[ -n "$DO_USE_AUTOCONF_CACHE" ] || DO_USE_AUTOCONF_CACHE="auto"
1583+
# What about after tests (e.g. loops?)
1584+
[ -n "$DO_CLEAN_AUTOCONF_CACHE_BEFORE" ] || DO_CLEAN_AUTOCONF_CACHE_BEFORE="$DO_CLEAN_AUTOCONF_CACHE"
1585+
[ -n "$DO_CLEAN_AUTOCONF_CACHE_FINAL" ] || DO_CLEAN_AUTOCONF_CACHE_FINAL="$DO_CLEAN_AUTOCONF_CACHE"
1586+
1587+
if [ x"${DO_CLEAN_AUTOCONF_CACHE}" = xauto ]; then
1588+
case "$BUILD_TYPE" in
1589+
#default-all-errors*) DO_CLEAN_AUTOCONF_CACHE="no" ;;
1590+
*) DO_CLEAN_AUTOCONF_CACHE="yes" ;;
1591+
esac
1592+
fi
1593+
export DO_CLEAN_AUTOCONF_CACHE
1594+
1595+
if [ x"${DO_USE_AUTOCONF_CACHE}" = xauto ]; then
1596+
case "$BUILD_TYPE" in
1597+
#default-all-errors*) DO_USE_AUTOCONF_CACHE="yes" ;;
1598+
*) DO_USE_AUTOCONF_CACHE="no" ;;
1599+
esac
1600+
fi
1601+
export DO_USE_AUTOCONF_CACHE
1602+
1603+
if [ x"${DO_CLEAN_AUTOCONF_CACHE_BEFORE}" = xauto ]; then
1604+
DO_CLEAN_AUTOCONF_CACHE_BEFORE="yes"
1605+
fi
1606+
if [ x"${DO_CLEAN_AUTOCONF_CACHE_FINAL}" = xauto ]; then
1607+
DO_CLEAN_AUTOCONF_CACHE_FINAL="yes"
1608+
fi
1609+
export DO_CLEAN_AUTOCONF_CACHE_BEFORE
1610+
export DO_CLEAN_AUTOCONF_CACHE_FINAL
1611+
1612+
if [ x"${DO_CLEAN_AUTOCONF_CACHE_BEFORE}" = xyes ]; then
1613+
rm -f config.cache*
1614+
fi
1615+
1616+
cleanup_exit() {
1617+
FINAL_RES=$?
1618+
if [ x"${DO_CLEAN_AUTOCONF_CACHE_FINAL}" = xyes ]; then
1619+
rm -f config.cache*
1620+
fi
1621+
return $FINAL_RES
1622+
}
1623+
1624+
trap 'cleanup_exit' 2 3 15
1625+
15181626
echo "Processing BUILD_TYPE='${BUILD_TYPE}' ..."
15191627
15201628
ensure_CI_CCACHE_SYMLINKDIR_envvar
@@ -1560,6 +1668,10 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-al
15601668
15611669
detect_platform_CANBUILD_LIBGD_CGI
15621670
1671+
if [ x"${DO_USE_AUTOCONF_CACHE}" = xyes ] ; then
1672+
CONFIG_OPTS+=("-C")
1673+
fi
1674+
15631675
# Prepend or use this build's preferred artifacts, if any
15641676
DEFAULT_PKG_CONFIG_PATH="${BUILD_PREFIX}/lib/pkgconfig"
15651677
detect_platform_PKG_CONFIG_PATH_and_FLAGS
@@ -1901,6 +2013,12 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-al
19012013
trap 'echo "!!! If clean-up looped remaking the configure script for maintainer-clean, try to:"; echo " rm -f Makefile configure include/config.h* ; $0 $SCRIPT_ARGS"' 2
19022014
19032015
echo "=== Starting initial clean-up (from old build products)"
2016+
rm -f config.cache.tmp || true
2017+
if [ x"${DO_CLEAN_AUTOCONF_CACHE}" = xno ] && [ -s config.cache ]; then
2018+
echo "=== Keeping old config.cache as asked by BUILD_TYPE default or caller request"
2019+
cp -f config.cache config.cache.tmp
2020+
fi
2021+
19042022
case "$MAKE_FLAGS $MAKE_FLAGS_CLEAN" in
19052023
*V=0*)
19062024
${MAKE} maintainer-clean $MAKE_FLAGS_CLEAN -k > /dev/null \
@@ -1913,7 +2031,12 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-al
19132031
|| true
19142032
echo "=== Finished initial clean-up"
19152033
2034+
if [ x"${DO_CLEAN_AUTOCONF_CACHE}" = xno ] && [ -s config.cache.tmp ]; then
2035+
mv -f config.cache.tmp config.cache || true
2036+
fi
2037+
19162038
trap - 2
2039+
trap 'cleanup_exit' 2 3 15
19172040
fi
19182041
19192042
# Just prepare `configure` script; we run it at different points
@@ -2498,8 +2621,19 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-al
24982621
echo "=== Completed sandbox cleanup-check after TESTCOMBO=${TESTCOMBO}, $BUILDSTODO build variants remaining"
24992622
else
25002623
if [ "$BUILDSTODO" -gt 0 ] && [ "${DO_CLEAN_CHECK-}" != no ]; then
2624+
rm -f config.cache.tmp || true
2625+
if [ x"${DO_CLEAN_AUTOCONF_CACHE}" = xno ] && [ -s config.cache ]; then
2626+
echo "=== Keeping old config.cache as asked by BUILD_TYPE default or caller request"
2627+
cp -f config.cache config.cache.tmp
2628+
fi
2629+
25012630
$MAKE distclean $MAKE_FLAGS_CLEAN -k \
25022631
|| echo "WARNING: 'make distclean' FAILED: $? ... proceeding" >&2
2632+
2633+
if [ x"${DO_CLEAN_AUTOCONF_CACHE}" = xno ] && [ -s config.cache.tmp ]; then
2634+
mv -f config.cache.tmp config.cache || true
2635+
fi
2636+
25032637
echo "=== Completed sandbox cleanup after TESTCOMBO=${TESTCOMBO}, $BUILDSTODO build variants remaining"
25042638
else
25052639
echo "=== SKIPPED sandbox cleanup because DO_CLEAN_CHECK=$DO_CLEAN_CHECK and $BUILDSTODO build variants remaining"
@@ -2640,7 +2774,19 @@ bindings)
26402774
# Help developers debug:
26412775
# Let initial clean-up be at default verbosity
26422776
echo "=== Starting initial clean-up (from old build products)"
2777+
2778+
rm -f config.cache.tmp || true
2779+
if [ x"${DO_CLEAN_AUTOCONF_CACHE}" = xno ] && [ -s config.cache ]; then
2780+
echo "=== Keeping old config.cache as asked by BUILD_TYPE default or caller request"
2781+
cp -f config.cache config.cache.tmp
2782+
fi
2783+
26432784
${MAKE} realclean -k || true
2785+
2786+
if [ x"${DO_CLEAN_AUTOCONF_CACHE}" = xno ] && [ -s config.cache.tmp ]; then
2787+
mv -f config.cache.tmp config.cache || true
2788+
fi
2789+
26442790
echo "=== Finished initial clean-up"
26452791
fi
26462792
@@ -2661,6 +2807,10 @@ bindings)
26612807
--disable-force-nut-version-header \
26622808
--enable-check-NIT --enable-maintainer-mode)
26632809
2810+
if [ x"${DO_USE_AUTOCONF_CACHE}" = xyes ] ; then
2811+
CONFIG_OPTS+=("-C")
2812+
fi
2813+
26642814
case x"${BUILD_TYPE}" in
26652815
xdoc*) CONFIG_OPTS+=("--with-${BUILD_TYPE}") ;;
26662816
*) CONFIG_OPTS+=("--with-doc=skip") ;;
@@ -2754,16 +2904,16 @@ bindings)
27542904
esac
27552905
27562906
if [ "${_EXPORT_FLAGS}" = true ] ; then
2757-
[ -z "${CFLAGS}" ] || export CFLAGS
2758-
[ -z "${CXXFLAGS}" ] || export CXXFLAGS
2759-
[ -z "${CPPFLAGS}" ] || export CPPFLAGS
2760-
[ -z "${LDFLAGS}" ] || export LDFLAGS
2907+
[ -z "${CFLAGS}" ] || export CFLAGS
2908+
[ -z "${CXXFLAGS}" ] || export CXXFLAGS
2909+
[ -z "${CPPFLAGS}" ] || export CPPFLAGS
2910+
[ -z "${LDFLAGS}" ] || export LDFLAGS
27612911
else
2762-
# NOTE: Passing via CONFIG_OPTS also fails
2763-
[ -z "${CFLAGS}" ] || echo "WARNING: SKIP: On '${CI_OS_NAME}' with ccache used, can not export CFLAGS='${CFLAGS}'" >&2
2764-
[ -z "${CXXFLAGS}" ] || echo "WARNING: SKIP: On '${CI_OS_NAME}' with ccache used, can not export CXXFLAGS='${CXXFLAGS}'" >&2
2765-
[ -z "${CPPFLAGS}" ] || echo "WARNING: SKIP: On '${CI_OS_NAME}' with ccache used, can not export CPPFLAGS='${CPPFLAGS}'" >&2
2766-
[ -z "${LDFLAGS}" ] || echo "WARNING: SKIP: On '${CI_OS_NAME}' with ccache used, can not export LDFLAGS='${LDFLAGS}'" >&2
2912+
# NOTE: Passing via CONFIG_OPTS also fails
2913+
[ -z "${CFLAGS}" ] || echo "WARNING: SKIP: On '${CI_OS_NAME}' with ccache used, can not export CFLAGS='${CFLAGS}'" >&2
2914+
[ -z "${CXXFLAGS}" ] || echo "WARNING: SKIP: On '${CI_OS_NAME}' with ccache used, can not export CXXFLAGS='${CXXFLAGS}'" >&2
2915+
[ -z "${CPPFLAGS}" ] || echo "WARNING: SKIP: On '${CI_OS_NAME}' with ccache used, can not export CPPFLAGS='${CPPFLAGS}'" >&2
2916+
[ -z "${LDFLAGS}" ] || echo "WARNING: SKIP: On '${CI_OS_NAME}' with ccache used, can not export LDFLAGS='${LDFLAGS}'" >&2
27672917
fi
27682918
27692919
PATH="`echo "${PATH}" | normalize_path`"

0 commit comments

Comments
 (0)