summaryrefslogtreecommitdiff
path: root/Justfile
blob: 73d189d6247b3bd7fc06d97cab2bbbe4cdee899e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# Camper Widget Build Configuration

set shell := ["/usr/bin/bash", "-cu"]

# Required tools (validated at parse time)
_rustc := require("rustc")
_cargo := require("cargo")
_kpackagetool6 := require("kpackagetool6")
_dbus_daemon := require("dbus-daemon")

# Help command
help:
    @echo "This justfile supports the following targets:"
    @echo "    - build           - Build service (release)"
    @echo "    - install         - Install widget (kpackagetool6) + service"
    @echo "    - install-widget  - Install/update widget via kpackagetool6"
    @echo "    - install-service - Build and install systemd service"
    @echo "    - uninstall       - Uninstall widget + clean old artifacts"
    @echo "    - run             - Run applet in plasmoidviewer"
    @echo "    - run-service     - Run service (release)"
    @echo "    - fmt             - Format Rust code (service)"
    @echo "    - check           - Check Rust code (format, clippy, check)"
    @echo "    - test            - Run Rust tests (service)"
    @echo "    - verify          - Run check + build"
    @echo "    - build-service   - Build camper-widget-refresh (Release)"
    @echo "    - check-service   - Check service only"
    @echo "    - check-deps      - Print versions of required tools"
    @echo "    - ci              - Full CI pipeline (check + test)"
    @echo "    - ci-quick        - Quick CI (check only, no build/test)"
    @echo "    - clean           - Delete build artifacts"
    @echo "    - help            - Print help"
    @echo

# Build (service only — widget is pure QML, no compilation needed)
build: build-service

# Install widget via kpackagetool6 + service via cargo
install: install-widget install-service

# Install/update widget KPackage
install-widget:
    kpackagetool6 -t Plasma/Applet -u package/ 2>/dev/null || kpackagetool6 -t Plasma/Applet -i package/

# Uninstall widget + clean old compiled plugin artifacts
uninstall:
    -kpackagetool6 -t Plasma/Applet -r craftknight.camper_widget
    rm -f ~/.local/lib/qt6/plugins/plasma/applets/craftknight.camper_widget.so
    rm -rf ~/.local/share/plasma/plasmoids/craftknight.camper_widget
    rm -rf ~/.local/lib/qt6/qml/craftknight/camper_widget

# Run applet in plasmoidviewer
run:
    plasmoidviewer -a craftknight.camper_widget

# Service commands
[working-directory: 'service']
build-service:
    cargo build --release

[working-directory: 'service']
run-service:
    cargo run --release

[working-directory: 'service']
install-service: build-service
        @echo "Installing camper-widget-refresh..."
        mkdir -p ~/.config/systemd/user
        mkdir -p ~/.local/bin
        cp config/camper-widget-refresh.service ~/.config/systemd/user/
        systemctl --user daemon-reload
        systemctl stop --user camper-widget-refresh
        cp target/release/camper-widget-refresh ~/.local/bin/camper-widget-refresh
        chmod +x ~/.local/bin/camper-widget-refresh
        systemctl start --user camper-widget-refresh
        @echo "Installation complete!"
        @echo "To enable: systemctl --user enable camper-widget-refresh"
        @echo "To start:  systemctl --user start camper-widget-refresh"

# Rust commands (service only)
[working-directory: 'service']
fmt:
    cargo fmt --all

[working-directory: 'service']
check:
    cargo fmt --all -- --check
    cargo clippy --all-targets --all-features -- -D warnings
    cargo check --all-targets

check-service: check

[working-directory: 'service']
test:
    cargo test

# Clean build artifacts
clean:
    rm -rf service/target

# Print versions of all required tools
[group: 'ci']
check-deps:
    @echo "Required tools:"
    @echo "  rustc:          $(rustc --version)"
    @echo "  cargo:          $(cargo --version)"
    @echo "  kpackagetool6:  $(kpackagetool6 --version)"
    @echo "  dbus-daemon:    $(dbus-daemon --version | head -1)"
    @echo "  just:           $(just --version)"

# Full CI pipeline: deps → lint/format → all tests
[group: 'ci']
ci: check-deps check test
    @echo ""
    @echo "CI pipeline passed."

# Quick CI: deps + lint/format only (no build/test)
[group: 'ci']
ci-quick: check-deps check
    @echo ""
    @echo "Quick CI passed."

# Combined verify command
verify: check build