The open source OpenXR runtime
1#!/bin/sh
2# Copyright 2019-2024, Collabora, Ltd.
3# SPDX-License-Identifier: BSL-1.0
4# Author: Rylie Pavlik <rylie.pavlik@collabora.com>
5
6# Formats all the source files in this project
7
8set -e
9
10if [ ! "${CLANGFORMAT}" ]; then
11 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
12 if command -v $fn > /dev/null; then
13 CLANGFORMAT=$fn
14 break
15 fi
16 done
17fi
18
19if [ ! "${CLANGFORMAT}" ]; then
20 echo "We need some version of clang-format, please install one!" 1>&2
21 exit 1
22fi
23
24(
25 ${CLANGFORMAT} --version
26
27 cd "$(dirname "$0")/.."
28
29 find \
30 src/xrt/auxiliary \
31 src/xrt/compositor \
32 src/xrt/drivers \
33 src/xrt/include \
34 src/xrt/ipc \
35 src/xrt/state_trackers \
36 src/xrt/targets \
37 src/xrt/tracking \
38 tests \
39 \( -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" \) \
40 -and -not \( -ipath \*/.cxx/\* \) \
41 -exec "${CLANGFORMAT}" -i -style=file \{\} +
42)