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.
This commit is contained in:
Michael Shigorin 2012-04-25 16:56:48 +03:00
parent 0439df3159
commit 454e7162f3
3 changed files with 27 additions and 13 deletions

View File

@ -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) \

View File

@ -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

View File

@ -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"