Found with ThreadSanitizer over the whole suite, not by reading: - ack: sp_ack_dir() returned one static buffer. The waiter and the answerer (the gateway is both) sprintf'd into each other's path, so an approval request could be looked for in the wrong place. One buffer per thread now; test_ack asserts the two threads get different addresses. - mcp: `stopping` was a plain volatile int with no happens-before, so a server thread could read 0 after shutdown killed its child and keep using buffers that teardown frees. Acquire/release accessors. - foreign: fr.ready was set before the paths it guards were filled, so a second thread returned early and read empty paths; the flag and the host handle are now an atomic pair (publish) plus a mutex (the init itself). - embed: catch_up() read c->path, c->offset and c->id outside the lock. A session switch mid-index published the old file's byte offset into the new session's index - everything below that offset was never searched again. A generation counter makes that run drop its batch, and the search path takes its snapshot under the same lock. Proof, both directions: - make check-tsan: 45/45 test binaries free of races (new target; the tree is rebuilt under TSan and back, like check-asan). - test_embed's new gated test (a server that holds the batch until the session has been switched): without the generation check short.emb ends with 4 records, 1 of them leaked from the other session; with it, 1 and 0. The test is deterministic, so it fails on a plain build too. - test_ack: reverting to `static char root[]` fails "the two threads do not share one buffer". - make check: all tests passed; make check-asan: 45/45 clean.
434 lines
24 KiB
Makefile
434 lines
24 KiB
Makefile
# splinter -- POSIX make for our own code, GNU make only for the vendored curses.
|
|
#
|
|
# make libsplinter.so, the splinter binary, the example plugin
|
|
# make check builds and runs every test binary
|
|
# make curses builds the vendored NetBSD curses explicitly
|
|
# make clean removes generated files only
|
|
#
|
|
# The layout is deliberate: the backend lives in libsplinter.so (src/backend,
|
|
# the engine and everything it owns). The front ends are src/frontend/curses.c
|
|
# (the screen), src/frontend/protocol.c (the engine on a socket) and
|
|
# src/frontend/client.c (the reference client); src/main.c launches them.
|
|
# Every one of them links that single library, so there is exactly one copy of
|
|
# each symbol in the process. Two copies would mean two registries.
|
|
|
|
CC ?= cc
|
|
CFLAGS ?= -std=c99 -O2 -Wall -Wextra -Werror -D_POSIX_C_SOURCE=200809L \
|
|
-fPIC -Iinclude -Isrc/backend -Isrc/frontend -Ivendor/libmcp -Ivendor/netbsd-curses/libcurses
|
|
LDFLAGS ?=
|
|
LIBS ?= -lpthread
|
|
PREFIX ?= /usr/local
|
|
|
|
CURSES_DIR = vendor/netbsd-curses
|
|
CURSES_A = $(CURSES_DIR)/libcurses/libcurses.a \
|
|
$(CURSES_DIR)/libterminfo/libterminfo.a
|
|
|
|
LIB = libsplinter.so
|
|
LIBOBJ = src/backend/buf.o src/backend/tool.o src/backend/session.o src/backend/conv.o src/backend/compact.o src/backend/transport.o \
|
|
src/backend/json.o src/backend/sse.o src/backend/openai.o src/backend/transport_openai.o \
|
|
src/backend/anthropic.o src/backend/transport_anthropic.o src/backend/builtin.o \
|
|
src/backend/agent.o src/backend/theme.o src/backend/palettes.o src/backend/decomp.o src/backend/i18n.o src/backend/delegate.o src/backend/telegram.o src/backend/log.o src/backend/cmdscript.o src/backend/folder.o src/backend/interview.o src/backend/ack.o src/backend/mcpserver.o src/backend/mcpsession.o src/backend/skills.o src/backend/user.o src/backend/prompt.o src/backend/config.o src/backend/plugin.o src/backend/curl.o src/backend/swarm.o src/backend/provstate.o src/backend/md.o src/backend/tgmd.o src/backend/b64.o src/backend/a2aserver.o src/backend/providers.o src/backend/usage.o src/backend/confblock.o src/backend/embed.o src/backend/agents.o src/backend/foreignopen.o src/backend/engine.o src/backend/http.o src/backend/openai_server.o src/backend/catalogs.o
|
|
# buildinfo.o is separate: buildinfo.c is generated from the objects below.
|
|
LIBOBJ_ALL = $(LIBOBJ) src/backend/buildinfo.o
|
|
BIN = splinter
|
|
BINOBJ = src/main.o src/frontend/curses.o src/frontend/protocol.o \
|
|
src/frontend/ui_local.o src/frontend/ui_remote.o
|
|
CLIENT = splinterctl
|
|
CLIENTOBJ = src/frontend/client.o
|
|
PLUGIN = plugins/clock/clock.so plugins/lcm/lcm.so plugins/cps/cps.so \
|
|
plugins/cli/cli.so plugins/focus/focus.so plugins/mcp/mcp.so \
|
|
plugins/ring/ring.so plugins/reminder/reminder.so \
|
|
plugins/kids/kids.so plugins/status/status.so plugins/processes/processes.so \
|
|
plugins/provider/provider.so \
|
|
plugins/scheduler/scheduler.so \
|
|
plugins/a2a/a2a.so \
|
|
plugins/junction/junction.so \
|
|
plugins/self/self.so \
|
|
plugins/cache/cache.so \
|
|
plugins/session/session.so \
|
|
plugins/foreign/foreign.so
|
|
TESTS = tests/test_buf tests/test_tool tests/test_session tests/test_conv \
|
|
tests/test_transport tests/test_agent tests/test_openai \
|
|
tests/test_theme tests/test_plugin tests/test_skills tests/test_telegram tests/test_delegate tests/test_builtin tests/test_ascii tests/test_ack tests/test_i18n tests/test_config tests/test_focus tests/test_sse tests/test_anthropic tests/test_cli tests/test_compactor tests/test_corecompact tests/test_secrets tests/test_mcpclient tests/test_kids tests/test_lifecycle tests/test_md tests/test_tgmd tests/test_providers tests/test_b64 tests/test_pause tests/test_swarm tests/test_provstate tests/test_usage tests/test_agents tests/test_confblock tests/test_jobs tests/test_engine tests/test_self tests/test_fuzz \
|
|
tests/test_sessiontools tests/test_embed tests/test_foreign \
|
|
tests/test_foreignopen
|
|
|
|
RPATH = -Wl,-rpath,'$$ORIGIN'
|
|
PLUGIN_RPATH = -Wl,-rpath,'$$ORIGIN/../..'
|
|
TEST_RPATH = -Wl,-rpath,'$$ORIGIN/..'
|
|
|
|
all: $(LIB) $(BIN) $(CLIENT) $(PLUGIN)
|
|
|
|
# The vendored tree ships a GNUmakefile; this is the only place that needs GNU
|
|
# make, and it is why the comment above says so out loud.
|
|
$(CURSES_A):
|
|
cd $(CURSES_DIR) && $(MAKE) -f GNUmakefile libcurses/libcurses.a \
|
|
libterminfo/libterminfo.a
|
|
|
|
curses: $(CURSES_A)
|
|
|
|
src/backend/catalogs.c: share/locale/de.msg share/locale/en.msg share/locale/pt_BR.msg tools/embed_catalogs.sh
|
|
sh tools/embed_catalogs.sh share/locale/*.msg > $@
|
|
|
|
# The build stamp --version prints. It is regenerated only when one of the
|
|
# objects it describes is newer, so a no-op make keeps the old stamp: the
|
|
# stamp says when this binary was actually built, not when make last ran.
|
|
# The revision is included because 0.1.0 does not tell two builds apart.
|
|
src/backend/buildinfo.c: $(LIBOBJ) $(BINOBJ)
|
|
@{ \
|
|
rev=`git rev-parse --short HEAD 2>/dev/null` || rev=unknown; \
|
|
if [ -n "`git status --porcelain --untracked-files=no 2>/dev/null | head -n 1`" ]; then \
|
|
rev="$$rev-dirty"; \
|
|
fi; \
|
|
printf '/* generated by make: the build stamp of this binary */\nconst char *sp_build_time = "%s";\nconst char *sp_build_rev = "%s";\n' \
|
|
"`date '+%Y-%m-%d %H:%M:%S %Z'`" "$$rev"; \
|
|
} > $@
|
|
|
|
$(LIB): $(LIBOBJ_ALL) $(CURSES_A)
|
|
$(CC) -shared -o $@ $(LIBOBJ_ALL) $(CURSES_A) $(LIBS)
|
|
|
|
# curses belongs to the front end, not to the library: a plugin that drew into
|
|
# a WINDOW would be a plugin holding the UI thread's state.
|
|
# The reference client links the library for the JSON it cannot be bothered to
|
|
# write twice, but never the curses code and never the engine's internals.
|
|
$(CLIENT): $(CLIENTOBJ) $(LIB)
|
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(CLIENTOBJ) -L. -lsplinter $(RPATH) \
|
|
$(LIBS)
|
|
|
|
$(BIN): $(BINOBJ) $(LIB)
|
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(BINOBJ) -L. -lsplinter $(RPATH) \
|
|
$(CURSES_A) $(LIBS)
|
|
|
|
plugins/clock/clock.so: plugins/clock/clock.c $(LIB)
|
|
$(CC) $(CFLAGS) -shared -o $@ plugins/clock/clock.c -L. -lsplinter \
|
|
$(PLUGIN_RPATH) $(LIBS)
|
|
|
|
plugins/lcm/lcm.so: plugins/lcm/lcm.c $(LIB)
|
|
$(CC) $(CFLAGS) -shared -o $@ plugins/lcm/lcm.c -L. -lsplinter \
|
|
$(PLUGIN_RPATH) $(LIBS)
|
|
|
|
plugins/session/session.so: plugins/session/session.c $(LIB)
|
|
$(CC) $(CFLAGS) -shared -o $@ plugins/session/session.c -L. -lsplinter \
|
|
$(PLUGIN_RPATH) $(LIBS)
|
|
|
|
plugins/foreign/foreign.so: plugins/foreign/foreign.c $(LIB)
|
|
$(CC) $(CFLAGS) -shared -o $@ plugins/foreign/foreign.c -L. -lsplinter \
|
|
$(PLUGIN_RPATH) $(LIBS)
|
|
|
|
plugins/cli/cli.so: plugins/cli/cli.c $(LIB)
|
|
$(CC) $(CFLAGS) -shared -o $@ plugins/cli/cli.c -L. -lsplinter \
|
|
$(PLUGIN_RPATH) $(LIBS)
|
|
|
|
plugins/ring/ring.so: plugins/ring/ring.c $(LIB)
|
|
$(CC) $(CFLAGS) -shared -o $@ plugins/ring/ring.c -L. -lsplinter \
|
|
$(PLUGIN_RPATH) $(LIBS)
|
|
plugins/kids/kids.so: plugins/kids/kids.c $(LIB)
|
|
$(CC) $(CFLAGS) -shared -o $@ plugins/kids/kids.c -L. -lsplinter \
|
|
$(PLUGIN_RPATH) $(LIBS)
|
|
plugins/processes/processes.so: plugins/processes/processes.c $(LIB)
|
|
$(CC) $(CFLAGS) -shared -o $@ plugins/processes/processes.c -L. -lsplinter \
|
|
$(PLUGIN_RPATH) $(LIBS)
|
|
plugins/status/status.so: plugins/status/status.c $(LIB)
|
|
$(CC) $(CFLAGS) -shared -o $@ plugins/status/status.c -L. -lsplinter \
|
|
$(PLUGIN_RPATH) $(LIBS)
|
|
plugins/reminder/reminder.so: plugins/reminder/reminder.c $(LIB)
|
|
$(CC) $(CFLAGS) -shared -o $@ plugins/reminder/reminder.c -L. -lsplinter \
|
|
$(PLUGIN_RPATH) $(LIBS)
|
|
plugins/mcp/mcp.so: plugins/mcp/mcp.c $(LIB)
|
|
$(CC) $(CFLAGS) -shared -o $@ plugins/mcp/mcp.c -L. -lsplinter \
|
|
$(PLUGIN_RPATH) $(LIBS)
|
|
plugins/focus/focus.so: plugins/focus/focus.c $(LIB)
|
|
$(CC) $(CFLAGS) -shared -o $@ plugins/focus/focus.c -L. -lsplinter \
|
|
$(PLUGIN_RPATH) $(LIBS)
|
|
|
|
plugins/cps/cps.so: plugins/cps/cps.c $(LIB)
|
|
$(CC) $(CFLAGS) -shared -o $@ plugins/cps/cps.c -L. -lsplinter \
|
|
$(PLUGIN_RPATH) $(LIBS)
|
|
|
|
.c.o:
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
# A cli delegate's child has to find plugins/cli/cli.so. Beside an installed
|
|
# binary there is no such file, so the build directory this binary came from is
|
|
# compiled in as the last resort (sp_delegate_cli_plugin in src/backend/delegate.c).
|
|
src/backend/delegate.o: src/backend/delegate.c
|
|
$(CC) $(CFLAGS) -DSPLINTER_PLUGIN_DIR='"$(CURDIR)"' -c -o $@ $<
|
|
|
|
# POSIX make has no automatic dependencies. Rather than a list that is wrong
|
|
# the day somebody adds an #include, every object depends on the headers that
|
|
# make up the interface: a change there rebuilds everything that could see it.
|
|
HDRS = include/splinter.h include/splinter_engine.h include/splinter_plugin.h \
|
|
src/backend/config.h src/backend/ack.h \
|
|
src/backend/curl.h src/backend/log.h src/backend/i18n.h src/backend/md.h src/backend/b64.h src/backend/a2aserver.h
|
|
$(LIBOBJ) $(BINOBJ): $(HDRS)
|
|
$(PLUGIN): $(HDRS)
|
|
#
|
|
# The tests too: a test that allocates a struct sp_reply by value and
|
|
# links a freshly built library is one header change away from reading
|
|
# the fields of a different layout. That failure looks like a broken
|
|
# test, not like a stale object, so it costs an hour every time.
|
|
$(TESTS): $(HDRS)
|
|
|
|
src/backend/agent.o: include/splinter.h
|
|
src/backend/buf.o: include/splinter.h
|
|
src/backend/tool.o: include/splinter.h
|
|
src/backend/session.o: include/splinter.h
|
|
src/backend/transport.o: include/splinter.h
|
|
src/backend/conv.o: include/splinter.h
|
|
src/backend/json.o: vendor/libmcp/mcp.h
|
|
src/backend/sse.o: include/splinter.h vendor/libmcp/mcp.h
|
|
src/backend/openai.o: include/splinter.h vendor/libmcp/mcp.h
|
|
src/backend/transport_openai.o: include/splinter.h src/backend/curl.h src/backend/log.h
|
|
src/backend/anthropic.o: include/splinter.h vendor/libmcp/mcp.h
|
|
src/backend/transport_anthropic.o: include/splinter.h src/backend/curl.h src/backend/log.h vendor/libmcp/mcp.h
|
|
src/backend/curl.o: src/backend/curl.h include/splinter.h
|
|
src/backend/builtin.o: include/splinter.h
|
|
src/backend/theme.o: src/backend/theme.h src/backend/palettes.h include/splinter.h
|
|
src/backend/palettes.o: src/backend/palettes.h
|
|
src/backend/decomp.o: src/backend/decomp.h
|
|
src/backend/i18n.o: src/backend/i18n.h include/splinter.h
|
|
src/backend/delegate.o: src/backend/config.h include/splinter.h
|
|
src/backend/telegram.o: include/splinter.h src/backend/curl.h src/backend/ack.h
|
|
src/backend/log.o: src/backend/log.h
|
|
src/backend/cmdscript.o: src/backend/cmdscript.h include/splinter.h
|
|
src/backend/folder.o: src/backend/folder.h include/splinter.h
|
|
src/backend/ack.o: src/backend/ack.h include/splinter.h
|
|
src/backend/interview.o: src/backend/interview.h include/splinter.h
|
|
src/backend/mcpserver.o: src/backend/mcpserver.h include/splinter.h
|
|
src/backend/skills.o: src/backend/skills.h src/backend/config.h include/splinter.h
|
|
src/backend/prompt.o: src/backend/prompt.h include/splinter.h
|
|
src/backend/config.o: src/backend/config.h include/splinter.h
|
|
src/backend/plugin.o: include/splinter.h include/splinter_plugin.h
|
|
src/frontend/curses.o: src/frontend/ui.h src/frontend/ui_backend.h \
|
|
include/splinter_engine.h src/backend/theme.h src/backend/decomp.h src/backend/i18n.h include/splinter.h include/splinter_plugin.h src/backend/md.h
|
|
src/backend/md.o: src/backend/md.h include/splinter.h
|
|
src/backend/b64.o: src/backend/b64.h include/splinter.h
|
|
src/backend/a2aserver.o: src/backend/a2aserver.h include/splinter.h vendor/libmcp/mcp.h
|
|
src/frontend/ui_local.o: src/frontend/ui_backend.h include/splinter_engine.h src/frontend/ui.h
|
|
src/frontend/ui_remote.o: src/frontend/ui_backend.h src/frontend/protocol.h include/splinter_engine.h vendor/libmcp/mcp.h
|
|
src/frontend/client.o: src/frontend/protocol.h include/splinter.h
|
|
src/frontend/protocol.o: src/frontend/protocol.h include/splinter_engine.h include/splinter.h src/backend/i18n.h
|
|
src/backend/http.o: src/backend/http.h include/splinter.h
|
|
src/backend/openai_server.o: src/backend/openai_server.h src/backend/http.h src/backend/config.h include/splinter.h vendor/libmcp/mcp.h
|
|
src/backend/engine.o: include/splinter_engine.h src/backend/config.h src/backend/providers.h src/backend/agents.h src/backend/swarm.h src/backend/cmdscript.h src/backend/i18n.h include/splinter_plugin.h
|
|
src/backend/providers.o: src/backend/providers.h src/backend/config.h include/splinter.h include/splinter_plugin.h
|
|
src/main.o: include/splinter.h include/splinter_engine.h \
|
|
src/frontend/ui_backend.h src/backend/config.h src/backend/i18n.h include/splinter_plugin.h src/frontend/ui.h src/backend/theme.h src/backend/a2aserver.h
|
|
|
|
tests/test_buf: tests/test_buf.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_buf.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_tool: tests/test_tool.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_tool.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_session: tests/test_session.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_session.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_transport: tests/test_transport.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_transport.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_agent: tests/test_agent.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_agent.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_conv: tests/test_conv.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_conv.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_openai: tests/test_openai.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_openai.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_theme: tests/test_theme.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_theme.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_focus: tests/test_focus.c $(LIB) $(PLUGIN)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_focus.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_skills: tests/test_skills.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_skills.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_telegram: tests/test_telegram.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_telegram.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_delegate: tests/test_delegate.c $(LIB) $(PLUGIN)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_delegate.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_builtin: tests/test_builtin.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_builtin.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_ack: tests/test_ack.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_ack.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_i18n: tests/test_i18n.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_i18n.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_ascii: tests/test_ascii.c $(LIB) $(BINOBJ)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_ascii.c src/frontend/curses.o -L. -lsplinter \
|
|
$(TEST_RPATH) $(CURSES_A) $(LIBS)
|
|
tests/test_md: tests/test_md.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_md.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_tgmd: tests/test_tgmd.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_tgmd.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_providers: tests/test_providers.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_providers.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_b64: tests/test_b64.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_b64.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_pause: tests/test_pause.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_pause.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_swarm: tests/test_swarm.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_swarm.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_provstate: tests/test_provstate.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_provstate.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
|
|
tests/test_agents: tests/test_agents.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_agents.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
|
|
tests/test_confblock: tests/test_confblock.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_confblock.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
|
|
tests/test_engine: tests/test_engine.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_engine.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_junction: tests/test_junction.c $(LIB) plugins/junction/junction.so
|
|
$(CC) $(CFLAGS) -o $@ tests/test_junction.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_self: tests/test_self.c $(LIB) plugins/self/self.so
|
|
$(CC) $(CFLAGS) -o $@ tests/test_self.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
|
|
tests/test_fuzz: tests/test_fuzz.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_fuzz.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
|
|
tests/test_sessiontools: tests/test_sessiontools.c $(LIB) plugins/session/session.so plugins/foreign/foreign.so
|
|
$(CC) $(CFLAGS) -o $@ tests/test_sessiontools.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_foreign: tests/test_foreign.c $(LIB) plugins/foreign/foreign.so
|
|
$(CC) $(CFLAGS) -o $@ tests/test_foreign.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_foreignopen: tests/test_foreignopen.c $(LIB) plugins/foreign/foreign.so
|
|
$(CC) $(CFLAGS) -o $@ tests/test_foreignopen.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
|
|
tests/test_usage: tests/test_usage.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_usage.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_jobs: tests/test_jobs.c $(LIB) $(PLUGIN)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_jobs.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_config: tests/test_config.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_config.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_anthropic: tests/test_anthropic.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_anthropic.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_sse: tests/test_sse.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_sse.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_cli: tests/test_cli.c $(LIB) $(PLUGIN)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_cli.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
|
|
tests/test_compactor: tests/test_compactor.c $(LIB) $(PLUGIN)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_compactor.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
|
|
tests/test_corecompact: tests/test_corecompact.c $(LIB)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_corecompact.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_secrets: tests/test_secrets.c $(LIB) $(PLUGIN)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_secrets.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_mcpclient: tests/test_mcpclient.c $(LIB) $(PLUGIN)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_mcpclient.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_kids: tests/test_kids.c $(LIB) $(PLUGIN)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_kids.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_embed: tests/test_embed.c $(LIB) $(HDRS)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_embed.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/plugin_lifecycle.so: tests/plugin_lifecycle.c $(LIB) $(HDRS)
|
|
$(CC) $(CFLAGS) -shared -o $@ tests/plugin_lifecycle.c -L. -lsplinter \
|
|
$(TEST_RPATH) $(LIBS)
|
|
tests/test_lifecycle: tests/test_lifecycle.c $(LIB) tests/plugin_lifecycle.so
|
|
$(CC) $(CFLAGS) -o $@ tests/test_lifecycle.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
tests/test_plugin: tests/test_plugin.c $(LIB) $(PLUGIN)
|
|
$(CC) $(CFLAGS) -o $@ tests/test_plugin.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
|
|
|
|
# Every test runs under a 64 MB address-space limit: splinter is meant to
|
|
# be small, and a test that runs away (a retry loop appending to a buffer
|
|
# took 17 GB, 2026-11-18) must die at once instead of swapping the host.
|
|
TEST_MEM_KB ?= 65536
|
|
|
|
check: $(LIB) $(BIN) $(CLIENT) $(PLUGIN) $(TESTS) tests/test_junction
|
|
@set -e; python3 tools/check_i18n.py; \
|
|
ulimit -v $(TEST_MEM_KB); \
|
|
export LD_LIBRARY_PATH=.; \
|
|
SPLINTER_SESSION_DIR=$$(mktemp -d "$${TMPDIR:-/tmp}/splinter-check-XXXXXX"); \
|
|
export SPLINTER_SESSION_DIR; \
|
|
trap 'rm -rf "$$SPLINTER_SESSION_DIR"' EXIT; \
|
|
for t in $(TESTS); do echo "== $$t"; ./$$t; done; \
|
|
echo "== tests/test_delegate_cli.sh"; sh tests/test_delegate_cli.sh; \
|
|
echo "== tests/test_interview.sh"; sh tests/test_interview.sh; \
|
|
echo "== tests/test_gateway.sh"; sh tests/test_gateway.sh; \
|
|
echo "== tests/test_a2a.sh"; sh tests/test_a2a.sh; \
|
|
echo "== tests/test_a2a_ui.sh"; sh tests/test_a2a_ui.sh; \
|
|
echo "== tests/test_a2a_server.sh"; sh tests/test_a2a_server.sh; \
|
|
echo "== tests/test_a2a_context.sh"; sh tests/test_a2a_context.sh; \
|
|
echo "== tests/test_limit_wait.sh"; sh tests/test_limit_wait.sh; \
|
|
echo "== tests/test_pools.sh"; sh tests/test_pools.sh; \
|
|
echo "== tests/test_anthropic.sh"; sh tests/test_anthropic.sh; \
|
|
echo "== tests/test_agents_ui.sh"; sh tests/test_agents_ui.sh; \
|
|
echo "== tests/test_a2a_input.sh"; sh tests/test_a2a_input.sh; \
|
|
echo "== tests/test_ui.sh"; sh tests/test_ui.sh; \
|
|
echo "== tests/test_protocol.sh"; sh tests/test_protocol.sh; \
|
|
echo "== tests/test_attach.sh"; sh tests/test_attach.sh; \
|
|
echo "== tests/test_attach_busy.sh"; sh tests/test_attach_busy.sh; \
|
|
echo "== tests/test_gateway_openai.sh"; sh tests/test_gateway_openai.sh; \
|
|
echo "== tests/test_usage_request.sh"; sh tests/test_usage_request.sh; \
|
|
echo "== tests/test_compact_resume.sh"; sh tests/test_compact_resume.sh; \
|
|
echo "== tests/test_reconnect.sh"; sh tests/test_reconnect.sh; \
|
|
echo "== tests/test_junction.sh"; sh tests/test_junction.sh; \
|
|
echo "== tests/test_mcpsession.sh"; sh tests/test_mcpsession.sh; \
|
|
echo "all tests passed"
|
|
|
|
# The unit tests under ASAN/UBSAN with leak detection. Rebuilds the tree with
|
|
# sanitizers and back; run it when nothing else builds in this tree.
|
|
check-asan:
|
|
@sh tests/check_asan.sh
|
|
|
|
# The unit tests under ThreadSanitizer: the engine has a turn thread, a UI
|
|
# thread, widget threads and one thread per MCP server. Rebuilds the tree with
|
|
# -fsanitize=thread and back; run it when nothing else builds in this tree.
|
|
check-tsan:
|
|
@sh tests/check_tsan.sh
|
|
|
|
# the test binaries as a list, for check_asan.sh
|
|
print-tests:
|
|
@echo $(TESTS)
|
|
|
|
# The installed binary finds its own library through an rpath relative to itself
|
|
# ($ORIGIN), so 'make install PREFIX=$HOME/.local' produces a program that runs
|
|
# without a wrapper, without LD_LIBRARY_PATH and without an environment file.
|
|
# Install by rename, never in place. A running splinter has these files
|
|
# mapped: cp truncates the old inode and writes into pages the process is
|
|
# executing, which killed a gateway that was up while make install ran
|
|
# (SIGSEGV at a nonsense address). A rename swaps the directory entry and
|
|
# leaves the mapped inode alone.
|
|
install: all
|
|
mkdir -p $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(PREFIX)/lib \
|
|
$(DESTDIR)$(PREFIX)/lib/splinter/plugins
|
|
$(CC) $(CFLAGS) $(LDFLAGS) -Wl,-rpath,'$$ORIGIN/../lib' \
|
|
-o $(DESTDIR)$(PREFIX)/bin/.splinter.new $(BINOBJ) -L. -lsplinter \
|
|
$(CURSES_A) $(LIBS)
|
|
mv -f $(DESTDIR)$(PREFIX)/bin/.splinter.new \
|
|
$(DESTDIR)$(PREFIX)/bin/splinter
|
|
$(CC) $(CFLAGS) $(LDFLAGS) -Wl,-rpath,'$$ORIGIN/../lib' \
|
|
-o $(DESTDIR)$(PREFIX)/bin/.$(CLIENT).new $(CLIENTOBJ) -L. -lsplinter \
|
|
$(LIBS)
|
|
mv -f $(DESTDIR)$(PREFIX)/bin/.$(CLIENT).new \
|
|
$(DESTDIR)$(PREFIX)/bin/$(CLIENT)
|
|
cp $(LIB) $(DESTDIR)$(PREFIX)/lib/.$(LIB).new
|
|
mv -f $(DESTDIR)$(PREFIX)/lib/.$(LIB).new $(DESTDIR)$(PREFIX)/lib/$(LIB)
|
|
for p in $(PLUGIN); do \
|
|
cp "$$p" "$(DESTDIR)$(PREFIX)/lib/splinter/plugins/.new.$$$$" && \
|
|
mv -f "$(DESTDIR)$(PREFIX)/lib/splinter/plugins/.new.$$$$" \
|
|
"$(DESTDIR)$(PREFIX)/lib/splinter/plugins/$${p##*/}" || exit 1; \
|
|
done
|
|
@echo "installed $(DESTDIR)$(PREFIX)/bin/splinter"
|
|
|
|
clean:
|
|
rm -f src/backend/catalogs.c src/backend/buildinfo.c $(BIN) $(CLIENT) $(LIB) $(LIBOBJ_ALL) $(BINOBJ) \
|
|
$(CLIENTOBJ) $(PLUGIN) $(TESTS) tests/plugin_lifecycle.so \
|
|
tests/test_junction
|
|
|
|
.PHONY: all check curses install clean
|
|
|
|
plugins/provider/provider.so: plugins/provider/provider.c $(LIB)
|
|
$(CC) $(CFLAGS) -shared -o $@ plugins/provider/provider.c -L. -lsplinter \
|
|
$(PLUGIN_RPATH) $(LIBS)
|
|
|
|
plugins/scheduler/scheduler.so: plugins/scheduler/scheduler.c $(LIB)
|
|
$(CC) $(CFLAGS) -shared -o $@ plugins/scheduler/scheduler.c -L. -lsplinter \
|
|
$(PLUGIN_RPATH) $(LIBS)
|
|
plugins/a2a/a2a.so: plugins/a2a/a2a.c $(LIB)
|
|
$(CC) $(CFLAGS) -shared -o $@ plugins/a2a/a2a.c -L. -lsplinter \
|
|
$(PLUGIN_RPATH) $(LIBS)
|
|
|
|
plugins/junction/junction.so: plugins/junction/junction.c $(LIB)
|
|
$(CC) $(CFLAGS) -shared -o $@ plugins/junction/junction.c -L. -lsplinter \
|
|
$(PLUGIN_RPATH) $(LIBS)
|
|
|
|
plugins/cache/cache.so: plugins/cache/cache.c $(LIB)
|
|
$(CC) $(CFLAGS) -shared -o $@ plugins/cache/cache.c -L. -lsplinter \
|
|
$(PLUGIN_LDFLAGS)
|
|
|
|
plugins/self/self.so: plugins/self/self.c $(LIB)
|
|
$(CC) $(CFLAGS) -shared -o $@ plugins/self/self.c -L. -lsplinter \
|
|
$(PLUGIN_RPATH) $(LIBS)
|