diff --git a/gl-check b/gl-check new file mode 100755 index 00000000..9a7098ca --- /dev/null +++ b/gl-check @@ -0,0 +1,152 @@ +#!/bin/bash +set -euo pipefail + +SCRIPT_DIR="$(cd -- "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)" +WAYLAND_SHELL="${WAYLAND_SHELL:-xdg-shell}" +CLANG_QUERY="${CLANG_QUERY:-clang-query}" +BUILD_DIR="${BUILD_DIR:-$SCRIPT_DIR/client/build}" + +case "$WAYLAND_SHELL" in + xdg-shell) shell_ignore=shell_libdecor.c ;; + libdecor) shell_ignore=shell_xdg.c ;; + *) + echo "Unknown Wayland shell: $WAYLAND_SHELL" + exit 1 +esac + +if ! command -v "$CLANG_QUERY" &> /dev/null; then + echo "clang-query is not installed" + exit 1 +fi + +if [ ! -f "$BUILD_DIR/compile_commands.json" ]; then + echo "compile_commands.json not found in $BUILD_DIR" + echo 'Run cmake with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON to enable' + exit 1 +fi + +tempdir="$(mktemp -d)" +cleanup() { + rm -rf "$tempdir" +} +trap cleanup EXIT + +sed '/EGL_VERSION_1_5/,$d' /usr/include/EGL/egl.h > "$tempdir/egl1.4.h" + +getCalls() { + query="$1" + dir="$2" + + command=(find "$dir" -name '*.c') + if [ $# -gt 2 ]; then + command+=(-not) + shift 2 + for exclude in "$@"; do + command+=(-name "$exclude") + done + fi + + cat > "$tempdir/query" <