| 1 | # plugin_filesystem - SCORPIOX BOT open-source allowlisted filesystem MCP connector |
| 2 | # |
| 3 | # The only non-stdlib dependency is the vendored yyjson JSON parser under |
| 4 | # vendor/yyjson (MIT, upstream yyjson/yyjson); it is compiled into the binary, |
| 5 | # so every artefact stays a standalone executable with zero shared-library |
| 6 | # requirements on the node. |
| 7 | # |
| 8 | # Targets: |
| 9 | # make native build -> ./plugin_filesystem |
| 10 | # make musl static musl x86_64 -> ./plugin_filesystem.musl |
| 11 | # make arm64 static arm64 musl (aarch64 cross) -> ./plugin_filesystem.arm64 |
| 12 | # make win64 MinGW-w64 static -> ./plugin_filesystem.exe |
| 13 | # make macos Apple clang -> ./plugin_filesystem (run this on macOS) |
| 14 | # make asan ASan + UBSan build (tests/run.sh drives the whole tool set through it) |
| 15 | # make fortify -D_FORTIFY_SOURCE=2 build |
| 16 | # make ui regenerate src/ui_html.h from src/ui.html |
| 17 | # make test build + run tests/run.sh |
| 18 | # make e2e build + run tests/e2e.py (Playwright) |
| 19 | # make clean |
| 20 | # |
| 21 | # The multi-arch dist publish lives in scorpiox-cli-botplugin (it owns the |
| 22 | # toolchains, the dist upload and the plugingit mirror) - see release-dist.sh. |
| 23 | |
| 24 | CC ?= cc |
| 25 | CFLAGS ?= -O2 -std=c99 -Wall -Wextra -pedantic -Wno-overlength-strings -I src -I vendor/yyjson |
| 26 | MUSL_CC ?= musl-gcc |
| 27 | MUSL_CFLAGS := -O2 -std=c99 -Wall -Wextra -Wno-overlength-strings -I src -I vendor/yyjson -static |
| 28 | ARM_CC ?= aarch64-linux-gnu-gcc |
| 29 | ARM_CFLAGS := -O2 -std=c99 -Wall -Wextra -Wno-overlength-strings -I src -I vendor/yyjson -static |
| 30 | WIN_CC ?= x86_64-w64-mingw32-gcc |
| 31 | WIN_CFLAGS := -O2 -std=c99 -Wall -Wextra -Wno-overlength-strings -I src -I vendor/yyjson -static |
| 32 | SRC := src/plugin_filesystem.c |
| 33 | VENDOR := vendor/yyjson/yyjson.c |
| 34 | UI_SRC := src/ui.html |
| 35 | UI_HDR := src/ui_html.h |
| 36 | BIN := plugin_filesystem |
| 37 | EXE := plugin_filesystem.exe |
| 38 | |
| 39 | .PHONY: all native musl arm64 win64 macos asan fortify ui test e2e clean help |
| 40 | |
| 41 | all: native |
| 42 | |
| 43 | $(UI_HDR): $(UI_SRC) tools/gen_ui.py |
| 44 | @echo "==> regenerating $(UI_HDR)" |
| 45 | python3 tools/gen_ui.py |
| 46 | |
| 47 | ui: $(UI_HDR) |
| 48 | |
| 49 | native: $(BIN) |
| 50 | |
| 51 | $(BIN): $(SRC) $(UI_HDR) $(VENDOR) |
| 52 | @echo "==> native build ($(CC))" |
| 53 | $(CC) $(CFLAGS) -o $(BIN) $(SRC) $(VENDOR) |
| 54 | |
| 55 | # Static musl build - the universal Linux artifact (Alpine, Debian, Arch, Omarchy) |
| 56 | musl: $(SRC) $(UI_HDR) $(VENDOR) |
| 57 | @echo "==> static musl build ($(MUSL_CC))" |
| 58 | $(MUSL_CC) $(MUSL_CFLAGS) -o $(BIN).musl $(SRC) $(VENDOR) |
| 59 | |
| 60 | # Static aarch64 build - Raspberry Pi 5 / ARM64 servers |
| 61 | arm64: $(SRC) $(UI_HDR) $(VENDOR) |
| 62 | @echo "==> static arm64 build ($(ARM_CC))" |
| 63 | $(ARM_CC) $(ARM_CFLAGS) -o $(BIN).arm64 $(SRC) $(VENDOR) |
| 64 | |
| 65 | # Native Win64 static PE - runs on any Windows 10/11 x64 node |
| 66 | win64: $(SRC) $(UI_HDR) $(VENDOR) |
| 67 | @echo "==> MinGW-w64 build ($(WIN_CC))" |
| 68 | $(WIN_CC) $(WIN_CFLAGS) -o $(EXE) $(SRC) $(VENDOR) |
| 69 | |
| 70 | # Apple clang build (run this on macOS) |
| 71 | macos: $(SRC) $(UI_HDR) $(VENDOR) |
| 72 | @echo "==> Apple clang build" |
| 73 | $(CC) $(CFLAGS) -o $(BIN) $(SRC) $(VENDOR) |
| 74 | |
| 75 | # Sanitizer build - tests/run.sh exercises every tool through this binary |
| 76 | asan: $(SRC) $(UI_HDR) $(VENDOR) |
| 77 | @echo "==> ASan + UBSan build" |
| 78 | $(CC) -O1 -g -std=c99 -fsanitize=address,undefined -fno-omit-frame-pointer \ |
| 79 | -I src -I vendor/yyjson -o $(BIN)-asan $(SRC) $(VENDOR) |
| 80 | |
| 81 | fortify: $(SRC) $(UI_HDR) $(VENDOR) |
| 82 | @echo "==> _FORTIFY_SOURCE=2 build" |
| 83 | $(CC) -O2 -D_FORTIFY_SOURCE=2 -std=c99 -Wall -Wextra -Wno-overlength-strings \ |
| 84 | -I src -I vendor/yyjson -o $(BIN)-fortify $(SRC) $(VENDOR) |
| 85 | |
| 86 | test: native |
| 87 | @sh tests/run.sh |
| 88 | |
| 89 | e2e: native |
| 90 | @python3 tests/e2e.py |
| 91 | |
| 92 | clean: |
| 93 | rm -f $(BIN) $(EXE) $(BIN).musl $(BIN).arm64 $(BIN)-asan $(BIN)-fortify |
| 94 | rm -rf bin |
| 95 | |
| 96 | help: |
| 97 | @echo "make | make musl | make arm64 | make win64 | make macos | make asan | make fortify | make ui | make test | make e2e | make clean" |