-
Notifications
You must be signed in to change notification settings - Fork 0
/
Justfile
129 lines (103 loc) · 4.45 KB
/
Justfile
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
124
125
126
127
128
129
#mod gui "rustbee-gui"
#mod daemon "rustbee-daemon"
# Workaround because modules dont work as I would and the mods above were
# only for CLI calls at root. e.g. `just gui::build`
GUI := "just --justfile rustbee-gui/Justfile"
DAEMON := "just --justfile rustbee-daemon/Justfile"
export MSRV := "1.80"
export docker_base_pkgs := "(apt-get update && apt-get install -y libdbus-1-dev pkg-config) > /dev/null 2>&1"
log_path := `cat rustbee-common/src/constants.rs | grep "const LOG_PATH" | grep -oE '".*"' | sed s/\"//g`
socket_path := `cat rustbee-common/src/constants.rs | grep "const SOCKET_PATH" | grep -oE '".*"' | sed s/\"//g`
export purple := "\\e[35m"
export red := "\\e[31m"
export white := "\\e[0m"
alias ba := build-all
alias ia := install-all
alias help := _default
# Not actually called but when calling "just" it takes the first recipe
[doc]
_default:
@just -l --justfile {{justfile()}} --list-heading $'Available commands:\n' --unsorted
@build-all: build build-gui
@install-all: install install-gui
# CLI Build
@build:
cargo build --release
sudo setcap cap_dac_override,cap_dac_read_search+ep ./target/release/rustbee
echo -e "$purple[Rustbee CLI] Finished compiling !$white"
{{DAEMON}} build
@build-gui:
{{GUI}} build
{{DAEMON}} build
[private]
@build-daemon:
{{DAEMON}} build
# CLI Build
build-docker:
#!/usr/bin/env bash
if [[ -f ./target/release/rustbee && -f ./rustbee-daemon/target/release/rustbee-daemon ]]; then
echo -e "${red}Binaries are already built, you can run \`just install-cli\` to install rustbee CLI$white"
exit 1
fi
echo "Compiling Rustbee CLI & its daemon with docker... (feel free to make some coffe)"
docker run --rm --user root -v {{justfile_dir()}}:/usr/src/rustbee -w /usr/src/rustbee rust:{{MSRV}}-bullseye \
bash -c "{{docker_base_pkgs}} && cargo build --release && cd rustbee-daemon && cargo build --release"
sudo chown -R $(id -u):$(id -g) ./target
sudo chown -R $(id -u):$(id -g) ./rustbee-daemon/target
sudo setcap cap_dac_override,cap_dac_read_search+ep ./target/release/rustbee
sudo setcap cap_dac_override+ep ./rustbee-daemon/target/release/rustbee-daemon
echo -e "${purple}Done! You can now run \`just install-cli\` to install rustbee CLI$white"
build-gui-docker:
{{GUI}} build-docker
# Build C dynamic lib on rustbee-common/target/release/librustbee_common.so
@build-lib:
cd rustbee-common && \
cargo rustc --release --features ffi --crate-type=cdylib
@debug-gui:
{{GUI}} debug
@debug-gui-win dest_path:
{{GUI}} debug-win {{ dest_path }}
# Used for new releases, version is x.x.x without the 'v'
@push-ver version:
sed '0,/version = ".*"/ s//version = "{{ version }}"/' -i rustbee-common/Cargo.toml
git add rustbee-common/Cargo.toml
find . -name Cargo.lock -execdir cargo update rustbee-common \;
git add **/Cargo.lock
git commit -m "chore: Tag release v{{ version }}" # Cannot skip ci, it also skips the tag trigger
git push origin main
git tag -a v{{ version }} -m "Release v{{ version }}"
git push origin --tags
@build-win dest_path:
{{DAEMON}} build-win
cargo build --release --target x86_64-pc-windows-gnu
echo -e "$purple[Rustbee CLI] Finished compiling !$white"
cp \
target/x86_64-pc-windows-gnu/release/rustbee.exe \
rustbee-daemon/target/x86_64-pc-windows-gnu/release/rustbee-daemon.exe \
dist/install_win.bat \
{{ dest_path }}
install:
#!/usr/bin/env bash
if [[ ! -f ./target/release/rustbee || ! -f ./rustbee-daemon/target/release/rustbee-daemon ]]; then
echo -e "${red}Binaries are not built, you must run \`just build-cli\` first$white"
exit 1
fi
{{DAEMON}} install
sudo ln -sf $PWD/target/release/rustbee /bin/rustbee
echo -e "${purple}Rustbee CLI symlinked to /bin dir$white"
echo -e "${purple}Done! You can now use \`rustbee\` globally$white"
@install-gui:
{{DAEMON}} install
{{GUI}} install
# This avoids failing so it can be used even if GUI isn't installed for e.g.
[doc("Optional flag: --preserve-logs")]
[confirm("Are you sure you want to uninstall everything ? (y/N)")]
@uninstall *flag:
-cargo clean > /dev/null 2>&1
-sudo rm /bin/rustbee > /dev/null 2>&1
{{GUI}} uninstall
{{DAEMON}} uninstall
if {{ if flag == "--preserve-logs" { "true" } else { "false" } }}; then \
-sudo rm $log_path > /dev/null 2>&1; \
fi
echo -e "${purple}Rustbee binaries are successfully uninstalled$white"