8141696: Improve COMPARE_BUILD

Reviewed-by: tbell, erikj
This commit is contained in:
Magnus Ihse Bursie 2015-11-10 11:41:21 +01:00
parent 44b3e9e0fe
commit 209ebcfafa
2 changed files with 77 additions and 37 deletions

View File

@ -305,49 +305,20 @@ else # HAS_SPEC=true
endif
on-failure:
ifneq ($(wildcard $(MAKESUPPORT_OUTPUTDIR)/failure-logs/*), )
$(PRINTF) "=== Output from failing command(s) repeated here ===\n"
$(foreach logfile, $(sort $(wildcard $(MAKESUPPORT_OUTPUTDIR)/failure-logs/*)), \
$(PRINTF) "* For target $(notdir $(basename $(logfile))):\n" $(NEWLINE) \
$(CAT) $(logfile) | $(GREP) -v -e "^Note: including file:" $(NEWLINE) \
)
$(PRINTF) "=== End of repeated output ===\n"
endif
if $(GREP) -q "recipe for target .* failed" $(BUILD_LOG) 2> /dev/null; then \
$(PRINTF) "=== Make failure sequence 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" ; \
else \
$(PRINTF) "No indication of failed target found.\n" ; \
$(PRINTF) "Hint: Try searching the build log for '] Error'.\n" ; \
fi
$(call PrintFailureReports)
$(call PrintBuildLogFailures)
$(PRINTF) "Hint: If caused by a warning, try configure --disable-warnings-as-errors.\n\n"
ifneq ($(COMPARE_BUILD), )
$(call CleanupCompareBuild)
endif
# Support targets for COMPARE_BUILD, used for makefile development
pre-compare-build:
$(ECHO) "Preparing for comparison rebuild"
# Apply patch, if any
ifneq ($(COMPARE_BUILD_PATCH), )
$(PATCH) -p1 < $(COMPARE_BUILD_PATCH)
endif
# Move the first build away and re-create the output directory
( cd $(TOPDIR) && \
$(MV) $(OUTPUT_ROOT) $(OUTPUT_ROOT).OLD && \
$(MKDIR) -p $(OUTPUT_ROOT) )
# Re-run configure with the same arguments (and possibly some additional),
# must be done after patching.
( cd $(OUTPUT_ROOT) && PATH="$(ORIGINAL_PATH)" \
$(BASH) $(TOPDIR)/configure $(CONFIGURE_COMMAND_LINE) $(COMPARE_BUILD_CONF))
$(call PrepareCompareBuild)
post-compare-build:
# Compare first and second build. Ignore any error code from compare.sh.
$(ECHO) "Comparing between comparison rebuild (this/new) and baseline (other/old)"
ifneq ($(COMPARE_BUILD_COMP_DIR), )
+(cd $(OUTPUT_ROOT) && ./compare.sh $(COMPARE_BUILD_COMP_OPTS) -2dirs $(OUTPUT_ROOT)/$(COMPARE_BUILD_COMP_DIR) $(OUTPUT_ROOT).OLD/$(COMPARE_BUILD_COMP_DIR) || true)
else
+(cd $(OUTPUT_ROOT) && ./compare.sh $(COMPARE_BUILD_COMP_OPTS) -o $(OUTPUT_ROOT).OLD || true)
endif
$(call CleanupCompareBuild)
$(call CompareBuildDoComparison)
.PHONY: print-targets print-modules reconfigure main on-failure
endif

View File

@ -321,6 +321,8 @@ else # $(HAS_SPEC)=true
# If any value contains "+", it will be replaced by space.
define ParseCompareBuild
ifneq ($$(COMPARE_BUILD), )
COMPARE_BUILD_OUTPUT_ROOT := $(TOPDIR)/build/compare-build/$(CONF_NAME)
ifneq ($$(findstring :, $$(COMPARE_BUILD)), )
$$(foreach part, $$(subst :, , $$(COMPARE_BUILD)), \
$$(if $$(filter PATCH=%, $$(part)), \
@ -364,6 +366,73 @@ else # $(HAS_SPEC)=true
endif
endef
# Prepare for a comparison rebuild
define PrepareCompareBuild
$(ECHO) "Preparing for comparison rebuild"
# Apply patch, if any
$(if $(COMPARE_BUILD_PATCH), $(PATCH) -p1 < $(COMPARE_BUILD_PATCH))
# Move the first build away temporarily
$(RM) -r $(TOPDIR)/build/.compare-build-temp
$(MKDIR) -p $(TOPDIR)/build/.compare-build-temp
$(MV) $(OUTPUT_ROOT) $(TOPDIR)/build/.compare-build-temp
# Restore an old compare-build, or create a new compare-build directory.
if test -d $(COMPARE_BUILD_OUTPUT_ROOT); then \
$(MV) $(COMPARE_BUILD_OUTPUT_ROOT) $(OUTPUT_ROOT); \
else \
$(MKDIR) -p $(OUTPUT_ROOT); \
fi
# Re-run configure with the same arguments (and possibly some additional),
# must be done after patching.
( cd $(OUTPUT_ROOT) && PATH="$(ORIGINAL_PATH)" \
$(BASH) $(TOPDIR)/configure $(CONFIGURE_COMMAND_LINE) $(COMPARE_BUILD_CONF))
endef
# Cleanup after a compare build
define CleanupCompareBuild
# If running with a COMPARE_BUILD patch, reverse-apply it
$(if $(COMPARE_BUILD_PATCH), $(PATCH) -R -p1 < $(COMPARE_BUILD_PATCH))
# Move this build away and restore the original build
$(MKDIR) -p $(TOPDIR)/build/compare-build
$(MV) $(OUTPUT_ROOT) $(COMPARE_BUILD_OUTPUT_ROOT)
$(MV) $(TOPDIR)/build/.compare-build-temp/$(CONF_NAME) $(OUTPUT_ROOT)
$(RM) -r $(TOPDIR)/build/.compare-build-temp
endef
# Do the actual comparison of two builds
define CompareBuildDoComparison
# Compare first and second build. Ignore any error code from compare.sh.
$(ECHO) "Comparing between comparison rebuild (this/new) and baseline (other/old)"
$(if $(COMPARE_BUILD_COMP_DIR), \
+(cd $(COMPARE_BUILD_OUTPUT_ROOT) && ./compare.sh $(COMPARE_BUILD_COMP_OPTS) \
-2dirs $(COMPARE_BUILD_OUTPUT_ROOT)/$(COMPARE_BUILD_COMP_DIR) $(OUTPUT_ROOT)/$(COMPARE_BUILD_COMP_DIR) || true), \
+(cd $(COMPARE_BUILD_OUTPUT_ROOT) && ./compare.sh $(COMPARE_BUILD_COMP_OPTS) \
-o $(OUTPUT_ROOT) || 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/*)), \
$(PRINTF) "* For target $(notdir $(basename $(logfile))):\n" $(NEWLINE) \
$(CAT) $(logfile) | $(GREP) -v -e "^Note: including file:" $(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" ; \
$(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" ; \
else \
$(PRINTF) "No indication of failed target found.\n" ; \
$(PRINTF) "Hint: Try searching the build log for '] Error'.\n" ; \
fi
endef
define RotateLogFiles
$(RM) $(BUILD_LOG).old 2> /dev/null
$(MV) $(BUILD_LOG) $(BUILD_LOG).old 2> /dev/null || true