scorpiox-bot-plugin-webhook
←Makefiletext
99 lines · 3 KBHEADBlameDownload
1# plugin_webhook - SCORPIOX BOT open-source named webhook & REST trigger
2# MCP connector
3#
4# Zero runtime dependencies on every artefact. The third-party C in the tree is
5# vendored under vendor/: yyjson (MIT) and Mbed TLS 3.6.7 (Apache-2.0), whose
6# sources sit in vendor/mbedtlslib with their public headers flattened into
7# vendor/mbedtls and vendor/psa. That layout is what the SCORPIOX BOT release
8# CLI (scorpiox-cli-botplugin build/publish) expects: it compiles every .c
9# under src/ and vendor/ with exactly -I <repo>/src -I <repo>/vendor, so a
10# vendored library must be reachable from those two include roots.
11#
12# On _WIN32 the HTTP and TLS legs are WinHTTP instead, so the static PE needs no
13# extra DLLs and no crypto object files are reached.
14#
15# Targets:
16# make native build -> ./plugin_webhook
17# make musl static musl x86_64 -> ./plugin_webhook.musl
18# make arm64 static arm64 musl -> ./plugin_webhook.arm64
19# make win64 MinGW-w64 static -> ./plugin_webhook.exe
20# make macos Apple clang -> ./plugin_webhook (run on macOS)
21# make asan ASan + UBSan + _FORTIFY_SOURCE=2 -> ./plugin_webhook-asan
22# make fortify -D_FORTIFY_SOURCE=2 -> ./plugin_webhook-fortify
23# make ui regenerate src/ui_html.h from src/ui.html
24# make test build + run tests/run.sh
25# make e2e build + run tests/e2e.py --shots (Playwright, refreshes docs/)
26# make clean
27
28CC ?= cc
29WARN := -Wall -Wextra -Wno-overlength-strings
30STD := -std=c99
31INCLUDES := -I src -I vendor -I vendor/mbedtlslib
32CFLAGS ?= -O2 $(STD) $(WARN) $(INCLUDES)
33MUSL_CC ?= musl-gcc
34MUSL_CFLAGS := -O2 $(STD) $(WARN) $(INCLUDES) -static
35ARM_CC ?= aarch64-linux-gnu-gcc
36ARM_CFLAGS := -O2 $(STD) $(WARN) $(INCLUDES) -static
37WIN_CC ?= x86_64-w64-mingw32-gcc
38WIN_CFLAGS := -O2 $(STD) $(WARN) $(INCLUDES) -static
39WIN_LIBS := -lwinhttp -lws2_32 -lbcrypt -lcrypt32
40
41SRC_C := $(wildcard src/*.c)
42VENDOR_C := $(wildcard vendor/*.c) $(wildcard vendor/mbedtlslib/*.c)
43UI_SRC := src/ui.html
44UI_HDR := src/ui_html.h
45BIN := plugin_webhook
46EXE := plugin_webhook.exe
47
48.PHONY: all native musl arm64 win64 macos asan fortify ui test e2e clean help
49
50all: native
51
52$(UI_HDR): $(UI_SRC) tools/gen_ui.py
53 @echo "==> regenerating $(UI_HDR)"
54 python3 tools/gen_ui.py
55
56ui: $(UI_HDR)
57
58native: $(BIN)
59
60$(BIN): $(SRC_C) $(VENDOR_C) $(UI_HDR)
61 @echo "==> native build ($(CC))"
62 $(CC) $(CFLAGS) $(SRC_C) $(VENDOR_C) -o $(BIN)
63
64musl: $(SRC_C) $(VENDOR_C) $(UI_HDR)
65 @echo "==> static musl build ($(MUSL_CC))"
66 $(MUSL_CC) $(MUSL_CFLAGS) $(SRC_C) $(VENDOR_C) -o $(BIN).musl
67
68arm64: $(SRC_C) $(VENDOR_C) $(UI_HDR)
69 @echo "==> static arm64 build ($(ARM_CC))"
70 $(ARM_CC) $(ARM_CFLAGS) $(SRC_C) $(VENDOR_C) -o $(BIN).arm64
71
72win64: $(SRC_C) $(VENDOR_C) $(UI_HDR)
73 @echo "==> MinGW-w64 build ($(WIN_CC))"
74 $(WIN_CC) $(WIN_CFLAGS) $(SRC_C) $(VENDOR_C) -o $(EXE) $(WIN_LIBS)
75
76macos: $(SRC_C) $(VENDOR_C) $(UI_HDR)
77 @echo "==> Apple clang build"
78 $(CC) $(CFLAGS) $(SRC_C) $(VENDOR_C) -o $(BIN)
79
80asan: $(SRC_C) $(VENDOR_C) $(UI_HDR)
81 $(CC) $(CFLAGS) -g -O1 -fsanitize=address,undefined \
82 -fno-omit-frame-pointer -D_FORTIFY_SOURCE=2 \
83 $(SRC_C) $(VENDOR_C) -o $(BIN)-asan
84
85fortify: $(SRC_C) $(VENDOR_C) $(UI_HDR)
86 $(CC) $(CFLAGS) -O2 -D_FORTIFY_SOURCE=2 $(SRC_C) $(VENDOR_C) -o $(BIN)-fortify
87
88test: native
89 @bash tests/run.sh
90
91e2e: native
92 @python3 tests/e2e.py --shots
93
94clean:
95 rm -f $(BIN) $(EXE) $(BIN).musl $(BIN).arm64 $(BIN)-asan $(BIN)-fortify
96 rm -rf tests/__pycache__
97
98help:
99 @echo "make | make musl | make arm64 | make win64 | make macos | make asan | make fortify | make ui | make test | make e2e | make clean"