forked from noctalia-dev/umbriel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
133 lines (112 loc) · 4.4 KB
/
Copy pathjustfile
File metadata and controls
133 lines (112 loc) · 4.4 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
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=(-Dcpp_std={{cpp-std}} --prefix "{{install_prefix}}")
case "{{m}}" in
release)
args+=(--buildtype=release -Db_lto=true)
;;
asan)
args+=(--buildtype=debug -Db_sanitize=address)
;;
debug|*)
args+=(--buildtype=debug)
;;
esac
if [[ -d "build-{{m}}" ]]; then
meson setup "build-{{m}}" "${args[@]}" --reconfigure
else
meson setup "build-{{m}}" "${args[@]}"
fi
ln -sfn "build-{{m}}/compile_commands.json" compile_commands.json
_ensure-configured m=mode:
#!/usr/bin/env bash
set -euo pipefail
if [[ ! -f "build-{{m}}/build.ninja" ]]; then
just configure {{m}}
fi
build m=mode: (_ensure-configured m)
meson compile -C build-{{m}} umbriel
debug: (build "debug")
asan: (build "asan")
release: (build "release")
install: (build "release")
meson install -C build-release --no-rebuild
uninstall:
sudo ninja -C build-release uninstall
run m=mode startup="": (build m)
#!/usr/bin/env bash
set -euo pipefail
if [[ "{{m}}" == "asan" ]]; then
export ASAN_OPTIONS="${ASAN_OPTIONS:-abort_on_error=1:detect_leaks=0:halt_on_error=1}"
fi
args=()
if [[ -n "${2:-}" ]]; then
args=(-s "$2")
fi
exec ./build-{{m}}/umbriel "${args[@]}"
test m=mode: (configure m)
meson compile -C build-{{m}} unit-tests
meson test -C build-{{m}} --print-errorlogs
# Whole harness suite, or the checks whose names contain any given fragment. Each
# check runs against its own headless compositor instance, so a fragment selects
# a group as readily as a single check.
# The build is silent unless it fails: the run's own report is the output.
[no-exit-message]
verify m=mode *filters: (_ensure-configured m)
#!/usr/bin/env bash
set -euo pipefail
if ! build_log=$(meson compile -C build-{{m}} umbriel harness-clients 2>&1); then
printf '%s\n' "$build_log" >&2
exit 1
fi
bash tests/harness/verify.sh ./build-{{m}}/umbriel {{filters}}
# One check, a group, or a few, on the default build, without naming the mode:
# `just check 310`, `just check drag`, `just check 310 -v` for full output.
[no-exit-message]
check +filters: (verify mode filters)
# Names of every harness check. Boots nothing.
checks:
@bash tests/harness/verify.sh ./build-{{mode}}/umbriel --list
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:]]*$//'
# Tests are checked too: they are code the same rules apply to, and a finding
# there is as real as one in src.
_clang_tidy m=mode *args:
#!/usr/bin/env bash
set -euo pipefail
src_root="$(realpath src)"
tests_root="$(realpath tests)"
run-clang-tidy -quiet -use-color -p "build-{{m}}" -j "$(nproc)" -header-filter='\.\./(src|tests)/.*' {{args}} "^(${src_root}|${tests_root})/.*"
# Fail on any compiler warning emitted while building. clang-tidy does not surface these: it reports its own check names, not the compiler's diagnostics. Compiles everything rather than only what changed. A warning is emitted when a file is compiled, so an incremental build reports nothing for the files it skipped, which silently turns a gate into a coin flip. A dead function left behind by an edit in another file is exactly the case that slips through.
_warnings m=mode: (_ensure-configured m)
#!/usr/bin/env bash
set -euo pipefail
ninja -C build-{{m}} -t clean >/dev/null
if ! output=$(ninja -C build-{{m}} 2>&1); then
printf '%s\n' "$output"
exit 1
fi
if printf '%s\n' "$output" | grep -q 'warning:'; then
printf '%s\n' "$output" | grep -A8 'warning:'
echo "error: compiler warnings are not allowed" >&2
exit 1
fi
lint m=mode: (_ensure-configured m) (_warnings m)
just _clang_tidy {{m}} '-warnings-as-errors=*'
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)