scorpiox-bot-plugin-time
←Makefiletext
82 lines · 2 KBHEADBlameDownload
1# plugin_time - SCORPIOX BOT open-source world-time 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# The IANA timezone table lives in src/tzdata.h, generated from a compiled tz
9# database by tools/gen_tzdata.py. Regenerate it only when you mean to move to
10# a newer tzdata release, and re-run the suite: every epoch in the tests is
11# absolute, so a tzdata change that moves a zone shows up as a failure rather
12# than as a silently different answer.
13#
14# Targets:
15# make native build -> ./plugin_time
16# make musl static musl x86_64 -> ./plugin_time.musl
17# make arm64 static arm64 musl (aarch64 cross) -> ./plugin_time.arm64
18# make win64 MinGW-w64 static -> ./plugin_time.exe
19# make macos Apple clang -> ./plugin_time (run this on macOS)
20# make asan ASan + UBSan + _FORTIFY_SOURCE=2 -> ./plugin_time.asan
21# make tzdata regenerate src/tzdata.h from /usr/share/zoneinfo
22# make ui regenerate src/ui_html.h from src/ui.html
23# make test run tests/run.sh
24# make clean
25
26CC ?= cc
27CFLAGS ?= -O2 -std=c99 -Wall -Wextra -pedantic -Wno-overlength-strings
28CPPFLAGS = -I src -I vendor
29SRCS = src/plugin_time.c src/timeutil.c src/tz.c vendor/yyjson.c
30HDRS = src/plugintime.h src/tz.h src/tzdata.h src/ui_html.h src/bot_theme_plugin.h
31
32MUSL_CC ?= musl-gcc
33ARM64_CC ?= aarch64-linux-gnu-gcc
34WIN64_CC ?= x86_64-w64-mingw32-gcc
35
36all: plugin_time
37
38plugin_time: $(SRCS) $(HDRS)
39 $(CC) $(CFLAGS) $(CPPFLAGS) $(SRCS) -o $@
40
41musl: plugin_time.musl
42plugin_time.musl: $(SRCS) $(HDRS)
43 $(MUSL_CC) $(CFLAGS) -static $(CPPFLAGS) $(SRCS) -o $@
44
45arm64: plugin_time.arm64
46plugin_time.arm64: $(SRCS) $(HDRS)
47 $(ARM64_CC) $(CFLAGS) -static $(CPPFLAGS) $(SRCS) -o $@
48
49win64: plugin_time.exe
50plugin_time.exe: $(SRCS) $(HDRS)
51 $(WIN64_CC) $(CFLAGS) -static -D_WIN32_WINNT=0x0601 $(CPPFLAGS) $(SRCS) -o $@
52
53macos: $(SRCS) $(HDRS)
54 clang $(CFLAGS) $(CPPFLAGS) $(SRCS) -o plugin_time
55
56asan: plugin_time.asan
57plugin_time.asan: $(SRCS) $(HDRS)
58 $(CC) -O1 -g -std=c99 -Wall -Wextra -D_FORTIFY_SOURCE=2 \
59 -fsanitize=address,undefined -fno-omit-frame-pointer \
60 $(CPPFLAGS) $(SRCS) -o $@
61
62tzdata:
63 python3 tools/gen_tzdata.py
64
65ui:
66 python3 tools/gen_ui.py
67
68install: plugin_time
69 PDIR="/workspace/.scorpiox/plugins"; [ -d /workspace ] || PDIR="$$HOME/.scorpiox/plugins"; \
70 mkdir -p "$$PDIR" && cp plugin_time "$$PDIR/plugin_time" && chmod 0755 "$$PDIR/plugin_time" && \
71 echo "installed $$PDIR/plugin_time (no restart needed: the node rescans plugins per request)"
72
73tzdiff: plugin_time
74 python3 tests/tz_diff.py
75
76test: plugin_time
77 sh tests/run.sh
78
79clean:
80 rm -f plugin_time plugin_time.musl plugin_time.arm64 plugin_time.exe plugin_time.asan
81
82.PHONY: all musl arm64 win64 macos asan tzdata ui install test tzdiff clean