-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
115 lines (96 loc) · 4.56 KB
/
Copy pathjustfile
File metadata and controls
115 lines (96 loc) · 4.56 KB
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
# Treasure Panel - Build and install recipes
#
# Usage:
# just build - Build everything (main binary + plugin)
# just install - Install plugin to XFCE panel (system-wide, requires sudo)
# just uninstall - Remove plugin from XFCE panel
# just run - Run the panel standalone
# just clean - Clean build artifacts
#
# The plugin .so embeds an absolute path to the launcher script (see PROJECT_ROOT).
# That script in turn execs the treasure-panel binary out of the same checkout's
# target dir. This means: build & install from the directory you intend to keep
# the source tree in. Move the source tree -> rerun `just build install`.
set shell := ["bash", "-c"]
# Resolve at recipe-time so we don't bake any one developer's $HOME into the file.
PROJECT_ROOT := justfile_directory()
# Where XFCE looks for panel plugin shared libraries / desktop manifests.
plugin_dir := "/usr/lib/xfce4/panel/plugins"
desktop_dir := "/usr/share/xfce4/panel/plugins"
# Optional: where `just link` drops the user-facing launcher symlink.
# Override on the CLI: `just bin_dir=$HOME/.local/bin link`
bin_dir := env_var_or_default("TREASURE_BIN_DIR", env_var('HOME') + "/.local/bin")
# Default recipe
default: build
# Build everything
build: build-main build-plugin
# Build main GTK4 binary (writes a launcher shim that knows where this checkout lives)
build-main:
cargo build
@echo '#!/usr/bin/env bash' > target/treasure-panel-launch
@echo 'exec {{PROJECT_ROOT}}/target/debug/treasure-panel --run-nu "$$@"' >> target/treasure-panel-launch
chmod +x target/treasure-panel-launch
@echo "Built: target/debug/treasure-panel"
# Build main GTK4 binary in release mode
build-main-release:
cargo build --release
@echo '#!/usr/bin/env bash' > target/treasure-panel-launch
@echo 'exec {{PROJECT_ROOT}}/target/release/treasure-panel --run-nu "$$@"' >> target/treasure-panel-launch
chmod +x target/treasure-panel-launch
@echo "Built: target/release/treasure-panel"
# Build XFCE panel plugin (the GTK3 .so loaded by xfce4-panel)
build-plugin:
cd plugin && TREASURE_PANEL_BIN={{PROJECT_ROOT}}/target/treasure-panel-launch cargo build
mkdir -p target/debug
gcc -Wall -shared -o target/debug/libtreasure-panel.so -fPIC plugin/plugin.c \
-Wl,--whole-archive plugin/target/debug/libtreasurepanelplugin.a -Wl,--no-whole-archive \
$(pkg-config --cflags --libs libxfce4panel-2.0 gtk+-3.0)
cp target/debug/libtreasure-panel.so plugin/libtreasure-panel.so
@echo "Built: plugin/libtreasure-panel.so"
# Build XFCE panel plugin in release mode
build-plugin-release:
cd plugin && TREASURE_PANEL_BIN={{PROJECT_ROOT}}/target/treasure-panel-launch cargo build --release
mkdir -p target/release
gcc -Wall -shared -O2 -o target/release/libtreasure-panel.so -fPIC plugin/plugin.c \
-Wl,--whole-archive plugin/target/release/libtreasurepanelplugin.a -Wl,--no-whole-archive \
$(pkg-config --cflags --libs libxfce4panel-2.0 gtk+-3.0)
cp target/release/libtreasure-panel.so plugin/libtreasure-panel.so
@echo "Built: plugin/libtreasure-panel.so"
# Spaceship panel-plugin contract: produce target/debug/<library>.
link-debug: build-main build-plugin
# Spaceship panel-plugin contract: produce target/release/<library>.
link-release: build-main-release build-plugin-release
# Install plugin to XFCE (requires sudo)
install: build
sudo cp plugin/libtreasure-panel.so {{plugin_dir}}/
sudo cp plugin/treasure-panel.desktop {{desktop_dir}}/
sudo chmod 644 {{desktop_dir}}/treasure-panel.desktop
xfce4-panel -r
@echo ""
@echo "Plugin installed."
@echo " Add 'Treasure Panel' via: Panel Preferences -> Items -> Add"
# Uninstall plugin
uninstall:
sudo rm -f {{plugin_dir}}/libtreasure-panel.so
sudo rm -f {{desktop_dir}}/treasure-panel.desktop
@echo "Plugin uninstalled."
# Run standalone (for testing)
run:
./target/release/treasure-panel --run-nu
# Run with position (for testing anchor behavior)
run-at x y anchor="top":
./target/release/treasure-panel --run-nu --pos-x {{x}} --pos-y {{y}} --anchor {{anchor}}
# Clean build artifacts
clean:
cargo clean
cd plugin && cargo clean
rm -f plugin/libtreasure-panel.so
# Rebuild from scratch
rebuild: clean build
# Drop a launcher into $bin_dir (default ~/.local/bin) that points at this checkout.
link:
mkdir -p {{bin_dir}}
@echo '#!/usr/bin/env bash' > {{bin_dir}}/treasure-panel
@echo 'exec {{PROJECT_ROOT}}/target/treasure-panel-launch "$$@"' >> {{bin_dir}}/treasure-panel
chmod +x {{bin_dir}}/treasure-panel
@echo "Wrote {{bin_dir}}/treasure-panel"