Commit 454e7162 authored by Michael Shigorin's avatar Michael Shigorin

no build means *no* build (and less reports), really

It's hard to tell a successful build from a failed one if downstream hides the exit code; it's useless to continue a `for' loop if a pipe shoves that to a subshell; well it seems that a bashism is worth a thousand quirks with extra fds here. Minor regexp enhancements are also due. reports.mk made a bit more resilient/prudent either.
parent 0439df31
......@@ -30,9 +30,13 @@ $(DIRECT_TARGETS):
export NUM_TARGETS := $(words $(MAKECMDGOALS))
# for pipefail
SHELL = /bin/bash
# real targets need real work
%:
@n=1; \
set -o pipefail; \
say() { echo "$$@" >&2; }; \
if [ "$(NUM_TARGETS)" -gt 1 ]; then \
n="`echo $(MAKECMDGOALS) \
......
......@@ -2,7 +2,8 @@
ANSI_OK ?= 1;32
ANSI_FAIL ?= 1;31
GOTCHA := ^(((\*\* )?(E:|[Ee]rror|[Ww]arning).*)|(.* (Stop|failed)\.))$$
MAX_ERRORS = 3
GOTCHA := ^(((\*\* )?(E:|[Ee]rror|[Ww]arning).*)|(.* (conflicts|Depends:) .*)|(.* (Stop|failed)\.))$$
ifndef MKIMAGE_PROFILES
$(error this makefile is designed to be included in toplevel one)
......@@ -51,7 +52,9 @@ build-image: profile/populate
tail -200 "$(BUILDLOG)" $(SHORTEN) \
| GREP_COLOR="$(ANSI_OK)" GREP_OPTIONS="--color=auto" \
grep '^\*\* image: .*$$' ||:; \
RETVAL=0; \
else \
RETVAL=$$?; \
echo -n "$(TIME) failed, see log"; \
if [ -z "$(DEBUG)" ]; then \
echo ": $(BUILDLOG)" $(SHORTEN); \
......@@ -61,9 +64,10 @@ build-image: profile/populate
fi; \
tail -200 "$(BUILDLOG)" \
| GREP_COLOR="$(ANSI_FAIL)" GREP_OPTIONS="--color=auto" \
egrep "$(GOTCHA)"; \
egrep -m "$(MAX_ERRORS)" "$(GOTCHA)"; \
df -P $(BUILDDIR) | awk 'END { if ($$4 < $(LOWSPACE)) \
{ print "NB: low space on "$$6" ("$$5" used)"}}'; \
fi; \
if [ -n "$(BELL)" ]; then echo -ne '\a'; fi; \
exit $$RETVAL; \
} >&2
......@@ -24,25 +24,31 @@ reports/prep:
@mkdir -p "$(REPORTDIR)"
reports/scripts: reports/prep
@grep "^mki.*scripts: Run: " $(BUILDLOG) \
| sed -rn "s,^.*($(BUILDDIR)|$(SYMLINK))/(.*)'$$,\2,p" \
> "$(REPORTDIR)/$*.log" \
&& echo "** scripts report: $(REPORTDIR)/$(@F).log" $(SHORTEN)
@OUT="$(REPORTDIR)/$(@F).log"; \
grep "^mki.*scripts: Run: " $(BUILDLOG) \
| sed -rn "s,^.*($(BUILDDIR)|$(SYMLINK))/(.*)'$$,\2,p" > "$$OUT" \
&& if [ -s "$$OUT" ]; then \
echo "** scripts report: $$OUT" $(SHORTEN); \
fi
reports/targets: reports/prep
@if ! [ -n "$(REPORT_PATH)" -a -s "$(REPORT_PATH)" ]; then \
exit 0; \
fi; \
if type -t dot >&/dev/null; then \
REPORT_IMAGE="$(REPORTDIR)/$(@F).png"; \
OUT="$(REPORTDIR)/$(@F).png"; \
report-targets < "$(REPORT_PATH)" \
| dot -Tpng -o "$$REPORT_IMAGE" \
&& echo "** target graph report: $$REPORT_IMAGE"; \
| dot -Tpng -o "$$OUT" \
&& if [ -s "$$OUT" ]; then \
echo "** target graph report: $$OUT"; \
fi; \
else \
REPORT_DOT="$(BUILDDIR)/targets.dot"; \
report-targets < "$(REPORT_PATH)" > "$$REPORT_DOT" \
&& echo "** graphviz missing, " \
"target graph dot file: $$REPORT_DOT"; \
OUT="$(BUILDDIR)/targets.dot"; \
report-targets < "$(REPORT_PATH)" > "$$OUT" \
&& if [ -s "$$OUT" ]; then \
echo "** graphviz missing, " \
"target graph dot file: $$OUT"; \
fi; \
fi $(SHORTEN); \
mv "$(REPORT_PATH)" "$(REPORTDIR)/$(@F).log"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment