8173120: Preserve command line at build failure

Reviewed-by: erikj
This commit is contained in:
Magnus Ihse Bursie 2017-01-20 14:44:17 +01:00
parent dd3c209701
commit 0a56b1da95
2 changed files with 10 additions and 8 deletions

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -460,27 +460,28 @@ else # $(HAS_SPEC)=true
endef
define PrintFailureReports
$(if $(wildcard $(MAKESUPPORT_OUTPUTDIR)/failure-logs/*), \
$(PRINTF) "=== Output from failing command(s) repeated here ===\n" $(NEWLINE) \
$(foreach logfile, $(sort $(wildcard $(MAKESUPPORT_OUTPUTDIR)/failure-logs/*)), \
$(if $(wildcard $(MAKESUPPORT_OUTPUTDIR)/failure-logs/*.log), \
$(PRINTF) "\n=== Output from failing command(s) repeated here ===\n" $(NEWLINE) \
$(foreach logfile, $(sort $(wildcard $(MAKESUPPORT_OUTPUTDIR)/failure-logs/*.log)), \
$(PRINTF) "* For target $(notdir $(basename $(logfile))):\n" $(NEWLINE) \
($(GREP) -v -e "^Note: including file:" < $(logfile) || true) | $(HEAD) -n 12 $(NEWLINE) \
if test `$(WC) -l < $(logfile)` -gt 12; then \
$(ECHO) " ... (rest of output omitted)" ; \
fi $(NEWLINE) \
) \
$(PRINTF) "\n* All command lines available in $(MAKESUPPORT_OUTPUTDIR)/failure-logs.\n" $(NEWLINE) \
$(PRINTF) "=== End of repeated output ===\n" \
)
endef
define PrintBuildLogFailures
if $(GREP) -q "recipe for target .* failed" $(BUILD_LOG) 2> /dev/null; then \
$(PRINTF) "=== Make failure sequence repeated here ===\n" ; \
$(PRINTF) "\n=== Make failed targets repeated here ===\n" ; \
$(GREP) "recipe for target .* failed" $(BUILD_LOG) ; \
$(PRINTF) "=== End of repeated output ===\n" ; \
$(PRINTF) "Hint: Try searching the build log for the name of the first failed target.\n" ; \
$(PRINTF) "\nHint: Try searching the build log for the name of the first failed target.\n" ; \
else \
$(PRINTF) "No indication of failed target found.\n" ; \
$(PRINTF) "\nNo indication of failed target found.\n" ; \
$(PRINTF) "Hint: Try searching the build log for '] Error'.\n" ; \
fi
endef

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -862,6 +862,7 @@ ExecuteWithLog = \
( $(strip $2) > >($(TEE) $(strip $1).log) 2> >($(TEE) $(strip $1).log >&2) || \
( exitcode=$(DOLLAR)? && \
$(CP) $(strip $1).log $(MAKESUPPORT_OUTPUTDIR)/failure-logs/$(subst /,_,$(patsubst $(BUILD_OUTPUT)/%,%,$(strip $1))).log && \
$(CP) $(strip $1).cmdline $(MAKESUPPORT_OUTPUTDIR)/failure-logs/$(subst /,_,$(patsubst $(BUILD_OUTPUT)/%,%,$(strip $1))).cmdline && \
exit $(DOLLAR)exitcode ) )
################################################################################