summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-02 17:33:13 +0300
committerMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-02 17:33:13 +0300
commit38c57e163abad6216f7e0f44d401c362c5fd5da6 (patch)
tree289728a5aedc626cda3ed4d39be6a3640b32b5ff /scripts
parentf3e2e3ca597244c6f1bced139704f342c494441b (diff)
downloadProject-Tick-38c57e163abad6216f7e0f44d401c362c5fd5da6.tar.gz
Project-Tick-38c57e163abad6216f7e0f44d401c362c5fd5da6.zip
NOISSUE add clang-format and clang-tidy configuration files, update CMakeLists for clang-tidy integration, and create script for clang-format checks
Signed-off-by: Mehmet Samet Duman <yongdohyun@projecttick.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/check-clang-format.sh46
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/check-clang-format.sh b/scripts/check-clang-format.sh
new file mode 100755
index 0000000000..c498650df5
--- /dev/null
+++ b/scripts/check-clang-format.sh
@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+# SPDX-FileCopyrightText: 2026 Project Tick
+# SPDX-FileContributor: Project Tick
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+set -euo pipefail
+
+repo_root="$(cd "$(dirname "$0")/.." && pwd)"
+file_list="$repo_root/.clang-format-files"
+
+discover_files() {
+ if git -C "$repo_root" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
+ git -C "$repo_root" ls-files '*.c' '*.h' '*.cpp'
+ else
+ rg --files "$repo_root" -g '*.c' -g '*.h' -g '*.cpp'
+ fi
+}
+
+if [[ -f "$file_list" ]]; then
+ mapfile -t files < <(grep -Ev '^(#|$)' "$file_list")
+ if [[ ${#files[@]} -eq 0 ]]; then
+ mapfile -t files < <(discover_files)
+ fi
+else
+ mapfile -t files < <(discover_files)
+fi
+
+if [[ ${#files[@]} -eq 0 ]]; then
+ echo "No C/C++ source files found for clang-format checks" >&2
+ exit 1
+fi
+
+for file in "${files[@]}"; do
+ if [[ "$file" = "$repo_root"/* ]]; then
+ candidate="$file"
+ else
+ candidate="$repo_root/$file"
+ fi
+ if [[ ! -f "$candidate" ]]; then
+ echo "Configured clang-format file not found: $file" >&2
+ exit 1
+ fi
+done
+
+cd "$repo_root"
+clang-format --dry-run --Werror --style=file "${files[@]}" \ No newline at end of file