Clean up logging and error handling
All checks were successful
the build was successful

This commit is contained in:
Reinhard Müller 2019-03-11 20:53:35 +01:00
parent fa0965202c
commit 89954e37cf
5 changed files with 46 additions and 50 deletions

View File

@ -18,7 +18,8 @@ SUBDIRS := $(shell find */* -name "Makefile" | xargs dirname)
all: $(SUBDIRS)
$(SUBDIRS): .FORCE
$(MAKE) -j -k -C $@ || true
@echo "* Preparing subdirectory $*"
@$(MAKE) -j -k -C $@
# -----------------------------------------------------------------------------
# Handle local menus

View File

@ -7,46 +7,48 @@ inc_buildrun=true
[ -z "$inc_misc" ] && . "$basedir/build/misc.sh"
build_into(){
set -o pipefail
printf %s "$start_time" > "$(logname start_time)"
ncpu="$(grep -c ^processor /proc/cpuinfo)"
[ -n "$statusdir" ] && cp "$basedir/build/status.html.sh" "$statusdir/index.cgi"
printf %s "$start_time" |logstatus start_time
[ -f "$(logname lasterror)" ] && rm "$(logname lasterror)"
[ -f "$(logname debug)" ] && rm "$(logname debug)"
forcelog Makefile
(
# Make sure that the following pipe exits with a nonzero exit code if the
# make run fails.
set -o pipefail
make -C "$basedir" | t_logstatus premake
) || exit 1
{
echo "Starting phase 1" \
&& make -C "$basedir" --no-print-directory 2>&1 \
&& echo "Finishing phase 1" \
|| die "Error during phase 1"
} | t_logstatus phase_1 || exit 1
dir_maker "$basedir" "$stagedir" || exit 1
tree_maker "$basedir" "$stagedir" > "$(logname Makefile)" || exit 1
{
tree_maker "$basedir" "$stagedir" 2>&1 \
|| die "Error during phase 2 Makefile generation"
} > "$(logname Makefile)" || exit 1
(
# Make sure that the following pipe exits with a nonzero exit code if the
# make run fails.
set -o pipefail
if ! make -j $ncpu -f "$(logname Makefile)" all 2>&1; then
die "See buildlog for errors reported by Make"
fi | t_logstatus buildlog
) || exit 1
{
echo "Starting phase 2" \
&& make -j $ncpu -f "$(logname Makefile)" 2>&1 \
&& echo "Finishing phase 2" \
|| die "Error during phase 2"
} | t_logstatus phase_2 || exit 1
if [ "$stagedir" != "$target" ]; then
rsync -av --del "$stagedir/" "$target/" | t_logstatus stagesync
fi
date +%s | logstatus end_time
date +%s > "$(logname end_time)"
if [ -n "$statusdir" ]; then
cd "$statusdir"
./index.cgi |tail -n+3 >status_$(date +%s).html
cd -
( cd "$statusdir"; ./index.cgi | tail -n+3 > status_$(date +%s).html )
fi
}

View File

@ -254,4 +254,3 @@ clean:
EOF
}

View File

@ -37,12 +37,11 @@ htmlcat(){
}
start_time=$(cat "start_time" || stat -c %Y "$0" || echo 0)
t_svnupdate=$(stat -c %Y "SVNlatest" ||echo 0)
t_gitupdate=$(stat -c %Y "GITlatest" ||echo 0)
t_premake=$(stat -c %Y "premake" ||echo 0)
t_phase_1=$(stat -c %Y "phase_1" ||echo 0)
t_makefile=$(stat -c %Y "Makefile" ||echo 0)
t_phase_2=$(stat -c %Y "phase_2" ||echo 0)
t_manifest=$(stat -c %Y "manifest" ||echo 0)
t_makerun=$(stat -c %Y "buildlog" ||echo 0)
t_stagesync=$(stat -c %Y "stagesync" ||echo 0)
end_time=$(cat "end_time" || echo 0)
duration=$(($end_time - $start_time))
@ -192,54 +191,43 @@ label {
)"
)
<h2>VCS changes</h2>$(
<h2>GIT changes</h2>$(
if [ ${start_time} -le ${t_gitupdate} ]; then
web_tab VCS_tab "at $(timestamp ${t_gitupdate})" "<pre>$(htmlcat GITlatest)</pre>" checked
elif [ ${start_time} -le ${t_svnupdate} ]; then
web_tab VCS_tab "at $(timestamp ${t_svnupdate})" "<pre>$(htmlcat SVNlatest)</pre>" checked
else
web_tab VCS_tab "Unconditional build, changes ignored" ""
fi)
<h2>Phase 1</h2>$(
if [ $start_time -lt $t_premake -a $start_time -lt $t_gitupdate ]; then
web_tab Premaketab "Premake run time $(duration $(($t_premake - $t_gitupdate)))" "<pre>$(tail premake |htmlcat)</pre><a href="premake">full log</a>"
elif [ $start_time -lt $t_premake -a $start_time -lt $t_svnupdate ]; then
web_tab Premaketab "Premake run time $(duration $(($t_premake - $t_svnupdate)))" "<pre>$(tail premake |htmlcat)</pre><a href="premake">full log</a>"
elif [ $start_time -lt $t_premake ]; then
web_tab Premaketab "Premake run time $(duration $(($t_premake - $start_time)))" "<pre>$(tail premake |htmlcat)</pre><a href="premake">full log</a>"
if [ $start_time -lt $t_phase_1 -a $start_time -lt $t_gitupdate ]; then
web_tab Premaketab "Premake run time $(duration $(($t_phase_1 - $t_gitupdate)))" "<pre>$(tail phase_1 |htmlcat)</pre><a href=\"phase_1\">full log</a>"
elif [ $start_time -lt $t_phase_1 ]; then
web_tab Premaketab "Premake run time $(duration $(($t_phase_1 - $start_time)))" "<pre>$(tail phase_1 |htmlcat)</pre><a href=\"phase_1\">full log</a>"
else
web_tab Premaketab "waiting..." ""
fi)
<h2>Phase 2 Makefile</h2>$(
if [ $start_time -lt $t_makefile ]; then
web_tab Makefiletab "Generation time: $(duration $(($t_makefile - $t_premake)) )" "
"<a href="Makefile">view</a>"
web_tab Makefiletab "Generation time: $(duration $(($t_makefile - $t_phase_1)) )" \
"<a href=\"Makefile\">view</a>"
else
web_tab Makefiletab "waiting..." ""
fi)
<h2>Phase 2</h2>$(
if [ $start_time -lt $t_makerun ]; then
web_tab Makeruntab "Build time: $(duration $(($t_makerun - $t_makefile)) )" "<pre>$(tail buildlog |htmlcat)</pre><a href=\"buildlog\">view full</a>"
if [ $start_time -lt $t_phase_2 ]; then
web_tab Makeruntab "Build time: $(duration $(($t_phase_2 - $t_makefile)) )" "<pre>$(tail phase_2 |htmlcat)</pre><a href=\"phase_2\">view full</a>"
else
web_tab Makeruntab "waiting..." ""
fi)
<h2>Errors</h2>$(
if [ -f lasterror ]; then
web_tab Errortab "There were errors" "<pre>$(htmlcat lasterror)</pre>"
else
web_tab Errortab "none" ""
fi)
<h2>File Manifest</h2>$(
if [ $start_time -lt $t_manifest ]; then
web_tab Manifesttab "Number of files: $(wc -l manifest | cut -d\ -f1)" "
<a href=\"manifest\">view</a>"
else
web_tab Makeruntab "waiting..." ""
web_tab Manifesttab "waiting..." ""
fi)
<h2>Files updated</h2>$(
@ -251,6 +239,12 @@ label {
web_tab Updatedtab "-" ""
fi)
<h2>Errors</h2>$(
if [ -f lasterror ]; then
web_tab Errortab "There were errors" "<pre>$(htmlcat lasterror)</pre>"
else
web_tab Errortab "none" ""
fi)
</body>
</html>

View File

@ -20,7 +20,7 @@ GENERATED_XML_SOURCES := $(patsubst %.xml,%.xhtml,$(subst /.,/,$(GENERATED_XML))
all: $(GENERATED_XML_SOURCES)
%.xhtml:
@echo '* Removing $(subst /,/.,$*).xml'
@echo '* Removing $(subst /,/.,$*).xml'
@rm '$(subst /,/.,$*).xml'
# -----------------------------------------------------------------------------
@ -38,5 +38,5 @@ XML := $(patsubst %.xhtml,%.xml,$(subst /,/.,$(XHTML)))
all: $(XML)
XMLSOURCE = $(patsubst %.xml,%.xhtml,$(subst /.,/,$@))
%.xml: $$(XMLSOURCE) xhtml2xml.xsl
@echo '* Generating $@'
@echo '* Generating $@'
@xsltproc --stringparam link '/news/$(basename $(basename $<)).html' xhtml2xml.xsl '$<' > '$@'