Skip to content

Commit 10a4351

Browse files
authored
Merge 5d95afd into ea7da8e
2 parents ea7da8e + 5d95afd commit 10a4351

12 files changed

Lines changed: 141 additions & 27 deletions

File tree

.circleci/config.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,15 @@ jobs:
171171
./ci_build.sh
172172
173173
- run:
174-
name: "ccache stats after build"
174+
name: "ccache stats after initial build"
175+
command: ccache -s || true
176+
177+
- run:
178+
name: "verify parallel build recipes in subdirs"
179+
command: make -s -j check-parallel-builds || exit
180+
181+
- run:
182+
name: "ccache stats after a few rebuilds"
175183
command: ccache -s || true
176184

177185
# NOTE: Detailed key name allows every scenario to only track its

.github/workflows/codeql.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,14 @@ jobs:
9797
run: |
9898
./autogen.sh
9999
./configure --enable-warnings --enable-Werror --enable-Wcolor --with-all=auto --with-dev --without-docs ${{matrix.compiler}} --with-ssl=${{matrix.NUT_SSL_VARIANTS}} --with-usb=${{matrix.NUT_USB_VARIANTS}}
100-
make -s -j 8
100+
make -s -j 8 || exit
101+
102+
- name: Debug gitlog2version processing
103+
run: bash -x ./tools/gitlog2version.sh || true
104+
105+
- if: matrix.language == 'cpp'
106+
name: NUT CI Build to verify parallel build recipes in subdirs
107+
run: make -s -j check-parallel-builds || exit
101108

102109
# ℹ️ Command-line programs to run using the OS shell.
103110
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

Makefile.am

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,3 +1443,38 @@ check-files-quick: $(CHECK_FILES_QUICK_TARGETS)
14431443

14441444
# Autotools hook: run the quick checks before recursing for defaults:
14451445
check-recursive: check-files-quick
1446+
1447+
# Not pulled in directly so far, can be used by developers to verify that build
1448+
# rules (inlcuding dependencies pulled from other directories) make sense and
1449+
# do not cause conflict by writing into same file names. Something that builds
1450+
# from root directory arrange nicely, but needs careful balancing on a tightrope
1451+
# if developers build pieces of code right in the directory of their interest.
1452+
# It is recommended to have "ccache" (or similar) setup working, to minimize the
1453+
# time cost and workload of compilations involved in these looped build retries.
1454+
# Auto-parallel recipe (if current 'make' implementation supports the "-j N"
1455+
# syntax; the optional MAXPARMAKES may be set in NUT CI farm style builds):
1456+
check-parallel-builds:
1457+
automake -f
1458+
./config.status
1459+
+@MAXPARMAKES_OPT=""; \
1460+
case " $(MAKEFLAGS) $(AM_MAKEFLAGS)" in \
1461+
*"j"*) ;; \
1462+
*) \
1463+
if ! [ "$${MAXPARMAKES-}" -gt 1 ] 2>/dev/null ; then \
1464+
MAXPARMAKES=8 ; \
1465+
fi ; \
1466+
MAXPARMAKES_OPT="-j $${MAXPARMAKES}" ; \
1467+
;; \
1468+
esac ; \
1469+
DIRS=""; \
1470+
for D in `find . -name '*.c' -o -name '*.cpp' | sed 's,/[^/]*\.cp*$$,,' | uniq` ; do \
1471+
[ -e "$$D/Makefile.am" ] && [ -s "$$D/Makefile" ] || continue ; \
1472+
$(MAKE) $(AM_MAKEFLAGS) -k -s $${MAXPARMAKES_OPT} clean || { RES=$$?; echo "$@: FAILED: make clean before going to $$D" >&2; exit $$RES; } ; \
1473+
echo " $@ in $${D}" ; \
1474+
( cd "$$D" && $(MAKE) $(AM_MAKEFLAGS) -k -s $${MAXPARMAKES_OPT} ) || { RES=$$?; echo "$@: FAILED: parallel make in $$D" >&2; \
1475+
echo "To investigate, try: $(MAKE) $(MAKEFLAGS) $(AM_MAKEFLAGS) $${MAXPARMAKES_OPT} clean ; automake -f && ./config.status && clear && (cd $${D}/ && $(MAKE) $(MAKEFLAGS) $(AM_MAKEFLAGS) V=1 $${MAXPARMAKES_OPT} 2>&1 ; echo $?) | tee /tmp/make.log ; grep -E '(\] Error|No rule to)' /tmp/make.log && less /tmp/make.log"; \
1476+
echo "If builds were interrupted before, you may also have to re-initialize the build area completely, e.g.: git clean -fdX ; ./ci_build.sh && $(MAKE) $(MAKEFLAGS) $(AM_MAKEFLAGS) $@" ; \
1477+
exit $$RES; } ; \
1478+
DIRS="$${DIRS} $${D}" ; \
1479+
done ; \
1480+
echo "$@: SUCCESS in all checked directories:$${DIRS}" >&2

NEWS.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,14 @@ https://github.com/networkupstools/nut/milestone/9
311311
services, if `systemctl preset-all` fails (assumed due to a systemd 252
312312
bug). [#3022]
313313

314+
- Added a `make check-parallel-builds` recipe to help troubleshoot recipes
315+
in sub-directories, and improved build-ability of existing NUT sources
316+
starting from scratch there. This is a workflow useful for NUT development
317+
(e.g. to focus only on drivers, or tests, or nut-scanner) but not so much
318+
for end-user packaging where everything builds from the root directory.
319+
[PR #3030, follows up from PR #2825, highlights why issue #2584 better
320+
be solved]
321+
314322

315323
Release notes for NUT 2.8.3 - what's new since 2.8.2
316324
----------------------------------------------------

clients/Makefile.am

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ $(top_builddir)/common/libcommonversion.la \
2424
$(top_builddir)/common/libparseconf.la: dummy
2525
+@cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F)
2626

27+
# Builds from root dir arrange stuff decently. Make sure parallel builds
28+
# started from scratch right in this dir get dependencies in proper order
29+
# (sub-makes are independent as far as trying to write into same files):
30+
$(top_builddir)/common/libcommon.la: $(top_builddir)/common/libparseconf.la
31+
$(top_builddir)/common/libcommonclient.la: $(top_builddir)/common/libparseconf.la
32+
2733
LDADD_FULL = \
2834
$(top_builddir)/common/libcommon.la \
2935
$(top_builddir)/common/libcommonversion.la \

data/driver.list.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@
670670
"Kanji" "ups" "1" "800 VA" "USB" "nutdrv_atcl_usb"
671671

672672
"Kebo" "ups" "2" "1200D/D Series" "" "blazer_ser"
673-
"Kebo" "ups" "2" "UPS-1000D (UPS-1000VA)" "USB" "blazer_usb" # https://github.com/networkupstools/nut/issues/981
673+
"Kebo" "ups" "2" "UPS-1000D (UPS-1000VA)" "USB" "blazer_usb langid_fix=0x4095 subdriver=krauler" # https://github.com/networkupstools/nut/issues/981
674674
"Kebo" "ups" "2" "UPS-650VA" "USB" "megatec_usb"
675675

676676
"KOLFF" "ups" "2" "BLACK NOVA 1K/2K/3K/6K/10K/20K TOWER" "USB" "blazer_usb"
@@ -1425,6 +1425,8 @@
14251425
"Tecnoware" "ups" "2" "UPS ERA LCD 0.65" "USB" "blazer_usb langid_fix=0x409"
14261426
"Tecnoware" "ups" "2" "UPS ERA PLUS 1100" "USB" "blazer_usb" # https://www.tecnoware.com/Prodotti/FGCERAPL1100/ups-era-plus-1100.aspx https://github.com/networkupstools/nut/issues/747
14271427

1428+
"Tescom" "ups" "2" "LEO Plus LCD 1500A" "USB" "blazer_usb langid_fix=0x4095 subdriver=krauler" # https://github.com/networkupstools/nut/issues/981
1429+
14281430
"Texas Instruments" "ups" "5" "INA219" "hwmon" "hwmon_ina219"
14291431

14301432
"Tripp Lite" "ups" "1" "(various)" "Lan 2.2 interface - black 73-0844 cable" "genericups upstype=5"

drivers/Makefile.am

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ $(top_builddir)/common/libparseconf.la \
1616
$(top_builddir)/clients/libupsclient.la: dummy
1717
+@cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F)
1818

19+
# Builds from root dir arrange stuff decently. Make sure parallel builds
20+
# started from scratch right in this dir get dependencies in proper order
21+
# (sub-makes are independent as far as trying to write into same files):
22+
$(top_builddir)/common/libcommon.la: $(top_builddir)/common/libparseconf.la
23+
# Internally (clients/Makefile.am) libupsclient.la requires libcommonclient.la
24+
# and that in turn libparseconf.la:
25+
$(top_builddir)/clients/libupsclient.la: $(top_builddir)/common/libparseconf.la
26+
1927
# by default, link programs in this directory with libcommon.la
2028
# (libtool version of the static lib, in order to access LTLIBOBJS)
2129
#FIXME: SERLIBS is only useful for LDADD_DRIVERS_SERIAL not for LDADD_COMMON
@@ -459,11 +467,11 @@ libdummy_upsdrvquery_la_LDFLAGS = -no-undefined -static
459467
EXTRA_LTLIBRARIES += libdummy_mockdrv.la
460468
libdummy_mockdrv_la_SOURCES = main.c dstate.c
461469
libdummy_mockdrv_la_CFLAGS = $(AM_CFLAGS) -DDRIVERS_MAIN_WITHOUT_MAIN=1
462-
libdummy_mockdrv_la_LDFLAGS = \
463-
-static \
470+
libdummy_mockdrv_la_LIBADD = \
464471
$(top_builddir)/common/libcommon.la \
465472
$(top_builddir)/common/libcommonversion.la \
466473
$(top_builddir)/common/libparseconf.la
474+
libdummy_mockdrv_la_LDFLAGS = -static
467475

468476
# Also define a library with serial-port UPS routines needed for nut-scanner
469477
noinst_LTLIBRARIES = libserial-nutscan.la

drivers/snmp-ups.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@
4747
#include "netvision-mib.h"
4848
#include "eaton-pdu-genesis2-mib.h"
4949
#include "eaton-pdu-marlin-mib.h"
50+
#include "eaton-pdu-nlogic-mib.h"
5051
#include "eaton-pdu-pulizzi-mib.h"
5152
#include "eaton-pdu-revelation-mib.h"
53+
#include "eaton-ups-pwnm2-mib.h"
54+
#include "eaton-ups-pxg-mib.h"
5255
#include "raritan-pdu-mib.h"
5356
#include "raritan-px2-mib.h"
5457
#include "baytech-mib.h"
@@ -69,9 +72,6 @@
6972
#include "emerson-avocent-pdu-mib.h"
7073
#include "hpe-pdu-mib.h"
7174
#include "hpe-pdu3-cis-mib.h"
72-
#include "eaton-pdu-nlogic-mib.h"
73-
#include "eaton-ups-pwnm2-mib.h"
74-
#include "eaton-ups-pxg-mib.h"
7575

7676
/* Address API change */
7777
#if ( ! NUT_HAVE_LIBNETSNMP_usmAESPrivProtocol ) && ( ! defined usmAESPrivProtocol )

server/Makefile.am

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ $(top_builddir)/common/libcommonversion.la \
1515
$(top_builddir)/common/libparseconf.la: dummy
1616
+@cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F)
1717

18+
# Builds from root dir arrange stuff decently. Make sure parallel builds
19+
# started from scratch right in this dir get dependencies in proper order
20+
# (sub-makes are independent as far as trying to write into same files):
21+
$(top_builddir)/common/libcommon.la: $(top_builddir)/common/libparseconf.la
22+
1823
# Avoid per-target CFLAGS, because this will prevent re-use of object
1924
# files. In any case, CFLAGS are only -I options, so there is no harm,
2025
# but only add them if we really use the target.

tests/Makefile.am

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,28 @@ check_SCRIPTS =
3434
check-NIT check-NIT-devel:
3535
+cd "$(builddir)/NIT" && $(MAKE) $(AM_MAKEFLAGS) $@
3636

37+
# Make sure out-of-dir dependencies exist (especially when dev-building
38+
# only some parts of NUT; note libnutclient* are for C++ but would not
39+
# be referenced unless that build ability is detected and enabled):
40+
$(top_builddir)/drivers/libdummy_mockdrv.la \
41+
$(top_builddir)/common/libnutconf.la \
42+
$(top_builddir)/common/libcommonclient.la \
43+
$(top_builddir)/common/libcommon.la \
44+
$(top_builddir)/common/libparseconf.la \
45+
$(top_builddir)/clients/libnutclient.la \
46+
$(top_builddir)/clients/libnutclientstub.la: dummy
47+
+@cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F)
48+
49+
# Builds from root dir arrange stuff decently. Make sure parallel builds
50+
# started from scratch right in this dir get dependencies in proper order
51+
# (sub-makes are independent as far as trying to write into same files):
52+
$(top_builddir)/common/libcommon.la $(top_builddir)/common/libcommonclient.la: $(top_builddir)/common/libparseconf.la
53+
$(top_builddir)/common/libnutconf.la: $(top_builddir)/common/libcommonclient.la
54+
$(top_builddir)/drivers/libdummy_mockdrv.la: $(top_builddir)/common/libcommon.la
55+
#... $(top_builddir)/common/libcommonversion.la $(top_builddir)/common/libparseconf.la
56+
$(top_builddir)/clients/libnutclient.la: $(top_builddir)/common/libcommonclient.la
57+
$(top_builddir)/clients/libnutclientstub.la: $(top_builddir)/clients/libnutclient.la
58+
3759
nutlogtest_SOURCES = nutlogtest.c
3860
nutlogtest_LDADD = $(top_builddir)/common/libcommon.la
3961

@@ -123,13 +145,6 @@ driver_methods_utest_SOURCES = driver_methods_utest.c
123145
driver_methods_utest_LDADD = $(top_builddir)/drivers/libdummy_mockdrv.la
124146
driver_methods_utest_CFLAGS = $(AM_CFLAGS) -I$(top_srcdir)/tests -DDRIVERS_MAIN_WITHOUT_MAIN=1
125147

126-
# Make sure out-of-dir dependencies exist (especially when dev-building parts):
127-
$(top_builddir)/drivers/libdummy_mockdrv.la \
128-
$(top_builddir)/common/libnutconf.la \
129-
$(top_builddir)/common/libcommonclient.la \
130-
$(top_builddir)/common/libcommon.la: dummy
131-
+@cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F)
132-
133148
### Optional tests which can not be built everywhere
134149
# List of src files for CppUnit tests
135150
CPPUNITTESTSRC = example.cpp nutclienttest.cpp
@@ -173,11 +188,6 @@ cppnit_LDADD = $(top_builddir)/clients/libnutclientstub.la
173188
cppnit_LDADD += $(top_builddir)/clients/libnutclient.la
174189
cppnit_SOURCES = $(CPPCLIENTTESTSRC) $(CPPUNITTESTERSRC)
175190

176-
# Make sure out-of-dir C++ dependencies exist (especially when dev-building
177-
# only some parts of NUT):
178-
$(top_builddir)/clients/libnutclient.la \
179-
$(top_builddir)/clients/libnutclientstub.la: dummy
180-
+@cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F)
181191

182192
else !HAVE_CPPUNIT
183193
# Just redistribute test source into tarball if not building tests

0 commit comments

Comments
 (0)