mirror of
https://github.com/Cacti/spine.git
synced 2026-10-23 03:27:10 +09:00
build: establish src/core layout for support modules (#617)
## What - move `keywords.c`/`.h` and `locks.c`/`.h` into `src/core/` - enable Automake `subdir-objects` for collision-safe nested object placement - update the Autotools binary, linked-test, standalone unit-test, and fuzz paths - make both cppcheck entry points share one complete nested-source discovery path - ignore nested Automake and Docker build artifacts - retain existing header include names and the Autotools build The four production source/header files are 100% renames with no content changes. The remaining changes are build and verification plumbing required by the new paths. ## Why Spine production sources currently live in the repository root. This starts the domain layout in a small, reviewable batch instead of repeating #523, where the source move was coupled to an 11k-line CMake/platform rewrite. `keywords` and `locks` were selected because active PRs #597 and #614 do not modify their implementation files; only shared build manifests overlap #597. `subdir-objects` is enabled in this first production move so future modules with the same basename cannot write the same top-level object under parallel builds. Closes #616. ## Verification - `./bootstrap` with no subdirectory-source warnings - `./configure --with-mysql=$(brew --prefix mariadb-connector-c) --with-snmp=$(brew --prefix net-snmp) CPPFLAGS=-I$(brew --prefix openssl@3)/include LDFLAGS=-L$(brew --prefix openssl@3)/lib` - warning-enabled `make -j$(sysctl -n hw.ncpu)`; project sources compile, with Homebrew Net-SNMP header warnings only - `make check` (cmocka unavailable to Autoconf locally; 0 local tests) - `make distcheck`; archive verified to contain all four `src/core` files - cppcheck source discovery verified under macOS Bash 3 and includes all four relocated files - standalone `tests/unit/Makefile` compiles through header resolution with `-I../../src/core` (the local macOS link retains unrelated existing client-library/toolchain issues) - GitHub checks pass, including fuzz, sanitizers, coverage, `distcheck`, gcc/clang, SNMPv3, and Rocky Linux The local macOS fuzz build reaches both relocated files, then fails identically on untouched `util.c` (`INT_MAX`) and Net-SNMP API declarations on both this branch and `develop`. Linux fuzz CI is the authoritative fuzz-build result. --------- Signed-off-by: Thomas Vincent <thomasvincent@gmail.com> Co-authored-by: TheWitness <thewitness@cacti.net>
This commit is contained in:
1 parent
de182d4f07
commit
f989722458
11 files changed
+45
-23
No files matched your search
+10
-10
@@ -23,16 +23,16 @@ configure
|
|||||||
configure~
|
configure~
|
||||||
libtool
|
libtool
|
||||||
stamp-h1
|
stamp-h1
|
||||||
.deps/
|
**/.deps/
|
||||||
.dirstamp
|
**/.dirstamp
|
||||||
.libs/
|
**/.libs/
|
||||||
*.o
|
**/*.o
|
||||||
*.lo
|
**/*.lo
|
||||||
*.la
|
**/*.la
|
||||||
*.gcda
|
**/*.gcda
|
||||||
*.gcno
|
**/*.gcno
|
||||||
*.log
|
**/*.log
|
||||||
*.tar.gz
|
**/*.tar.gz
|
||||||
|
|
||||||
# the built binary itself
|
# the built binary itself
|
||||||
/spine
|
/spine
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
# +-------------------------------------------------------------------------+
|
# +-------------------------------------------------------------------------+
|
||||||
|
|
||||||
.deps
|
.deps
|
||||||
|
.dirstamp
|
||||||
Makefile
|
Makefile
|
||||||
Makefile.in
|
Makefile.in
|
||||||
configure
|
configure
|
||||||
|
|||||||
+9
-9
@@ -22,7 +22,8 @@
|
|||||||
AUTOMAKE_OPTIONS = foreign
|
AUTOMAKE_OPTIONS = foreign
|
||||||
ACLOCAL_AMFLAGS = -I m4
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
|
|
||||||
spine_SOURCES = sql.c spine.c util.c snmp.c locks.c poller.c nft_popen.c php.c ping.c keywords.c error.c
|
spine_SOURCES = sql.c spine.c util.c snmp.c src/core/locks.c poller.c \
|
||||||
|
nft_popen.c php.c ping.c src/core/keywords.c error.c
|
||||||
|
|
||||||
configdir = $(sysconfdir)
|
configdir = $(sysconfdir)
|
||||||
config_DATA = spine.conf.dist
|
config_DATA = spine.conf.dist
|
||||||
@@ -48,8 +49,9 @@ man_MANS = spine.1
|
|||||||
|
|
||||||
# Headers are not referenced by any _SOURCES, so automake will not distribute
|
# Headers are not referenced by any _SOURCES, so automake will not distribute
|
||||||
# them unless they are listed. Without this the release tarball builds nothing.
|
# them unless they are listed. Without this the release tarball builds nothing.
|
||||||
noinst_HEADERS = common.h error.h keywords.h locks.h nft_popen.h php.h \
|
noinst_HEADERS = common.h error.h src/core/keywords.h src/core/locks.h \
|
||||||
ping.h poller.h snmp.h spine.h spine_sem.h sql.h uthash.h util.h
|
nft_popen.h php.h ping.h poller.h snmp.h spine.h spine_sem.h sql.h \
|
||||||
|
uthash.h util.h
|
||||||
|
|
||||||
EXTRA_DIST = spine.1 spine.conf.dist
|
EXTRA_DIST = spine.1 spine.conf.dist
|
||||||
|
|
||||||
@@ -66,12 +68,9 @@ verify: docker-dev
|
|||||||
docker run --rm spine-dev
|
docker run --rm spine-dev
|
||||||
|
|
||||||
cppcheck: docker-dev
|
cppcheck: docker-dev
|
||||||
docker run --rm spine-dev bash -c \
|
docker run --rm -e VERIFY_CPPCHECK_ONLY=1 spine-dev
|
||||||
"cppcheck --enable=all --std=c11 --error-exitcode=1 \
|
|
||||||
--suppress=missingIncludeSystem --suppress=unusedFunction \
|
|
||||||
--suppress=checkersReport --suppress=toomanyconfigs $(spine_SOURCES)"
|
|
||||||
|
|
||||||
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_builddir)
|
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/src/core -I$(top_builddir)
|
||||||
|
|
||||||
check_PROGRAMS =
|
check_PROGRAMS =
|
||||||
|
|
||||||
@@ -98,7 +97,8 @@ tests_unit_test_safety_fixes_LDADD = $(CMOCKA_LIBS)
|
|||||||
# Everything except spine.c is linked as built; tests/fuzz/stubs.c supplies the
|
# Everything except spine.c is linked as built; tests/fuzz/stubs.c supplies the
|
||||||
# globals that spine.c would define.
|
# globals that spine.c would define.
|
||||||
tests_unit_test_linked_SOURCES = tests/unit/test_linked.c tests/fuzz/stubs.c \
|
tests_unit_test_linked_SOURCES = tests/unit/test_linked.c tests/fuzz/stubs.c \
|
||||||
sql.c util.c snmp.c locks.c poller.c nft_popen.c php.c ping.c keywords.c error.c
|
sql.c util.c snmp.c src/core/locks.c poller.c nft_popen.c php.c ping.c \
|
||||||
|
src/core/keywords.c error.c
|
||||||
tests_unit_test_linked_LDADD = $(CMOCKA_LIBS) $(LIBS)
|
tests_unit_test_linked_LDADD = $(CMOCKA_LIBS) $(LIBS)
|
||||||
|
|
||||||
TESTS = $(check_PROGRAMS)
|
TESTS = $(check_PROGRAMS)
|
||||||
+1
-1
@@ -30,7 +30,7 @@ AC_CONFIG_SRCDIR(spine.c)
|
|||||||
AC_PREFIX_DEFAULT(/usr/local/spine)
|
AC_PREFIX_DEFAULT(/usr/local/spine)
|
||||||
AC_LANG(C)
|
AC_LANG(C)
|
||||||
|
|
||||||
AM_INIT_AUTOMAKE([foreign])
|
AM_INIT_AUTOMAKE([foreign subdir-objects])
|
||||||
AM_SILENT_RULES([yes])
|
AM_SILENT_RULES([yes])
|
||||||
AC_CONFIG_HEADERS(config/config.h)
|
AC_CONFIG_HEADERS(config/config.h)
|
||||||
|
|
||||||
|
|||||||
+20
-1
@@ -2,12 +2,31 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
echo "=== cppcheck ==="
|
echo "=== cppcheck ==="
|
||||||
|
source_list=$(mktemp)
|
||||||
|
trap 'rm -f "$source_list"' EXIT
|
||||||
|
find . -maxdepth 1 -type f \( -name '*.c' -o -name '*.h' \) \
|
||||||
|
-print0 > "$source_list"
|
||||||
|
find src -type f \( -name '*.c' -o -name '*.h' \) \
|
||||||
|
-print0 >> "$source_list"
|
||||||
|
source_files=()
|
||||||
|
while IFS= read -r -d '' source_file; do
|
||||||
|
source_files+=("$source_file")
|
||||||
|
done < "$source_list"
|
||||||
|
if (( ${#source_files[@]} == 0 )); then
|
||||||
|
echo "ERROR: no C sources or headers found" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
cppcheck --enable=all --std=c11 --error-exitcode=1 \
|
cppcheck --enable=all --std=c11 --error-exitcode=1 \
|
||||||
|
-I. -Isrc/core \
|
||||||
--suppress=missingIncludeSystem \
|
--suppress=missingIncludeSystem \
|
||||||
--suppress=unusedFunction \
|
--suppress=unusedFunction \
|
||||||
--suppress=checkersReport \
|
--suppress=checkersReport \
|
||||||
--suppress=toomanyconfigs \
|
--suppress=toomanyconfigs \
|
||||||
-- *.c *.h 2>&1 | tee /tmp/cppcheck.txt
|
-- "${source_files[@]}" 2>&1 | tee /tmp/cppcheck.txt
|
||||||
|
|
||||||
|
if [[ "${VERIFY_CPPCHECK_ONLY:-0}" == "1" ]]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "=== scan-build ==="
|
echo "=== scan-build ==="
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+3
-2
@@ -24,10 +24,11 @@ NETSNMP_CFLAGS := $(filter -I% -D%, $(shell net-snmp-config --base-cflags 2>/dev
|
|||||||
NETSNMP_LIBS := $(filter -l% -L%, $(shell net-snmp-config --libs 2>/dev/null))
|
NETSNMP_LIBS := $(filter -l% -L%, $(shell net-snmp-config --libs 2>/dev/null))
|
||||||
|
|
||||||
SPINE_SRC := $(addprefix $(SPINE_ROOT)/, \
|
SPINE_SRC := $(addprefix $(SPINE_ROOT)/, \
|
||||||
ping.c util.c sql.c snmp.c locks.c poller.c nft_popen.c php.c keywords.c error.c)
|
ping.c util.c sql.c snmp.c src/core/locks.c poller.c nft_popen.c php.c \
|
||||||
|
src/core/keywords.c error.c)
|
||||||
|
|
||||||
FUZZ_CFLAGS := $(SANITIZERS) -g -O1 -DHAVE_CONFIG_H \
|
FUZZ_CFLAGS := $(SANITIZERS) -g -O1 -DHAVE_CONFIG_H \
|
||||||
-I$(SPINE_ROOT) -I$(SPINE_ROOT)/config \
|
-I$(SPINE_ROOT) -I$(SPINE_ROOT)/src/core -I$(SPINE_ROOT)/config \
|
||||||
$(NETSNMP_CFLAGS) \
|
$(NETSNMP_CFLAGS) \
|
||||||
$(shell mysql_config --include 2>/dev/null)
|
$(shell mysql_config --include 2>/dev/null)
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ CFLAGS += \
|
|||||||
-std=c99 \
|
-std=c99 \
|
||||||
-D_DEFAULT_SOURCE \
|
-D_DEFAULT_SOURCE \
|
||||||
-I$(SPINE_ROOT) \
|
-I$(SPINE_ROOT) \
|
||||||
|
-I$(SPINE_ROOT)/src/core \
|
||||||
-I$(SPINE_ROOT)/config \
|
-I$(SPINE_ROOT)/config \
|
||||||
$(CMOCKA_CFLAGS) \
|
$(CMOCKA_CFLAGS) \
|
||||||
$(MYSQL_CFLAGS) \
|
$(MYSQL_CFLAGS) \
|
||||||
|
|||||||
Reference in new issue
Block a user