Minos Galanakis | f4ca6ac | 2017-12-11 02:39:21 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | #------------------------------------------------------------------------------- |
| 3 | # Copyright (c) 2018-2019, Arm Limited and Contributors. All rights reserved. |
| 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | #------------------------------------------------------------------------------- |
| 8 | |
| 9 | ## |
| 10 | ##@file |
| 11 | ##@brief This script is to make a summary of run-checkpatch.sh generated output |
| 12 | ##files. |
| 13 | ## |
| 14 | ##The generated summary will hold the number of error and warning messages for |
| 15 | ##each file. |
| 16 | ## |
| 17 | ##The first parameter of the script must be the location of input file. |
| 18 | ## |
| 19 | |
| 20 | #Check parameter |
| 21 | if [ -z ${1+x} ] |
| 22 | then |
| 23 | echo "Checkpatch output file not specified!" |
| 24 | exit 1 |
| 25 | fi |
| 26 | |
| 27 | infile="$1" |
| 28 | |
| 29 | #Find the summary line for each file. Cut the summary line plus the file name |
| 30 | #the previous line. |
| 31 | #Concatenate the current line to the previos one, |
| 32 | #Print the two lines match the following regexp: |
| 33 | # remember anything any number of non : characters (this is the file path) |
| 34 | # followed by a : |
| 35 | # match any nuber of following characters till "total:" is found |
| 36 | # remember all characters after "total:" (this is the summary) |
| 37 | # replace the matched string with first and and the second match concatenated |
| 38 | # with new line and a tab character in between. |
| 39 | # we use s: single line and m: multi line modificators for the regexp match |
| 40 | res=$(perl -ne '$l=$l.$_; print "$l" if $l=~s/.*?([^:]+):.*\ntotal:(.*)/$1:\n\t$2/sm;$l=$_;' "$infile") |
| 41 | |
| 42 | #Print the result to standard output. |
| 43 | cat <<EOM |
| 44 | Checkpatch result summary: |
| 45 | $res |
| 46 | EOM |