Michael Schaffner | 388f5d5 | 2020-01-15 12:04:40 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright lowRISC contributors. |
| 3 | # Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| 4 | # SPDX-License-Identifier: Apache-2.0 |
| 5 | # |
| 6 | # this script runs the verible formatter on all system verilog |
| 7 | # files under hw/{ip,vendor,top_earlgrey} |
| 8 | # |
| 9 | # make sure to invoke this tool from the project root. |
| 10 | # |
| 11 | # NOTE: this operates in-place - so make sure to make a backup or |
| 12 | # run this on an experimental branch |
| 13 | # |
| 14 | # TODO: integrate this with Fusesoc and the other linting flows. |
| 15 | |
| 16 | NUM_PROCS=8 |
Michael Schaffner | 76469e2 | 2020-08-10 10:13:23 -0700 | [diff] [blame] | 17 | REPORT_FILE="verible-format.rpt" |
| 18 | VERIBLE_VERSION=`verible-verilog-format --version` |
| 19 | |
| 20 | if [ -z $VERIBLE_VERSION ]; then |
| 21 | echo "verible-verilog-format either not installed or not visible in PATH" |
| 22 | exit 1 |
| 23 | fi |
Michael Schaffner | 388f5d5 | 2020-01-15 12:04:40 -0800 | [diff] [blame] | 24 | |
| 25 | # this is a precaution in order to prevent accidental |
| 26 | # overwriting of uncomitted changes |
| 27 | git add -u |
| 28 | |
| 29 | # get all system verilog files and pipe through style formatter |
| 30 | find hw/{ip,vendor,top_earlgrey} -type f -name "*.sv" -o -name "*.svh" | \ |
Michael Schaffner | 76469e2 | 2020-08-10 10:13:23 -0700 | [diff] [blame] | 31 | xargs -n 1 -P $NUM_PROCS verible-verilog-format \ |
Michael Schaffner | 388f5d5 | 2020-01-15 12:04:40 -0800 | [diff] [blame] | 32 | --inplace |
| 33 | |
Michael Schaffner | 76469e2 | 2020-08-10 10:13:23 -0700 | [diff] [blame] | 34 | echo "Usign verible-verilog-format version $VERIBLE_VERSION" > $REPORT_FILE |
| 35 | |
Michael Schaffner | 388f5d5 | 2020-01-15 12:04:40 -0800 | [diff] [blame] | 36 | # report changed files |
| 37 | git status | \ |
| 38 | grep modified | \ |
| 39 | grep dv | \ |
| 40 | awk -F ' ' '{print $2}' | \ |
Michael Schaffner | 76469e2 | 2020-08-10 10:13:23 -0700 | [diff] [blame] | 41 | tee -a $REPORT_FILE |