Commit 70044923 authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

build: check formatting with astyle



Change-Id: Ic09b4dd7ccccb557e8236fc0b7e3105fce1644b3
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 5abc81fd
Loading
Loading
Loading
Loading

.astylerc

0 → 100644
+26 −0
Original line number Diff line number Diff line
# Bracket Style
style=kr # K&R brackets

# Indentation
indent=force-tab=8 # Use tabs for indentation, spaces for minor alignment
min-conditional-indent=0

# Padding
unpad-paren # Remove all spaces with parens that aren't requested below
pad-oper # Put spaces around operators
pad-header # Put spaces between if/while/for etc. and the first paren

# Pointers
align-pointer=name # Align the * next to the variable name

# Line wrapping
max-code-length=100 # 100 character line limit
break-after-logical # For if statements, wrap to the next line after logical operator

# Line endings
lineend=linux # LF line endings

# General options
suffix=none
recursive
formatted
+2 −0
Original line number Diff line number Diff line
@@ -10,6 +10,8 @@ DPDK_DIR=/usr/local/dpdk-2.1.0/x86_64-native-linuxapp-gcc

cd $src

./scripts/check_format.sh

scanbuild=''
if hash scan-build; then
	scanbuild="scan-build -o $out/scan-build-tmp --status-bugs"
+32 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash

readonly BASEDIR=$(readlink -f $(dirname $0))/..
cd $BASEDIR

# exit on errors
set -e

if hash astyle; then
	echo -n "Checking coding style..."
	rm -f astyle.log
	touch astyle.log
	astyle --options=.astylerc "*.c" >> astyle.log
	astyle --options=.astylerc "*.h" >> astyle.log
	if grep -q "^Formatted" astyle.log; then
		echo " errors detected"
		sed -i -e 's/  / /g' astyle.log
		grep --color=auto "^Formatted.*" astyle.log
		echo "Incorrect code style detected in one or more files."
		echo "The files have been automatically formatted."
		echo "Remember to add the files to your commit."
		rm -f astyle.log
		exit 1
	fi
	echo " OK"
	rm -f astyle.log
else
	echo "You do not have astyle installed so your code style is not being checked!"
	exit 0
fi

exit 0