-
Notifications
You must be signed in to change notification settings - Fork 12
/
justfile
142 lines (118 loc) · 4.49 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
130
131
132
133
134
135
136
137
138
139
140
141
142
set shell := ["bash", "-c"]
rootdir := justfile_directory()
xdg_data_dir := `echo "${XDG_DATA_HOME:-$HOME/.local/share}/pinnacle"`
root_xdg_data_dir := "/usr/share/pinnacle"
root_xdg_config_dir := "/etc/xdg/pinnacle"
lua_version := "5.4"
list:
@just --list --unsorted
# Install the configs, protobuf definitions, and the Lua library (requires Luarocks)
install: install-configs install-protos install-lua-lib install-snowcap
# Install the default Lua and Rust configs
install-configs:
#!/usr/bin/env bash
set -euxo pipefail
default_config_dir="{{xdg_data_dir}}/default_config"
default_lua_dir="${default_config_dir}/lua"
default_rust_dir="${default_config_dir}/rust"
rm -rf "${default_config_dir}"
mkdir -p "${default_config_dir}"
cp -r "{{rootdir}}/api/lua/examples/default" "${default_lua_dir}"
cp -LR "{{rootdir}}/api/rust/examples/default_config/for_copying" "${default_rust_dir}"
# Install the protobuf definitions (only needed for the Lua API)
install-protos:
#!/usr/bin/env bash
set -euxo pipefail
proto_dir="{{xdg_data_dir}}/protobuf"
rm -rf "${proto_dir}"
mkdir -p "{{xdg_data_dir}}"
cp -r "{{rootdir}}/api/protocol" "${proto_dir}"
# Install the Lua library (requires Luarocks)
install-lua-lib: gen-lua-pb-defs
#!/usr/bin/env bash
cd "{{rootdir}}/api/lua"
luarocks build --local https://raw.githubusercontent.com/pinnacle-comp/lua-grpc-client/main/lua-grpc-client-dev-1.rockspec
luarocks build --local --lua-version "{{lua_version}}"
# Remove installed configs and the Lua API (requires Luarocks)
clean: clean-snowcap
rm -rf "{{xdg_data_dir}}"
-luarocks remove --local pinnacle-api
-luarocks remove --local lua-grpc-client
# [root] Remove installed configs and the Lua API (requires Luarocks)
clean-root:
rm -rf "{{root_xdg_data_dir}}"
rm -rf "{{root_xdg_config_dir}}"
-luarocks remove pinnacle-api
# [root] Install the configs, protobuf definitions, and the Lua library (requires Luarocks)
install-root: install-configs-root install-protos-root install-lua-lib-root
# [root] Install the default Lua and Rust configs
install-configs-root:
#!/usr/bin/env bash
set -euxo pipefail
default_config_dir="{{root_xdg_config_dir}}/default_config"
default_lua_dir="${default_config_dir}/lua"
default_rust_dir="${default_config_dir}/rust"
rm -rf "${default_config_dir}"
mkdir -p "${default_config_dir}"
cp -r "{{rootdir}}/api/lua/examples/default" "${default_lua_dir}"
cp -LR "{{rootdir}}/api/rust/examples/default_config/for_copying" "${default_rust_dir}"
# [root] Install the protobuf definitions (only needed for the Lua API)
install-protos-root:
#!/usr/bin/env bash
set -euxo pipefail
proto_dir="{{root_xdg_data_dir}}/protobuf"
rm -rf "${proto_dir}"
mkdir -p "{{root_xdg_data_dir}}"
cp -r "{{rootdir}}/api/protocol" "${proto_dir}"
# [root] Install the Lua library (requires Luarocks)
install-lua-lib-root:
#!/usr/bin/env bash
set -euxo pipefail
cd "{{rootdir}}/api/lua"
luarocks make --lua-version "{{lua_version}}"
# Run `cargo build`
build *args: gen-lua-pb-defs
cargo build {{args}}
# Generate the protobuf definitions Lua file
gen-lua-pb-defs:
#!/usr/bin/env bash
set -euxo pipefail
cargo build --package lua-build
./target/debug/lua-build ./api/protocol > "./api/lua/pinnacle/grpc/defs.lua"
# Run `cargo run`
run *args: gen-lua-pb-defs
cargo run {{args}}
# Run `cargo test`
test *args: gen-lua-pb-defs
cargo test --no-default-features {{args}}
compile-wlcs:
#!/usr/bin/env bash
set -euxo pipefail
WLCS_SHA=26c5a8cfef265b4ae021adebfec90d758c08792e
cd "{{rootdir}}"
if [ -f "./wlcs/wlcs" ] && [ "$(cd wlcs; git rev-parse HEAD)" = "${WLCS_SHA}" ] ; then
echo "WLCS commit 26c5a8c is already compiled"
else
echo "Compiling WLCS"
git clone https://github.com/canonical/wlcs
cd wlcs || exit
# checkout a specific revision
git reset --hard "${WLCS_SHA}"
cmake -DWLCS_BUILD_ASAN=False -DWLCS_BUILD_TSAN=False -DWLCS_BUILD_UBSAN=False -DCMAKE_EXPORT_COMPILE_COMMANDS=1 .
make
fi
wlcs *args: compile-wlcs
#!/usr/bin/env bash
set -euxo pipefail
cargo build -p wlcs_pinnacle
RUST_BACKTRACE=1 ./wlcs/wlcs target/debug/libwlcs_pinnacle.so {{args}}
install-snowcap:
#!/usr/bin/env bash
set -euxo pipefail
cd "{{rootdir}}/snowcap"
just install
clean-snowcap:
#!/usr/bin/env bash
set -euxo pipefail
cd "{{rootdir}}/snowcap"
just clean