2024-04-23 18:01:33 +02:00
|
|
|
set shell := ["bash", "-c"]
|
|
|
|
|
|
|
|
rootdir := justfile_directory()
|
2024-04-24 00:01:44 +02:00
|
|
|
xdg_data_dir := `echo "${XDG_DATA_HOME:-$HOME/.local/share}/pinnacle"`
|
2024-04-23 23:16:54 +02:00
|
|
|
root_xdg_data_dir := "/usr/share/pinnacle"
|
|
|
|
root_xdg_config_dir := "/etc/xdg/pinnacle"
|
2024-04-23 18:01:33 +02:00
|
|
|
|
2024-04-25 03:01:04 +02:00
|
|
|
lua_version := "5.4"
|
|
|
|
|
2024-04-23 18:01:33 +02:00
|
|
|
list:
|
|
|
|
@just --list --unsorted
|
|
|
|
|
|
|
|
# Install the configs, protobuf definitions, and the Lua library (requires Luarocks)
|
2024-06-17 23:27:02 +02:00
|
|
|
install: install-configs install-protos install-lua-lib install-snowcap
|
2024-04-23 18:01:33 +02:00
|
|
|
|
|
|
|
# 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}"
|
2024-04-23 23:16:54 +02:00
|
|
|
mkdir -p "${default_config_dir}"
|
2024-04-23 18:01:33 +02:00
|
|
|
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}"
|
2024-04-24 00:01:44 +02:00
|
|
|
mkdir -p "{{xdg_data_dir}}"
|
2024-04-23 18:01:33 +02:00
|
|
|
cp -r "{{rootdir}}/api/protocol" "${proto_dir}"
|
|
|
|
|
|
|
|
# Install the Lua library (requires Luarocks)
|
|
|
|
install-lua-lib:
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
cd "{{rootdir}}/api/lua"
|
2024-04-25 03:01:04 +02:00
|
|
|
luarocks make --local --lua-version "{{lua_version}}"
|
2024-04-23 18:01:33 +02:00
|
|
|
|
2024-04-23 23:16:54 +02:00
|
|
|
# Remove installed configs and the Lua API (requires Luarocks)
|
2024-06-17 23:27:02 +02:00
|
|
|
clean: clean-snowcap
|
2024-04-23 23:16:54 +02:00
|
|
|
rm -rf "{{xdg_data_dir}}"
|
|
|
|
-luarocks remove --local pinnacle-api
|
|
|
|
|
|
|
|
# [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}"
|
2024-04-24 00:01:44 +02:00
|
|
|
mkdir -p "{{root_xdg_data_dir}}"
|
2024-04-23 23:16:54 +02:00
|
|
|
cp -r "{{rootdir}}/api/protocol" "${proto_dir}"
|
|
|
|
|
|
|
|
# [root] Install the Lua library (requires Luarocks)
|
|
|
|
install-lua-lib-root:
|
|
|
|
#!/usr/bin/env bash
|
2024-04-27 07:29:27 +02:00
|
|
|
set -euxo pipefail
|
2024-04-23 23:16:54 +02:00
|
|
|
cd "{{rootdir}}/api/lua"
|
2024-04-25 03:01:04 +02:00
|
|
|
luarocks make --lua-version "{{lua_version}}"
|
2024-04-23 23:16:54 +02:00
|
|
|
|
|
|
|
# Run `cargo build`
|
|
|
|
build *args:
|
2024-04-23 18:01:33 +02:00
|
|
|
cargo build {{args}}
|
|
|
|
|
2024-04-23 23:16:54 +02:00
|
|
|
# Run `cargo run`
|
|
|
|
run *args:
|
2024-04-23 18:01:33 +02:00
|
|
|
cargo run {{args}}
|
|
|
|
|
2024-04-23 23:16:54 +02:00
|
|
|
# Run `cargo test`
|
|
|
|
test *args:
|
2024-04-23 18:01:33 +02:00
|
|
|
cargo test {{args}}
|
2024-04-27 07:29:27 +02:00
|
|
|
|
|
|
|
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
|
2024-05-01 21:47:57 +02:00
|
|
|
RUST_BACKTRACE=1 ./wlcs/wlcs target/debug/libwlcs_pinnacle.so {{args}}
|
2024-06-17 23:27:02 +02:00
|
|
|
|
|
|
|
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
|