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~
|
||||
libtool
|
||||
stamp-h1
|
||||
.deps/
|
||||
.dirstamp
|
||||
.libs/
|
||||
*.o
|
||||
*.lo
|
||||
*.la
|
||||
*.gcda
|
||||
*.gcno
|
||||
*.log
|
||||
*.tar.gz
|
||||
**/.deps/
|
||||
**/.dirstamp
|
||||
**/.libs/
|
||||
**/*.o
|
||||
**/*.lo
|
||||
**/*.la
|
||||
**/*.gcda
|
||||
**/*.gcno
|
||||
**/*.log
|
||||
**/*.tar.gz
|
||||
|
||||
# the built binary itself
|
||||
/spine
|
||||
@@ -20,6 +20,7 @@
|
||||
# +-------------------------------------------------------------------------+
|
||||
|
||||
.deps
|
||||
.dirstamp
|
||||
Makefile
|
||||
Makefile.in
|
||||
configure
|
||||
|
||||
+9
-9
@@ -22,7 +22,8 @@
|
||||
AUTOMAKE_OPTIONS = foreign
|
||||
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)
|
||||
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
|
||||
# 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 \
|
||||
ping.h poller.h snmp.h spine.h spine_sem.h sql.h uthash.h util.h
|
||||
noinst_HEADERS = common.h error.h src/core/keywords.h src/core/locks.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
|
||||
|
||||
@@ -66,12 +68,9 @@ verify: docker-dev
|
||||
docker run --rm spine-dev
|
||||
|
||||
cppcheck: docker-dev
|
||||
docker run --rm spine-dev bash -c \
|
||||
"cppcheck --enable=all --std=c11 --error-exitcode=1 \
|
||||
--suppress=missingIncludeSystem --suppress=unusedFunction \
|
||||
--suppress=checkersReport --suppress=toomanyconfigs $(spine_SOURCES)"
|
||||
docker run --rm -e VERIFY_CPPCHECK_ONLY=1 spine-dev
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_builddir)
|
||||
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/src/core -I$(top_builddir)
|
||||
|
||||
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
|
||||
# globals that spine.c would define.
|
||||
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 = $(check_PROGRAMS)
|
||||
+1
-1
@@ -30,7 +30,7 @@ AC_CONFIG_SRCDIR(spine.c)
|
||||
AC_PREFIX_DEFAULT(/usr/local/spine)
|
||||
AC_LANG(C)
|
||||
|
||||
AM_INIT_AUTOMAKE([foreign])
|
||||
AM_INIT_AUTOMAKE([foreign subdir-objects])
|
||||
AM_SILENT_RULES([yes])
|
||||
AC_CONFIG_HEADERS(config/config.h)
|
||||
|
||||
|
||||
+20
-1
@@ -2,12 +2,31 @@
|
||||
set -euo pipefail
|
||||
|
||||
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 \
|
||||
-I. -Isrc/core \
|
||||
--suppress=missingIncludeSystem \
|
||||
--suppress=unusedFunction \
|
||||
--suppress=checkersReport \
|
||||
--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 "=== 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))
|
||||
|
||||
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 \
|
||||
-I$(SPINE_ROOT) -I$(SPINE_ROOT)/config \
|
||||
-I$(SPINE_ROOT) -I$(SPINE_ROOT)/src/core -I$(SPINE_ROOT)/config \
|
||||
$(NETSNMP_CFLAGS) \
|
||||
$(shell mysql_config --include 2>/dev/null)
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ CFLAGS += \
|
||||
-std=c99 \
|
||||
-D_DEFAULT_SOURCE \
|
||||
-I$(SPINE_ROOT) \
|
||||
-I$(SPINE_ROOT)/src/core \
|
||||
-I$(SPINE_ROOT)/config \
|
||||
$(CMOCKA_CFLAGS) \
|
||||
$(MYSQL_CFLAGS) \
|
||||
|
||||
Reference in new issue
Block a user