Add a script to check whether all project sources are properly formatted
This commit is contained in:
parent
98da473fdc
commit
bb26996cb7
29
tools/check-formatting.sh
Executable file
29
tools/check-formatting.sh
Executable file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source $(dirname $0)/env.sh
|
||||
|
||||
cd $LUNA_ROOT
|
||||
|
||||
SOURCES=($(find kernel/src -type f | grep "\.c") $(find kernel/include -type f))
|
||||
SOURCES+=($(find libs/libc/src -type f | grep "\.c") $(find libs/libc/include -type f))
|
||||
SOURCES+=($(find apps/src -type f))
|
||||
|
||||
ALL_OK=1
|
||||
|
||||
for f in ${SOURCES[@]}
|
||||
do
|
||||
clang-format -n $f 2>&1 | grep ".*" >/dev/null
|
||||
if [ "$?" = "0" ]
|
||||
then
|
||||
echo "File $f needs formatting"
|
||||
ALL_OK=0
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $ALL_OK = "1" ]
|
||||
then
|
||||
echo "All files OK"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
exit 1
|
Loading…
Reference in New Issue
Block a user