GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git
scripts/style-audit (2.8K)
1 #!/usr/bin/env bash
2 # style-audit — does each cce app stand on the standard root plate and take
3 # its spacing from the ladder? A conformance check, not a build step: it
4 # greps the sibling app crates and prints one row per app.
5 #
6 # cce-ui/scripts/style-audit # every cce-* app beside cce-ui
7 # cce-ui/scripts/style-audit cce-mail # one or more apps
8 # cce-ui/scripts/style-audit --strict # exit 1 if any row is off-standard
9 #
10 # Columns:
11 # root PLATE paints PlateSpec::window / root_plate / root_at
12 # FILL paints a full-window quad or rounded_rect instead (off)
13 # NONE paints no window base at all (off unless opted out)
14 # ladder how many spacing-ladder getters the app reads
15 # (root_plate_inset/padding/gap, plate_padding/gap, control_gap,
16 # the Style::root_/pane_/controls_ presets)
17 # literals spacing consts of the app's own (const *PAD*/*GAP*/*MARGIN*),
18 # each one a number the ladder should be supplying
19 #
20 # Opt-outs: a crate that is not a plate by design (a transparent surface,
21 # a full-bleed canvas) declares it with a line anywhere in its src:
22 # // style-audit: opt-out <reason>
23 # and is listed as OPT-OUT rather than off-standard.
24 set -u
25 here=$(cd "$(dirname "$0")/.." && pwd)
26 ws=$(dirname "$here")
27 strict=0; apps=()
28 for a in "$@"; do case "$a" in --strict) strict=1;; *) apps+=("$a");; esac; done
29 if [ ${#apps[@]} -eq 0 ]; then
30 for d in "$ws"/cce-*/; do
31 d=${d%/}; n=$(basename "$d")
32 case "$n" in cce-ui|cce-compositor|cce-window-manager|cce-icons) continue;; esac
33 [ -f "$d/Cargo.toml" ] && grep -q '^cce-ui' "$d/Cargo.toml" 2>/dev/null && apps+=("$n")
34 done
35 fi
36 printf '%-24s %-8s %-7s %-9s %s\n' app root ladder literals note
37 fail=0
38 for n in "${apps[@]}"; do
39 src="$ws/$n/src"; [ -d "$src" ] || { printf '%-24s (no src)\n' "$n"; continue; }
40 if grep -rqE 'style-audit: *opt-out' "$src"; then
41 reason=$(grep -rhoE 'style-audit: *opt-out.*' "$src" | head -1 | sed 's/style-audit: *opt-out *//')
42 printf '%-24s %-8s %-7s %-9s %s\n' "$n" OPT-OUT - - "$reason"; continue
43 fi
44 if grep -rqE 'PlateSpec::(window|root_at)\(|\.root_plate\(' "$src"; then root=PLATE
45 elif grep -rqE '(quad|rounded_rect)\([^;]*(0\.0, *0\.0|x: *0\.0, *y: *0\.0)' "$src"; then root=FILL
46 else root=NONE; fi
47 ladder=$(grep -rhoE 'root_plate_(inset|padding|gap)\(\)|plate_(padding|gap)\(\)|control_gap\(\)|Style::(root|pane|controls)_(column|row)\(\)|ColumnLayout::(pane|controls)\(' "$src" | wc -l)
48 literals=$(grep -rhE '^\s*(pub )?const [A-Z_]*(PAD|GAP|MARGIN|INSET)[A-Z_]*: *f32' "$src" | wc -l)
49 note=""
50 [ "$root" != PLATE ] && { note="base is not the standard root plate"; fail=1; }
51 [ "$ladder" -eq 0 ] && { note="${note:+$note; }no ladder getter read"; fail=1; }
52 printf '%-24s %-8s %-7s %-9s %s\n' "$n" "$root" "$ladder" "$literals" "$note"
53 done
54 [ $strict -eq 1 ] && exit $fail
55 exit 0