2019-06-18 16:14:30 +00:00
|
|
|
#!/bin/sh
|
2024-08-16 16:44:26 +00:00
|
|
|
# Copyright 2019-2024, Collabora, Ltd.
|
2019-06-18 16:14:30 +00:00
|
|
|
# SPDX-License-Identifier: BSL-1.0
|
2023-11-15 17:09:51 +00:00
|
|
|
# Author: Rylie Pavlik <rylie.pavlik@collabora.com>
|
2019-03-18 05:52:32 +00:00
|
|
|
|
2019-06-18 16:14:30 +00:00
|
|
|
# Formats all the source files in this project
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if [ ! "${CLANGFORMAT}" ]; then
|
2023-03-25 07:50:06 +00:00
|
|
|
for fn in clang-format-14 clang-format-13 clang-format-12 clang-format-11 clang-format-10 clang-format-9 clang-format-8 clang-format-7 clang-format-6.0 clang-format; do
|
2019-06-18 16:14:30 +00:00
|
|
|
if command -v $fn > /dev/null; then
|
|
|
|
CLANGFORMAT=$fn
|
2019-03-18 05:52:32 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
2019-06-18 16:14:30 +00:00
|
|
|
|
|
|
|
if [ ! "${CLANGFORMAT}" ]; then
|
|
|
|
echo "We need some version of clang-format, please install one!" 1>&2
|
2019-03-18 05:52:32 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
(
|
2021-03-16 12:35:53 +00:00
|
|
|
${CLANGFORMAT} --version
|
|
|
|
|
2024-08-16 16:44:26 +00:00
|
|
|
cd "$(dirname "$0")/.."
|
2021-03-16 12:35:53 +00:00
|
|
|
|
2019-06-18 16:14:30 +00:00
|
|
|
find \
|
|
|
|
src/xrt/auxiliary \
|
|
|
|
src/xrt/compositor \
|
|
|
|
src/xrt/drivers \
|
|
|
|
src/xrt/include \
|
2020-04-11 00:28:35 +00:00
|
|
|
src/xrt/ipc \
|
2019-06-18 16:14:30 +00:00
|
|
|
src/xrt/state_trackers \
|
|
|
|
src/xrt/targets \
|
2022-06-14 18:27:56 +00:00
|
|
|
src/xrt/tracking \
|
2020-06-17 09:58:29 +00:00
|
|
|
tests \
|
2019-12-03 14:52:45 +00:00
|
|
|
\( -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" \) \
|
2024-08-16 16:44:26 +00:00
|
|
|
-and -not \( -ipath \*/.cxx/\* \) \
|
|
|
|
-exec "${CLANGFORMAT}" -i -style=file \{\} +
|
2019-03-18 05:52:32 +00:00
|
|
|
)
|