Files
FreeRDP/scripts/cmake-format.sh

38 lines
1012 B
Bash
Raw Normal View History

2024-11-27 13:14:37 +01:00
#!/bin/bash -e
SCRIPT_PATH=$(dirname "${BASH_SOURCE[0]}")
SCRIPT_PATH=$(realpath "$SCRIPT_PATH")
SRC_PATH="${SCRIPT_PATH}/.."
FORMAT_ARG="--check"
REST_ARGS=$@
2025-02-25 13:31:20 +01:00
if [ $# -ne 0 ]; then
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
echo "usage: $0 [options] [file, file, ...]"
echo "\t--check.-c ... run format check only, no files changed (default)"
echo "\t--format,-f ... format files in place"
echo "\t--help,-h ... print this help"
2024-11-27 13:14:37 +01:00
2025-02-25 13:31:20 +01:00
exit 1
fi
2024-11-27 13:14:37 +01:00
2025-02-25 13:31:20 +01:00
if [ "$1" = "--check" ] || [ "$1" = "-c" ]; then
FORMAT_ARG="--check"
REST_ARGS="${@:2}"
fi
if [ "$1" = "--format" ] || [ "$1" = "-f" ]; then
FORMAT_ARG="-i"
REST_ARGS="${@:2}"
fi
2024-11-27 13:14:37 +01:00
fi
2025-02-25 13:31:20 +01:00
if [ ! -n "$REST_ARGS" ]; then
CMAKE_FILES=$(find ${SRC_PATH} -name "*.cmake" -o -name "CMakeLists.txt")
CMAKE_CI_FILES=$(find ${SRC_PATH}/ci -name "*.txt")
fi
2024-12-26 10:07:01 +01:00
2025-02-25 13:31:20 +01:00
for FILE in $CMAKE_FILES $CMAKE_CI_FILES $REST_ARGS; do
echo "processing file $FILE..."
cmake-format -c "$SCRIPT_PATH/cmake-format.yml" $FORMAT_ARG $FILE
2024-11-27 13:14:37 +01:00
done