forked from noctalia-dev/noctalia
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
103 lines (88 loc) · 3.65 KB
/
Copy pathjustfile
File metadata and controls
103 lines (88 loc) · 3.65 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
set positional-arguments
mode := "debug"
build-dir := "build-" + mode
prefix := "/usr/local"
cpp-std := "c++23"
default:
@just --list
configure m=mode install_prefix=prefix:
#!/usr/bin/env bash
set -euo pipefail
args=(--buildtype={{ if m == "release" { "release" } else { "debug" } }} -Dcpp_std={{cpp-std}} -Dtests=auto)
[[ "{{m}}" == "release" ]] && args+=(-Db_lto=true)
[[ "{{m}}" == "asan" ]] && args+=(-Db_sanitize=address,undefined)
if [[ -d "build-{{m}}" ]]; then
meson setup "build-{{m}}" "${args[@]}" --prefix "{{install_prefix}}" --reconfigure
else
meson setup "build-{{m}}" "${args[@]}" --prefix "{{install_prefix}}"
fi
ln -sfn "build-{{m}}/compile_commands.json" compile_commands.json
build m=mode: (_ensure-configured m)
meson compile -C build-{{m}} noctalia
_ensure-configured m=mode:
#!/usr/bin/env bash
set -euo pipefail
if [[ ! -f "build-{{m}}/build.ninja" ]]; then
just configure {{m}}
exit 0
fi
configure_output="$(meson configure "build-{{m}}")"
current_cpp_std="$(awk '$1 == "cpp_std" { print $2; found=1 } END { if (!found) exit 1 }' <<<"$configure_output")"
current_tests="$(awk '$1 == "tests" { print $2; found=1 } END { if (!found) exit 1 }' <<<"$configure_output")"
args=()
[[ "$current_cpp_std" != "{{cpp-std}}" ]] && args+=(-Dcpp_std={{cpp-std}})
[[ "$current_tests" != "auto" ]] && args+=(-Dtests=auto)
if (( ${#args[@]} > 0 )); then
meson configure "build-{{m}}" "${args[@]}"
fi
run m=mode: (build m)
./build-{{m}}/noctalia
# Build and run the unit tests, enabling their targets when auto mode omits them.
test m=mode *args: (_ensure-configured m)
#!/usr/bin/env bash
set -euo pipefail
if [[ "{{m}}" == "release" || "{{m}}" == "asan" ]]; then
meson setup "build-{{m}}" -Dtests=enabled --reconfigure >/dev/null
fi
meson test -C build-{{m}} {{args}}
install m:
#!/usr/bin/env bash
set -euo pipefail
if [[ ! -x "build-{{m}}/noctalia" ]]; then
echo "error: build-{{m}}/noctalia is missing; run 'just build {{m}}' before installing" >&2
exit 1
fi
meson install --no-rebuild -C build-{{m}}
uninstall m:
#!/usr/bin/env bash
set -euo pipefail
if [[ ! -f "build-{{m}}/build.ninja" ]]; then
echo "error: build-{{m}} is missing or was not configured with the Ninja backend; nothing to uninstall" >&2
exit 1
fi
ninja -C build-{{m}} uninstall
format:
find src tests \( -name '*.cpp' -o -name '*.h' \) -print0 | xargs -0 clang-format -i
find src tests \( -name '*.cpp' -o -name '*.h' \) -print0 | xargs -0 grep -ZlP '\s+$' | xargs -0 -r sed -i 's/[[:space:]]*$//'
_clang_tidy m=mode *args:
#!/usr/bin/env bash
set -euo pipefail
src_root="$(realpath src)"
# compile_commands.json stores build-relative paths, so clang-tidy emits header
# diagnostics as ../src/...; the header-filter must match that form (an absolute
# ^${src_root} anchor never matches, silently dropping every header diagnostic).
# ../src/ also excludes vendored third_party/*/src/* headers.
run-clang-tidy -quiet -use-color -p "build-{{m}}" -j "$(nproc)" -header-filter='\.\./src/.*' {{args}} "^${src_root}/.*"
lint m=mode: (_ensure-configured m)
just _clang_tidy {{m}} '-warnings-as-errors=*'
fix m=mode: (_ensure-configured m)
just _clang_tidy {{m}} -fix
just format
clean m=mode:
#!/usr/bin/env bash
set -euo pipefail
if [[ -L compile_commands.json && "$(readlink compile_commands.json)" == "build-{{m}}/compile_commands.json" ]]; then
rm -f compile_commands.json
fi
rm -rf build-{{m}}
rebuild m=mode: (clean m) (build m)