49 lines
1.7 KiB
Bash
Executable File
49 lines
1.7 KiB
Bash
Executable File
#!/bin/zsh
|
|
# The return code
|
|
local ERR=0
|
|
# Format all c files
|
|
local GLOB=( **/*.c )
|
|
# Astyle options:
|
|
# --mode=c : c formatting
|
|
# -xc : Brace attached to class names
|
|
# --style=stroustrup : stroustrup style (similar to 1tbs)
|
|
# -j : Always add brackets (even on one line if statements)
|
|
# -s2 : Three spaces
|
|
# -xG : Indent modifiers
|
|
# -S : Indent switches
|
|
# -K : Indent cases
|
|
# -N : Indent namespaces
|
|
# -xn : Attach bracket to namespace
|
|
# -xl : Attach inlines
|
|
# -n : Don't make a backup
|
|
# -p : Pad operators
|
|
# -H : Pad header (space after if, for, while)
|
|
local OPTS=( --mode=c -xc --style=stroustrup -j -s2 -xG -S -K -N -xn -xl -n -p -H )
|
|
# Process the c files by adding the comment and removing newlines
|
|
perl "${0:h}/process.pl" $GLOB
|
|
# Colorize output if you can
|
|
if which colout>/dev/null; then
|
|
astyle $OPTS $GLOB|\grep -P '^(?!Unchanged)'|colout '(Formatted)' green||true
|
|
else
|
|
astyle $OPTS $GLOB|\grep -P '^(?!Unchanged)'||true
|
|
fi
|
|
# Check for todos
|
|
if command -v ag >/dev/null; then
|
|
ag TODO >&2 && ERR=2
|
|
fi
|
|
# Now check for documentation
|
|
# Run doxygen, redirecting stdout to dev null, and setting stderr to $OUTPUT
|
|
if command -v doxygen >/dev/null; then
|
|
OUTPUT=$((doxygen "${0:h}/Doxyfile" > /dev/null) 2>&1)
|
|
#TODO: We might need this in the future, bur for now, delete html directory
|
|
rm -r html || true
|
|
# If there is output, something went wrong
|
|
if [ ! -z "$OUTPUT" ]; then
|
|
printf "$OUTPUT\n" >&2
|
|
ERR=3
|
|
fi
|
|
else
|
|
printf "You don't have doxygen installed. Can't check documentation\n" >&2
|
|
fi
|
|
return "$ERR"
|