1#!/bin/bash
2# Copyright (C) 2019-2022 Intel Corporation.
3# SPDX-License-Identifier: BSD-3-Clause
4
5# run the filter-known-issues.py script to remove "expected" warning
6# messages from the output of the document build process and write
7# the filtered output to stdout
8#
9# Only argument is the name of the log file saved by the build.
10
11KI_SCRIPT=scripts/filter-known-issues.py
12CONFIG_DIR=.known-issues/doc
13
14LOG_FILE=$1
15BUILDDIR=$(dirname $LOG_FILE)
16
17if [ -z "${LOG_FILE}" ]; then
18        echo "Error in $0: missing input parameter <logfile>"
19        exit 1
20fi
21
22# When running in background, detached from terminal jobs, tput will
23# fail; we usually can tell because there is no TERM env variable.
24if [ -z "${TERM:-}" -o "${TERM:-}" = dumb ]; then
25    TPUT="true"
26    red=''
27    green=''
28else
29    TPUT="tput"
30    red='\E[31m'
31    green='\e[32m'
32fi
33
34if [ -s "${LOG_FILE}" ]; then
35   $KI_SCRIPT --config-dir ${CONFIG_DIR} ${LOG_FILE} > ${BUILDDIR}/doc.warnings 2>&1
36   if [ -s ${BUILDDIR}/doc.warnings ]; then
37	   echo
38	   echo -e "${red}New errors/warnings found, please fix them:"
39	   echo -e "=============================================="
40	   $TPUT sgr0
41	   echo
42	   cat ${BUILDDIR}/doc.warnings
43	   echo
44	   exit 1
45   else
46	   echo -e "${green}No new errors/warnings."
47	   $TPUT sgr0
48   fi
49
50else
51   echo "Error in $0: logfile \"${LOG_FILE}\" not found."
52   exit 1
53fi
54