forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathretired-ble-flags.sh
More file actions
executable file
·60 lines (53 loc) · 1.8 KB
/
Copy pathretired-ble-flags.sh
File metadata and controls
executable file
·60 lines (53 loc) · 1.8 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
#!/usr/bin/env bash
# Regression guard: a consumer still passing the retired SimpleBLE flags must
# fail at configure time with a migration message, never configure silently and
# then throw BleDisabled on the first Scan/Listen at runtime.
set -uo pipefail
cpp_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
work_dir="$(mktemp -d)"
trap 'rm -rf "$work_dir"' EXIT
failures=0
expect_configure_failure() {
local flag="$1"
local build_dir="$work_dir/${flag}"
local output
output="$(cmake -S "$cpp_dir" -B "$build_dir" "-D${flag}=ON" 2>&1)"
local status=$?
# CMake word-wraps message() output, so match against a single flattened line.
local flat
flat="$(tr '\n' ' ' <<<"$output" | tr -s ' ')"
if [ "$status" -eq 0 ]; then
echo "FAIL: -D${flag}=ON configured successfully; it must be a hard error"
failures=$((failures + 1))
return
fi
if ! grep -q "was removed along with the SimpleBLE dependency" <<<"$flat"; then
echo "FAIL: -D${flag}=ON failed without the migration message:"
echo "$output"
failures=$((failures + 1))
return
fi
if ! grep -q "SetBleBackend" <<<"$flat"; then
echo "FAIL: -D${flag}=ON message does not name the replacement API"
failures=$((failures + 1))
return
fi
echo "ok: -D${flag}=ON fails at configure time with the migration message"
}
expect_clean_configure() {
local build_dir="$work_dir/clean"
if ! cmake -S "$cpp_dir" -B "$build_dir" >/dev/null 2>&1; then
echo "FAIL: a plain configure must still succeed"
failures=$((failures + 1))
return
fi
echo "ok: plain configure succeeds"
}
expect_configure_failure OMI_DEVICE_BLE
expect_configure_failure OMI_DEVICE_SIMPLEBLE_SOURCE_DIR
expect_clean_configure
if [ "$failures" -ne 0 ]; then
echo "$failures check(s) failed"
exit 1
fi
echo "all retired-flag checks passed"