| 1 | # plugin_github - SCORPIOX BOT open-source GitHub MCP connector |
| 2 | # |
| 3 | # The only third-party C in the tree is vendored under vendor/: |
| 4 | # vendor/yyjson.c (MIT, ibireme) JSON parse/write |
| 5 | # vendor/bearssl/ (MIT, Thomas Pornin) TLS 1.2+ client |
| 6 | # |
| 7 | # The plugin runtime is the SCORPIOX BOT Connector SDK, vendored into src/: |
| 8 | # src/sx_connector.{c,h} the plugin/connector contract (CGI, auth, MCP, |
| 9 | # connector state, theming) and src/sx_http_tls.{c,h} |
| 10 | # (HTTP/1.1 + TLS over the BearSSL tree above). |
| 11 | # The vendored TLS stack lives flat in vendor/bearssl (sources and public |
| 12 | # headers side by side) because the SCORPIOX BOT release CLI compiles every .c |
| 13 | # under src/ + vendor/ with a fixed -I src -I vendor flag set - and a |
| 14 | # vendor/<lib>/ subdirectory used to fail every dist target silently. Nothing |
| 15 | # here needs libcurl, OpenSSL or a system CA file at runtime: the roots are |
| 16 | # compiled in (src/ca_roots_pem.h). |
| 17 | # |
| 18 | # Targets: |
| 19 | # make native build -> ./plugin_github |
| 20 | # make musl static musl x86_64 -> ./plugin_github.musl |
| 21 | # make arm64 static arm64 musl -> ./plugin_github.arm64 |
| 22 | # make win64 MinGW-w64 static -> ./plugin_github.exe |
| 23 | # make macos Apple clang -> ./plugin_github (run this on macOS) |
| 24 | # make asan ASan + UBSan + _FORTIFY_SOURCE=2 -> ./plugin_github-asan |
| 25 | # make ui regenerate src/ui_html.h from src/ui.html |
| 26 | # make test build + run tests/run.sh |
| 27 | # make e2e build + run tests/e2e.py (Playwright) |
| 28 | # make clean |
| 29 | |
| 30 | CC ?= cc |
| 31 | WARN := -Wall -Wextra -Wno-overlength-strings -Wno-unused-function |
| 32 | STD := -std=c99 |
| 33 | INCLUDES := -I src -I vendor |
| 34 | CFLAGS ?= -O2 $(STD) $(WARN) $(INCLUDES) |
| 35 | MUSL_CC ?= musl-gcc |
| 36 | ARM_CC ?= aarch64-linux-gnu-gcc |
| 37 | WIN_CC ?= x86_64-w64-mingw32-gcc |
| 38 | |
| 39 | SRC_C := $(wildcard src/*.c) |
| 40 | # Every header is a prerequisite too: without them a one-line header edit |
| 41 | # would leave the previous binary in place while `make` says success. |
| 42 | HDR := $(wildcard src/*.h) $(wildcard vendor/*.h) $(wildcard vendor/bearssl/*.h) |
| 43 | VENDOR_C := $(wildcard vendor/*.c) $(wildcard vendor/bearssl/*.c) |
| 44 | UI_SRC := src/ui.html |
| 45 | UI_HDR := src/ui_html.h |
| 46 | BIN := plugin_github |
| 47 | EXE := plugin_github.exe |
| 48 | WIN_LIBS := -lws2_32 |
| 49 | # The vendored SDK's transport is self-contained on every platform (BearSSL |
| 50 | # does the TLS on Windows too), so -lws2_32 is the only import library. |
| 51 | |
| 52 | .PHONY: all native musl arm64 win64 macos asan ui test e2e clean help install |
| 53 | |
| 54 | all: native |
| 55 | |
| 56 | $(UI_HDR): $(UI_SRC) tools/gen_ui.py |
| 57 | @echo "==> regenerating $(UI_HDR)" |
| 58 | python3 tools/gen_ui.py |
| 59 | |
| 60 | ui: $(UI_HDR) |
| 61 | |
| 62 | native: $(BIN) |
| 63 | |
| 64 | $(BIN): $(SRC_C) $(HDR) $(UI_HDR) $(VENDOR_C) |
| 65 | @echo "==> native build ($(CC))" |
| 66 | $(CC) $(CFLAGS) -o $(BIN) $(SRC_C) $(VENDOR_C) |
| 67 | |
| 68 | musl: $(BIN).musl |
| 69 | $(BIN).musl: $(SRC_C) $(HDR) $(UI_HDR) $(VENDOR_C) |
| 70 | @echo "==> static musl build ($(MUSL_CC))" |
| 71 | $(MUSL_CC) $(CFLAGS) -static -fno-strict-aliasing -o $@ $(SRC_C) $(VENDOR_C) |
| 72 | |
| 73 | arm64: $(BIN).arm64 |
| 74 | $(BIN).arm64: $(SRC_C) $(HDR) $(UI_HDR) $(VENDOR_C) |
| 75 | @echo "==> static arm64 build ($(ARM_CC))" |
| 76 | $(ARM_CC) $(CFLAGS) -static -fno-strict-aliasing -o $@ $(SRC_C) $(VENDOR_C) |
| 77 | |
| 78 | win64: $(EXE) |
| 79 | $(EXE): $(SRC_C) $(HDR) $(UI_HDR) $(VENDOR_C) |
| 80 | @echo "==> MinGW-w64 build ($(WIN_CC))" |
| 81 | $(WIN_CC) $(CFLAGS) -static -D_WIN32_WINNT=0x0601 -fno-strict-aliasing \ |
| 82 | -o $@ $(SRC_C) $(VENDOR_C) $(WIN_LIBS) |
| 83 | |
| 84 | macos: $(SRC_C) $(HDR) $(UI_HDR) $(VENDOR_C) |
| 85 | @echo "==> Apple clang build" |
| 86 | $(CC) $(CFLAGS) -fno-strict-aliasing -o $(BIN) $(SRC_C) $(VENDOR_C) |
| 87 | |
| 88 | asan: $(BIN)-asan |
| 89 | $(BIN)-asan: $(SRC_C) $(HDR) $(UI_HDR) $(VENDOR_C) |
| 90 | @echo "==> ASan + UBSan + FORTIFY build" |
| 91 | $(CC) -O1 -g $(STD) $(WARN) $(INCLUDES) -D_FORTIFY_SOURCE=2 \ |
| 92 | -fsanitize=address,undefined -fno-omit-frame-pointer \ |
| 93 | -o $@ $(SRC_C) $(VENDOR_C) |
| 94 | |
| 95 | install: $(BIN) |
| 96 | PDIR="/workspace/.scorpiox/plugins"; [ -d /workspace ] || PDIR="$$HOME/.scorpiox/plugins"; \ |
| 97 | mkdir -p "$$PDIR" && cp $(BIN) "$$PDIR/$(BIN)" && chmod 0755 "$$PDIR/$(BIN)" && \ |
| 98 | echo "installed $$PDIR/$(BIN) (no restart needed: the node rescans plugins per request)" |
| 99 | |
| 100 | test: $(BIN) |
| 101 | sh tests/run.sh |
| 102 | |
| 103 | e2e: $(BIN) |
| 104 | python3 tests/e2e.py |
| 105 | |
| 106 | clean: |
| 107 | rm -f $(BIN) $(BIN).musl $(BIN).arm64 $(EXE) $(BIN)-asan |
| 108 | |
| 109 | help: |
| 110 | @sed -n '1,30p' Makefile |