< prev index next >

make/InitSupport.gmk

Print this page




 334   BUILD_LOG_PIPE := > >($(TEE) -a $(BUILD_LOG)) 2> >($(TEE) -a $(BUILD_LOG) >&2)
 335 
 336   # Sanity check the spec file, so it matches this source code
 337   define CheckSpecSanity
 338     ifneq ($$(ACTUAL_TOPDIR), $$(TOPDIR))
 339       ifneq ($$(ACTUAL_TOPDIR), $$(ORIGINAL_TOPDIR))
 340         ifneq ($$(ACTUAL_TOPDIR), $$(CANONICAL_TOPDIR))
 341           $$(info Error: SPEC mismatch! Current working directory)
 342           $$(info $$(ACTUAL_TOPDIR))
 343           $$(info does not match either TOPDIR, ORIGINAL_TOPDIR or CANONICAL_TOPDIR)
 344           $$(info $$(TOPDIR))
 345           $$(info $$(ORIGINAL_TOPDIR))
 346           $$(info $$(CANONICAL_TOPDIR))
 347           $$(error Cannot continue)
 348         endif
 349       endif
 350     endif
 351   endef
 352 
 353   # Parse COMPARE_BUILD into COMPARE_BUILD_*
 354   # Syntax: COMPARE_BUILD=CONF=<configure options>:PATCH=<patch file>:
 355   #         MAKE=<make targets>:COMP_OPTS=<compare script options>:
 356   #         COMP_DIR=<compare script base dir>|<default>

 357   # If neither CONF or PATCH is given, assume <default> means CONF if it
 358   # begins with "--", otherwise assume it means PATCH.
 359   # MAKE and COMP_OPTS can only be used with CONF and/or PATCH specified.
 360   # If any value contains "+", it will be replaced by space.

 361   define ParseCompareBuild
 362     ifneq ($$(COMPARE_BUILD), )
 363       COMPARE_BUILD_OUTPUT_ROOT := $(TOPDIR)/build/compare-build/$(CONF_NAME)

 364 
 365       ifneq ($$(findstring :, $$(COMPARE_BUILD)), )
 366         $$(foreach part, $$(subst :, , $$(COMPARE_BUILD)), \
 367           $$(if $$(filter PATCH=%, $$(part)), \
 368             $$(eval COMPARE_BUILD_PATCH=$$(strip $$(patsubst PATCH=%, %, $$(part)))) \
 369           ) \
 370           $$(if $$(filter CONF=%, $$(part)), \
 371             $$(eval COMPARE_BUILD_CONF=$$(strip $$(subst +, , $$(patsubst CONF=%, %, $$(part))))) \
 372           ) \
 373           $$(if $$(filter MAKE=%, $$(part)), \
 374             $$(eval COMPARE_BUILD_MAKE=$$(strip $$(subst +, , $$(patsubst MAKE=%, %, $$(part))))) \
 375           ) \
 376           $$(if $$(filter COMP_OPTS=%, $$(part)), \
 377             $$(eval COMPARE_BUILD_COMP_OPTS=$$(strip $$(subst +, , $$(patsubst COMP_OPTS=%, %, $$(part))))) \
 378           ) \
 379           $$(if $$(filter COMP_DIR=%, $$(part)), \
 380             $$(eval COMPARE_BUILD_COMP_DIR=$$(strip $$(subst +, , $$(patsubst COMP_DIR=%, %, $$(part))))) \
 381           ) \



 382         )
 383       else
 384         # Separate handling for single field case, to allow for spaces in values.
 385         ifneq ($$(filter PATCH=%, $$(COMPARE_BUILD)), )
 386           COMPARE_BUILD_PATCH=$$(strip $$(patsubst PATCH=%, %, $$(COMPARE_BUILD)))
 387         else ifneq ($$(filter CONF=%, $$(COMPARE_BUILD)), )
 388           COMPARE_BUILD_CONF=$$(strip $$(subst +, , $$(patsubst CONF=%, %, $$(COMPARE_BUILD))))
 389         else ifneq ($$(filter --%, $$(COMPARE_BUILD)), )
 390           # Assume CONF if value begins with --
 391           COMPARE_BUILD_CONF=$$(strip $$(subst +, , $$(COMPARE_BUILD)))
 392         else
 393           # Otherwise assume patch file
 394           COMPARE_BUILD_PATCH=$$(strip $$(COMPARE_BUILD))
 395         endif
 396       endif
 397       ifneq ($$(COMPARE_BUILD_PATCH), )
 398         ifneq ($$(wildcard $$(TOPDIR)/$$(COMPARE_BUILD_PATCH)), )
 399           # Assume relative path, if file exists
 400           COMPARE_BUILD_PATCH := $$(wildcard $$(TOPDIR)/$$(COMPARE_BUILD_PATCH))
 401         else ifeq ($$(wildcard $$(COMPARE_BUILD_PATCH)), )
 402           $$(error Patch file $$(COMPARE_BUILD_PATCH) does not exist)
 403         endif
 404       endif



 405     endif
 406   endef
 407 
 408   # Prepare for a comparison rebuild
 409   define PrepareCompareBuild
 410         $(ECHO) "Preparing for comparison rebuild"
 411         # Apply patch, if any
 412         $(if $(COMPARE_BUILD_PATCH), $(PATCH) -p1 < $(COMPARE_BUILD_PATCH))
 413         # Move the first build away temporarily
 414         $(RM) -r $(TOPDIR)/build/.compare-build-temp
 415         $(MKDIR) -p $(TOPDIR)/build/.compare-build-temp
 416         $(MV) $(OUTPUT_ROOT) $(TOPDIR)/build/.compare-build-temp
 417         # Restore an old compare-build, or create a new compare-build directory.
 418         if test -d $(COMPARE_BUILD_OUTPUT_ROOT); then \
 419           $(MV) $(COMPARE_BUILD_OUTPUT_ROOT) $(OUTPUT_ROOT); \
 420         else \
 421           $(MKDIR) -p $(OUTPUT_ROOT); \
 422         fi
 423         # Re-run configure with the same arguments (and possibly some additional),
 424         # must be done after patching.


 426             $(BASH) $(TOPDIR)/configure $(CONFIGURE_COMMAND_LINE) $(COMPARE_BUILD_CONF))
 427   endef
 428 
 429   # Cleanup after a compare build
 430   define CleanupCompareBuild
 431         # If running with a COMPARE_BUILD patch, reverse-apply it
 432         $(if $(COMPARE_BUILD_PATCH), $(PATCH) -R -p1 < $(COMPARE_BUILD_PATCH))
 433         # Move this build away and restore the original build
 434         $(MKDIR) -p $(TOPDIR)/build/compare-build
 435         $(MV) $(OUTPUT_ROOT) $(COMPARE_BUILD_OUTPUT_ROOT)
 436         $(MV) $(TOPDIR)/build/.compare-build-temp/$(CONF_NAME) $(OUTPUT_ROOT)
 437         $(RM) -r $(TOPDIR)/build/.compare-build-temp
 438   endef
 439 
 440   # Do the actual comparison of two builds
 441   define CompareBuildDoComparison
 442         # Compare first and second build. Ignore any error code from compare.sh.
 443         $(ECHO) "Comparing between comparison rebuild (this/new) and baseline (other/old)"
 444         $(if $(COMPARE_BUILD_COMP_DIR), \
 445           +(cd $(COMPARE_BUILD_OUTPUT_ROOT) && ./compare.sh $(COMPARE_BUILD_COMP_OPTS) \
 446               -2dirs $(COMPARE_BUILD_OUTPUT_ROOT)/$(COMPARE_BUILD_COMP_DIR) $(OUTPUT_ROOT)/$(COMPARE_BUILD_COMP_DIR) || true), \

 447           +(cd $(COMPARE_BUILD_OUTPUT_ROOT) && ./compare.sh $(COMPARE_BUILD_COMP_OPTS) \
 448               -o $(OUTPUT_ROOT) || true) \
 449         )
 450   endef
 451 
 452   define PrintFailureReports
 453         $(if $(wildcard $(MAKESUPPORT_OUTPUTDIR)/failure-logs/*), \
 454           $(PRINTF) "=== Output from failing command(s) repeated here ===\n" $(NEWLINE) \
 455           $(foreach logfile, $(sort $(wildcard $(MAKESUPPORT_OUTPUTDIR)/failure-logs/*)), \
 456               $(PRINTF) "* For target $(notdir $(basename $(logfile))):\n" $(NEWLINE) \
 457               ($(GREP) -v -e "^Note: including file:" <  $(logfile) || true) | $(HEAD) -n 12 $(NEWLINE) \
 458               if test `$(WC) -l < $(logfile)` -gt 12; then \
 459                 $(ECHO) "   ... (rest of output omitted)" ; \
 460               fi $(NEWLINE) \
 461           ) \
 462           $(PRINTF) "=== End of repeated output ===\n" \
 463         )
 464   endef
 465 
 466   define PrintBuildLogFailures
 467         if $(GREP) -q "recipe for target .* failed" $(BUILD_LOG) 2> /dev/null; then  \
 468           $(PRINTF) "=== Make failure sequence repeated here ===\n" ; \




 334   BUILD_LOG_PIPE := > >($(TEE) -a $(BUILD_LOG)) 2> >($(TEE) -a $(BUILD_LOG) >&2)
 335 
 336   # Sanity check the spec file, so it matches this source code
 337   define CheckSpecSanity
 338     ifneq ($$(ACTUAL_TOPDIR), $$(TOPDIR))
 339       ifneq ($$(ACTUAL_TOPDIR), $$(ORIGINAL_TOPDIR))
 340         ifneq ($$(ACTUAL_TOPDIR), $$(CANONICAL_TOPDIR))
 341           $$(info Error: SPEC mismatch! Current working directory)
 342           $$(info $$(ACTUAL_TOPDIR))
 343           $$(info does not match either TOPDIR, ORIGINAL_TOPDIR or CANONICAL_TOPDIR)
 344           $$(info $$(TOPDIR))
 345           $$(info $$(ORIGINAL_TOPDIR))
 346           $$(info $$(CANONICAL_TOPDIR))
 347           $$(error Cannot continue)
 348         endif
 349       endif
 350     endif
 351   endef
 352 
 353   # Parse COMPARE_BUILD into COMPARE_BUILD_*
 354   # Syntax: COMPARE_BUILD=CONF=<configure options>:PATCH=<patch file>:FAIL_BUILD=<bool>
 355   #         MAKE=<make targets>:COMP_OPTS=<compare script options>:
 356   #         COMP_DIR=<compare script base dir>|<default>
 357   #         FAIL=<bool>
 358   # If neither CONF or PATCH is given, assume <default> means CONF if it
 359   # begins with "--", otherwise assume it means PATCH.
 360   # MAKE and COMP_OPTS can only be used with CONF and/or PATCH specified.
 361   # If any value contains "+", it will be replaced by space.
 362   # FAIL can be set to false to have the return value of compare be ignored.
 363   define ParseCompareBuild
 364     ifneq ($$(COMPARE_BUILD), )
 365       COMPARE_BUILD_OUTPUT_ROOT := $(TOPDIR)/build/compare-build/$(CONF_NAME)
 366       COMPARE_BUILD_FAILE := true
 367 
 368       ifneq ($$(findstring :, $$(COMPARE_BUILD)), )
 369         $$(foreach part, $$(subst :, , $$(COMPARE_BUILD)), \
 370           $$(if $$(filter PATCH=%, $$(part)), \
 371             $$(eval COMPARE_BUILD_PATCH=$$(strip $$(patsubst PATCH=%, %, $$(part)))) \
 372           ) \
 373           $$(if $$(filter CONF=%, $$(part)), \
 374             $$(eval COMPARE_BUILD_CONF=$$(strip $$(subst +, , $$(patsubst CONF=%, %, $$(part))))) \
 375           ) \
 376           $$(if $$(filter MAKE=%, $$(part)), \
 377             $$(eval COMPARE_BUILD_MAKE=$$(strip $$(subst +, , $$(patsubst MAKE=%, %, $$(part))))) \
 378           ) \
 379           $$(if $$(filter COMP_OPTS=%, $$(part)), \
 380             $$(eval COMPARE_BUILD_COMP_OPTS=$$(strip $$(subst +, , $$(patsubst COMP_OPTS=%, %, $$(part))))) \
 381           ) \
 382           $$(if $$(filter COMP_DIR=%, $$(part)), \
 383             $$(eval COMPARE_BUILD_COMP_DIR=$$(strip $$(subst +, , $$(patsubst COMP_DIR=%, %, $$(part))))) \
 384           ) \
 385           $$(if $$(filter FAIL=%, $$(part)), \
 386             $$(eval COMPARE_BUILD_FAIL=$$(strip $$(subst +, , $$(patsubst FAIL=%, %, $$(part))))) \
 387           ) \
 388         )
 389       else
 390         # Separate handling for single field case, to allow for spaces in values.
 391         ifneq ($$(filter PATCH=%, $$(COMPARE_BUILD)), )
 392           COMPARE_BUILD_PATCH=$$(strip $$(patsubst PATCH=%, %, $$(COMPARE_BUILD)))
 393         else ifneq ($$(filter CONF=%, $$(COMPARE_BUILD)), )
 394           COMPARE_BUILD_CONF=$$(strip $$(subst +, , $$(patsubst CONF=%, %, $$(COMPARE_BUILD))))
 395         else ifneq ($$(filter --%, $$(COMPARE_BUILD)), )
 396           # Assume CONF if value begins with --
 397           COMPARE_BUILD_CONF=$$(strip $$(subst +, , $$(COMPARE_BUILD)))
 398         else
 399           # Otherwise assume patch file
 400           COMPARE_BUILD_PATCH=$$(strip $$(COMPARE_BUILD))
 401         endif
 402       endif
 403       ifneq ($$(COMPARE_BUILD_PATCH), )
 404         ifneq ($$(wildcard $$(TOPDIR)/$$(COMPARE_BUILD_PATCH)), )
 405           # Assume relative path, if file exists
 406           COMPARE_BUILD_PATCH := $$(wildcard $$(TOPDIR)/$$(COMPARE_BUILD_PATCH))
 407         else ifeq ($$(wildcard $$(COMPARE_BUILD_PATCH)), )
 408           $$(error Patch file $$(COMPARE_BUILD_PATCH) does not exist)
 409         endif
 410       endif
 411       ifneq ($$(COMPARE_BUILD_FAIL), true)
 412         COMPARE_BUILD_IGNORE_RESULT := || true
 413       endif
 414     endif
 415   endef
 416 
 417   # Prepare for a comparison rebuild
 418   define PrepareCompareBuild
 419         $(ECHO) "Preparing for comparison rebuild"
 420         # Apply patch, if any
 421         $(if $(COMPARE_BUILD_PATCH), $(PATCH) -p1 < $(COMPARE_BUILD_PATCH))
 422         # Move the first build away temporarily
 423         $(RM) -r $(TOPDIR)/build/.compare-build-temp
 424         $(MKDIR) -p $(TOPDIR)/build/.compare-build-temp
 425         $(MV) $(OUTPUT_ROOT) $(TOPDIR)/build/.compare-build-temp
 426         # Restore an old compare-build, or create a new compare-build directory.
 427         if test -d $(COMPARE_BUILD_OUTPUT_ROOT); then \
 428           $(MV) $(COMPARE_BUILD_OUTPUT_ROOT) $(OUTPUT_ROOT); \
 429         else \
 430           $(MKDIR) -p $(OUTPUT_ROOT); \
 431         fi
 432         # Re-run configure with the same arguments (and possibly some additional),
 433         # must be done after patching.


 435             $(BASH) $(TOPDIR)/configure $(CONFIGURE_COMMAND_LINE) $(COMPARE_BUILD_CONF))
 436   endef
 437 
 438   # Cleanup after a compare build
 439   define CleanupCompareBuild
 440         # If running with a COMPARE_BUILD patch, reverse-apply it
 441         $(if $(COMPARE_BUILD_PATCH), $(PATCH) -R -p1 < $(COMPARE_BUILD_PATCH))
 442         # Move this build away and restore the original build
 443         $(MKDIR) -p $(TOPDIR)/build/compare-build
 444         $(MV) $(OUTPUT_ROOT) $(COMPARE_BUILD_OUTPUT_ROOT)
 445         $(MV) $(TOPDIR)/build/.compare-build-temp/$(CONF_NAME) $(OUTPUT_ROOT)
 446         $(RM) -r $(TOPDIR)/build/.compare-build-temp
 447   endef
 448 
 449   # Do the actual comparison of two builds
 450   define CompareBuildDoComparison
 451         # Compare first and second build. Ignore any error code from compare.sh.
 452         $(ECHO) "Comparing between comparison rebuild (this/new) and baseline (other/old)"
 453         $(if $(COMPARE_BUILD_COMP_DIR), \
 454           +(cd $(COMPARE_BUILD_OUTPUT_ROOT) && ./compare.sh $(COMPARE_BUILD_COMP_OPTS) \
 455               -2dirs $(COMPARE_BUILD_OUTPUT_ROOT)/$(COMPARE_BUILD_COMP_DIR) \
 456               $(OUTPUT_ROOT)/$(COMPARE_BUILD_COMP_DIR) $(COMPARE_BUILD_IGNORE_RESULT)), \
 457           +(cd $(COMPARE_BUILD_OUTPUT_ROOT) && ./compare.sh $(COMPARE_BUILD_COMP_OPTS) \
 458               -o $(OUTPUT_ROOT) $(COMPARE_BUILD_IGNORE_RESULT)) \
 459         )
 460   endef
 461 
 462   define PrintFailureReports
 463         $(if $(wildcard $(MAKESUPPORT_OUTPUTDIR)/failure-logs/*), \
 464           $(PRINTF) "=== Output from failing command(s) repeated here ===\n" $(NEWLINE) \
 465           $(foreach logfile, $(sort $(wildcard $(MAKESUPPORT_OUTPUTDIR)/failure-logs/*)), \
 466               $(PRINTF) "* For target $(notdir $(basename $(logfile))):\n" $(NEWLINE) \
 467               ($(GREP) -v -e "^Note: including file:" <  $(logfile) || true) | $(HEAD) -n 12 $(NEWLINE) \
 468               if test `$(WC) -l < $(logfile)` -gt 12; then \
 469                 $(ECHO) "   ... (rest of output omitted)" ; \
 470               fi $(NEWLINE) \
 471           ) \
 472           $(PRINTF) "=== End of repeated output ===\n" \
 473         )
 474   endef
 475 
 476   define PrintBuildLogFailures
 477         if $(GREP) -q "recipe for target .* failed" $(BUILD_LOG) 2> /dev/null; then  \
 478           $(PRINTF) "=== Make failure sequence repeated here ===\n" ; \


< prev index next >