Added function for clang formatting.
The shell function finds all the C source and header files in the './src' directory; then it applies the formatting specified in the .clang-format file. Right now it only runs when the ctests shell function is called.
This commit is contained in:
parent
77364c22d1
commit
0723cb259b
23
otto.sh
23
otto.sh
|
@ -10,6 +10,28 @@ TEMPLATE_FILES=".template_files"
|
|||
MODULE_DIR="${TEMPLATE_FILES}/modules"
|
||||
|
||||
|
||||
format_source_code () {
|
||||
if [ ! -f .clang-format]; then
|
||||
echo "Missing '.clang-format' file!"
|
||||
return
|
||||
fi
|
||||
|
||||
#Get a list of all C files
|
||||
source_c_files=$(find ./src -name '*.c')
|
||||
for f in $source_c_files; do
|
||||
clang-format -style=.clang-format $f
|
||||
done
|
||||
|
||||
#Get a list of all H files
|
||||
source_h_files=$(find ./src -name '*.h')
|
||||
for f in $source_h_files; do
|
||||
clang-format -style=.clang-format $f
|
||||
done
|
||||
|
||||
echo "Applying Formating standard!"
|
||||
}
|
||||
|
||||
|
||||
add_compile_commands () {
|
||||
if [ -f ./compile_commands.json ]; then
|
||||
echo "compile_commands.json already exists!\n"
|
||||
|
@ -173,6 +195,7 @@ build_main () {
|
|||
|
||||
run_c_tests () {
|
||||
clear_cmake_cache
|
||||
format_source_code
|
||||
cmake -DUNIT_TESTING=ON -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE} ../
|
||||
make AllTests && ./tests/AllTests
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue