-
Notifications
You must be signed in to change notification settings - Fork 1
/
format
executable file
·34 lines (29 loc) · 1.09 KB
/
format
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
VERILOG_FORMATTER_PATH=$(dirname $0)/istyle-verilog-formatter
VERILOG_FORMATTER_BIN=${VERILOG_FORMATTER_PATH}/bin/release/iStyle
if [ ! -f "$VERILOG_FORMATTER_BIN" ]; then
echo "${VERILOG_FORMATTER_BIN} doesn't exist. Running 'make'..."
make --directory "$VERILOG_FORMATTER_PATH"
fi
# Loop through all arguments and format the specified files or recursively format
# files in specified directories.
count=0
for path in "$@"; do
if [ -d "$path" ]; then
# Set the Internal Field Separator for bash so that \n is used as a delimiter
# in for loops.
IFS=$'\n'
for subpath in $(find "$path" -iname *.v -o -iname *.sv); do
echo "Formatting ${subpath}."
eval $VERILOG_FORMATTER_BIN "$subpath" --convert-tabs --suffix=none --style=kr
((count++))
done
elif [ -f "$path" ]; then
echo "Formatting ${path}."
eval $VERILOG_FORMATTER_BIN "$path" --convert-tabs --suffix=none --style=kr
((count++))
else
echo "$path does not exist." 1>&2;
fi
done
echo "Formatted $count files."