blob: d2017e3c9dbd1d10e2959bdb61eaf63aa03800a1 [file] [log] [blame]
Michael Schaffner388f5d52020-01-15 12:04:40 -08001#!/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
16NUM_PROCS=8
Michael Schaffner76469e22020-08-10 10:13:23 -070017REPORT_FILE="verible-format.rpt"
18VERIBLE_VERSION=`verible-verilog-format --version`
19
20if [ -z $VERIBLE_VERSION ]; then
21 echo "verible-verilog-format either not installed or not visible in PATH"
22 exit 1
23fi
Michael Schaffner388f5d52020-01-15 12:04:40 -080024
25# this is a precaution in order to prevent accidental
26# overwriting of uncomitted changes
27git add -u
28
29# get all system verilog files and pipe through style formatter
30find hw/{ip,vendor,top_earlgrey} -type f -name "*.sv" -o -name "*.svh" | \
Michael Schaffner76469e22020-08-10 10:13:23 -070031 xargs -n 1 -P $NUM_PROCS verible-verilog-format \
Michael Schaffner388f5d52020-01-15 12:04:40 -080032 --inplace
33
Michael Schaffner76469e22020-08-10 10:13:23 -070034echo "Usign verible-verilog-format version $VERIBLE_VERSION" > $REPORT_FILE
35
Michael Schaffner388f5d52020-01-15 12:04:40 -080036# report changed files
37git status | \
38 grep modified | \
39 grep dv | \
40 awk -F ' ' '{print $2}' | \
Michael Schaffner76469e22020-08-10 10:13:23 -070041 tee -a $REPORT_FILE