zephyr/doc/scripts/filter-doc-log.sh
Ulf Magnusson 6188579063 filter-doc-log.sh: Fix error for empty log file
Running 'make html' in doc/ when doc.log is missing or empty gives the
following error if sphinx-build doesn't write anything on stdout/stderr:

    Error in ./scripts/filter-doc-log.sh: logfile "doc.log" not found.
    Makefile:84: recipe for target ”html” failed
    make: *** [html] Error 1

The problem is that scripts/filter-doc-log.sh tests for the existence of
the log file with [ -s ${LOG_FILE} ], which requires it to be nonempty.

Fix it by using -e instead, which only checks if the log file exists.
scripts/filter-known-issues.py ($KI_SCRIPT) seems to be able to deal
with empty files (and runs quickly).

Fixes #6854

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2018-03-29 08:26:47 -04:00

50 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# run the filter-known-issues.py script to remove "expected" warning
# messages from the output of the document build process and write
# the filtered output to stdout
#
# Only argument is the name of the log file saved by the build.
KI_SCRIPT=${ZEPHYR_BASE}/scripts/filter-known-issues.py
CONFIG_DIR=${ZEPHYR_BASE}/.known-issues/doc
LOG_FILE=$1
if [ -z "${LOG_FILE}" ]; then
echo "Error in $0: missing input parameter <logfile>"
exit 1
fi
# When running in background, detached from terminal jobs, tput will
# fail; we usually can tell because there is no TERM env variable.
if [ -z "${TERM:-}" -o "${TERM:-}" = dumb ]; then
TPUT="true"
red=''
green=''
else
TPUT="tput"
red='\E[31m'
green='\e[32m'
fi
if [ -e "${LOG_FILE}" ]; then
$KI_SCRIPT --config-dir ${CONFIG_DIR} ${LOG_FILE} > doc.warnings 2>&1
if [ -s doc.warnings ]; then
echo
echo -e "${red}New errors/warnings found, please fix them:"
echo -e "=============================================="
$TPUT sgr0
echo
cat doc.warnings
echo
else
echo -e "${green}No new errors/warnings."
$TPUT sgr0
fi
else
echo "Error in $0: logfile \"${LOG_FILE}\" not found."
exit 1
fi