PREFIX ?= /usr/local
PLASMOID_ID ?= io.github.akitaonrails.ai-usagebar
PLASMOID_DIR = $(abspath $(DESTDIR)$(PREFIX))/share/plasma/plasmoids/$(PLASMOID_ID)
.PHONY: build install uninstall install-plasmoid uninstall-plasmoid \
test desktop-test plugin-test qml-lint qml-test mjs-probe smoke clippy fmt clean
build:
cargo build --release
install: build
install -Dm755 -- target/release/ai-usagebar "$(DESTDIR)$(PREFIX)/bin/ai-usagebar"
install -Dm755 -- target/release/ai-usagebar-tui "$(DESTDIR)$(PREFIX)/bin/ai-usagebar-tui"
install -Dm644 -- config.example.toml "$(DESTDIR)$(PREFIX)/share/ai-usagebar/config.example.toml"
install -Dm644 -- README.md "$(DESTDIR)$(PREFIX)/share/doc/ai-usagebar/README.md"
install -Dm644 -- LICENSE "$(DESTDIR)$(PREFIX)/share/licenses/ai-usagebar/LICENSE"
uninstall:
rm -f -- "$(DESTDIR)$(PREFIX)/bin/ai-usagebar"
rm -f -- "$(DESTDIR)$(PREFIX)/bin/ai-usagebar-tui"
rm -rf -- "$(DESTDIR)$(PREFIX)/share/ai-usagebar"
rm -rf -- "$(DESTDIR)$(PREFIX)/share/doc/ai-usagebar"
rm -rf -- "$(DESTDIR)$(PREFIX)/share/licenses/ai-usagebar"
install-plasmoid:
cd kde-plasmoid/package && find metadata.json contents -type f \
-exec install -Dm644 -- {} "$(PLASMOID_DIR)/{}" \;
uninstall-plasmoid:
rm -rf -- "$(PLASMOID_DIR)"
test:
cargo test
$(MAKE) desktop-test
$(MAKE) plugin-test
desktop-test:
node gnome-extension/marker-logic.test.mjs
node kde-plasmoid/plasmoid-logic.test.mjs
plugin-test:
node omarchy/model.test.mjs
QT6_BINDIR := $(shell command -v qtpaths6 >/dev/null 2>&1 && qtpaths6 --binaries-dir 2>/dev/null)
PATH_QMLLINT6 := $(shell p=$$(command -v qmllint 2>/dev/null); \
[ -n "$$p" ] && "$$p" --version 2>&1 | grep -Eq '(^|[[:space:]])6\.' && printf '%s' "$$p")
QT6_TOOL_DIRS := $(QT6_BINDIR) /usr/lib/qt6/bin /usr/lib64/qt6/bin $(dir $(PATH_QMLLINT6))
QMLLINT ?= $(firstword $(foreach d,$(QT6_TOOL_DIRS),$(wildcard $(d)/qmllint)) \
$(shell command -v qmllint6 2>/dev/null))
qml-lint:
@test -x "$(QMLLINT)" || { echo "Qt 6 qmllint not found" >&2; exit 1; }
@"$(QMLLINT)" --version 2>&1 | grep -Eq '(^|[[:space:]])6\.' || \
{ echo "$(QMLLINT) is not Qt 6 qmllint" >&2; exit 1; }
"$(QMLLINT)" --unqualified disable \
kde-plasmoid/package/contents/config/*.qml \
kde-plasmoid/package/contents/ui/*.qml
QMLTESTRUNNER ?= $(firstword $(foreach d,$(QT6_TOOL_DIRS),$(wildcard $(d)/qmltestrunner)) \
$(shell command -v qmltestrunner6 2>/dev/null))
qml-test:
@test -x "$(QMLTESTRUNNER)" || { echo "Qt 6 qmltestrunner not found" >&2; exit 1; }
QT_QPA_PLATFORM=offscreen "$(QMLTESTRUNNER)" -input kde-plasmoid/qmltests
mjs-probe:
@out=$$(QT_LOGGING_RULES="qml.debug=true" timeout 15 plasmoidviewer \
-a kde-plasmoid/probe -l topedge -f horizontal 2>&1 \
| grep -E "^qml: (ok|FAIL)|MJS PROBE" || true); \
printf '%s\n' "$$out"; \
case "$$out" in *FAIL*) \
echo "✗ mjs-probe: a check failed under the applet host"; exit 1 ;; esac; \
case "$$out" in *"MJS PROBE OK"*) ;; *) \
echo "✗ mjs-probe: no verdict — needs plasma-sdk and a running Plasma session"; \
exit 1 ;; esac; \
case "$$out" in *"MJS PROBE EXEC DONE"*) ;; *) \
echo "✗ mjs-probe: the executable-engine check never reported back"; exit 1 ;; esac; \
echo "✓ mjs-probe: module loads and the timeout wrapper executes under V4"
smoke:
@echo "Running live API smoke tests (requires creds in shell env)..."
cargo test --test live -- --ignored --nocapture
clippy:
cargo clippy --all-targets -- -D warnings
fmt:
cargo fmt
clean:
cargo clean