mirror of
https://github.com/zeldaret/mm.git
synced 2024-11-23 12:59:44 +00:00
57a9fb7b34
* Added tools/check_format.sh. * Exit nonzero from format.sh if clang-format-11 not installed. * Replace which with command -v. * Fail check_format.sh if format.sh fails. * Improve Jenkinsfile. * Take exit 0 out of else in check_format.sh. * Format flg_set.c to test new Jenkins environment. * Fix formatter failed logic in check_format.sh. * Format all misformatted files in master. * Remove Summarize Problems stage from Jenkins. I didn't realize Jenkins would not a run a subsequent stage if a previous stage errored. This defeats the purpose of summarizing all problems at the end, since this will only happen if there *are* no problems. * Use Post->Failure block to print all logs instead. * Remove spurious semicolon in arms_hook.
37 lines
1.1 KiB
Bash
Executable File
37 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
FORMAT_VER="11"
|
|
FORMAT_OPTS="-i -style=file"
|
|
TIDY_OPTS="-p . --fix --fix-errors"
|
|
COMPILER_OPTS="-fno-builtin -std=gnu90 -Iinclude -Isrc -D_LANGUAGE_C -DNON_MATCHING"
|
|
|
|
shopt -s globstar
|
|
|
|
if [ -z `command -v clang-format-${FORMAT_VER}` ]
|
|
then
|
|
echo "clang-format-${FORMAT_VER} not found. Exiting."
|
|
exit 1
|
|
fi
|
|
|
|
if (( $# > 0 )); then
|
|
echo "Formatting file(s) $*"
|
|
echo "Running clang-format..."
|
|
clang-format-${FORMAT_VER} ${FORMAT_OPTS} "$@"
|
|
echo "Running clang-tidy..."
|
|
clang-tidy ${TIDY_OPTS} "$@" -- ${COMPILER_OPTS} &> /dev/null
|
|
echo "Adding missing final new lines..."
|
|
sed -i -e '$a\' "$@"
|
|
echo "Done formatting file(s) $*"
|
|
exit
|
|
fi
|
|
|
|
echo "Formatting C files. This will take a bit"
|
|
echo "Running clang-format..."
|
|
clang-format-${FORMAT_VER} ${FORMAT_OPTS} src/**/*.c
|
|
echo "Running clang-tidy..."
|
|
clang-tidy ${TIDY_OPTS} src/**/*.c -- ${COMPILER_OPTS} &> /dev/null
|
|
echo "Adding missing final new lines..."
|
|
find src/ -type f -name "*.c" -exec sed -i -e '$a\' {} \;
|
|
find assets/xml/ -type f -name "*.xml" -exec sed -i -e '$a\' {} \;
|
|
echo "Done formatting all files."
|