mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2026-03-27 08:08:11 +03:00
chore: checkpoint before lint autofix
This commit is contained in:
75
build-scripts/lint_style.sh
Normal file
75
build-scripts/lint_style.sh
Normal file
@@ -0,0 +1,75 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage: build-scripts/lint_style.sh [check|format]
|
||||
|
||||
Commands:
|
||||
check Verify C/C++ style with clang-format (default)
|
||||
format Apply clang-format in place
|
||||
EOF
|
||||
}
|
||||
|
||||
MODE="${1:-check}"
|
||||
if [[ "$MODE" != "check" && "$MODE" != "format" ]]; then
|
||||
usage
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if ! command -v clang-format >/dev/null 2>&1; then
|
||||
echo "clang-format is required but was not found in PATH." >&2
|
||||
exit 127
|
||||
fi
|
||||
|
||||
REPO_ROOT="$(git rev-parse --show-toplevel)"
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
declare -a PATHSPECS=(
|
||||
"*.c"
|
||||
"*.h"
|
||||
"*.cc"
|
||||
"*.cpp"
|
||||
"*.hpp"
|
||||
":(exclude)build/**"
|
||||
":(exclude)managed_components/**"
|
||||
":(exclude)components/codecs/inc/**"
|
||||
":(exclude)components/esp-dsp/**"
|
||||
":(exclude)components/esp_http_server/**"
|
||||
":(exclude)components/spotify/cspot/**"
|
||||
":(exclude)components/squeezelite/**"
|
||||
":(exclude)components/telnet/libtelnet/**"
|
||||
":(exclude)components/tjpgd/**"
|
||||
":(exclude)components/wifi-manager/webapp/dist/**"
|
||||
":(exclude)components/wifi-manager/webapp/src/js/proto/**"
|
||||
)
|
||||
|
||||
mapfile -t FILES < <(git ls-files -- "${PATHSPECS[@]}" | grep -E '^(components|main|test)/.*\.(c|h|cc|cpp|hpp)$' || true)
|
||||
|
||||
if [[ ${#FILES[@]} -eq 0 ]]; then
|
||||
echo "No C/C++ files matched lint scope."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "$MODE" == "format" ]]; then
|
||||
printf '%s\0' "${FILES[@]}" | xargs -0 -r clang-format -i
|
||||
echo "Formatted ${#FILES[@]} file(s)."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
declare -a FAILING=()
|
||||
for file in "${FILES[@]}"; do
|
||||
if ! clang-format --dry-run --Werror "$file" >/dev/null 2>&1; then
|
||||
FAILING+=("$file")
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ${#FAILING[@]} -gt 0 ]]; then
|
||||
echo "Style check failed in ${#FAILING[@]} file(s)."
|
||||
echo "First failing files:"
|
||||
printf ' - %s\n' "${FAILING[@]:0:30}"
|
||||
echo "Run: build-scripts/lint_style.sh format"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Style check passed for ${#FILES[@]} file(s)."
|
||||
45
build-scripts/ui_footprint_snapshot.sh
Normal file
45
build-scripts/ui_footprint_snapshot.sh
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(git rev-parse --show-toplevel)"
|
||||
DIST_DIR="$ROOT/components/wifi-manager/webapp/dist"
|
||||
|
||||
if [[ ! -d "$DIST_DIR" ]]; then
|
||||
echo "dist directory not found: $DIST_DIR" >&2
|
||||
echo "Build webapp first (e.g. npm run build in components/wifi-manager/webapp)." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
python - "$DIST_DIR" <<'PY'
|
||||
import os
|
||||
import sys
|
||||
import glob
|
||||
from datetime import datetime, timezone
|
||||
|
||||
dist = sys.argv[1]
|
||||
|
||||
def rel(p):
|
||||
return os.path.relpath(p, start=os.getcwd())
|
||||
|
||||
all_files = [p for p in glob.glob(os.path.join(dist, "**", "*"), recursive=True) if os.path.isfile(p)]
|
||||
ship_files = [p for p in all_files if p.endswith(".gz") or p.endswith(".png")]
|
||||
|
||||
all_files_sorted = sorted([(os.path.getsize(p), p) for p in all_files], reverse=True)
|
||||
ship_sorted = sorted([(os.path.getsize(p), p) for p in ship_files], reverse=True)
|
||||
|
||||
print(f"Snapshot UTC: {datetime.now(timezone.utc).isoformat(timespec='seconds')}")
|
||||
print(f"Dist dir: {rel(dist)}")
|
||||
print("")
|
||||
print(f"All dist files: {len(all_files)}")
|
||||
print(f"All dist bytes: {sum(s for s, _ in all_files_sorted)}")
|
||||
print(f"Shipped files (*.gz + *.png): {len(ship_sorted)}")
|
||||
print(f"Shipped bytes: {sum(s for s, _ in ship_sorted)}")
|
||||
print("")
|
||||
print("Top 15 dist files:")
|
||||
for size, path in all_files_sorted[:15]:
|
||||
print(f"{size:9d} {rel(path)}")
|
||||
print("")
|
||||
print("Shipped files:")
|
||||
for size, path in ship_sorted:
|
||||
print(f"{size:9d} {rel(path)}")
|
||||
PY
|
||||
Reference in New Issue
Block a user