mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-29 11:06:18 +00:00
scripts: Replace format-project.sh with faster and BSL-1.0 licensed one
This commit is contained in:
parent
e745a28374
commit
a01cda7434
|
@ -1,28 +1,35 @@
|
||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
# Copyright 2018-2019, Collabora, Ltd.
|
# Copyright 2019, Collabora, Ltd.
|
||||||
# Copyright 2016, Sensics, Inc.
|
# SPDX-License-Identifier: BSL-1.0
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# Author: Ryan Pavlik <ryan.pavlik@collabora.com>
|
||||||
|
|
||||||
if [ ! "$CLANG_FORMAT" ]; then
|
# Formats all the source files in this project
|
||||||
for exe in clang-format-8 clang-format-7 clang-format-6.0 clang-format; do
|
|
||||||
if which $exe >/dev/null 2>&1; then
|
set -e
|
||||||
CLANG_FORMAT=$exe
|
|
||||||
|
if [ ! "${CLANGFORMAT}" ]; then
|
||||||
|
for fn in clang-format-9 clang-format-8 clang-format-7 clang-format-6.0 clang-format; do
|
||||||
|
if command -v $fn > /dev/null; then
|
||||||
|
CLANGFORMAT=$fn
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
if [ ! "$CLANG_FORMAT" ]; then
|
|
||||||
echo "Can't find clang-format - please set CLANG_FORMAT to a command or path" >&2
|
if [ ! "${CLANGFORMAT}" ]; then
|
||||||
|
echo "We need some version of clang-format, please install one!" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
runClangFormatOnDir() {
|
|
||||||
find "$1" \( -name "*.c" -o -name "*.cpp" -o -name "*.h" \)| \
|
|
||||||
grep -v "\.boilerplate" | \
|
|
||||||
xargs ${CLANG_FORMAT} -style=file -i
|
|
||||||
}
|
|
||||||
|
|
||||||
(
|
(
|
||||||
cd $(dirname $0)/../src/xrt
|
cd $(dirname $0)/..
|
||||||
runClangFormatOnDir .
|
find \
|
||||||
|
src/xrt/auxiliary \
|
||||||
|
src/xrt/compositor \
|
||||||
|
src/xrt/drivers \
|
||||||
|
src/xrt/include \
|
||||||
|
src/xrt/state_trackers \
|
||||||
|
src/xrt/targets \
|
||||||
|
\( -name "*.c" -o -name "*.cpp" -o -name "*.h" \) \
|
||||||
|
-exec ${CLANGFORMAT} -i -style=file \{\} +
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue