make/Init.gmk
changeset 32344 0b288e0efcfa
parent 30415 c5629d65265d
child 32461 e1cfbafc4e9c
equal deleted inserted replaced
32341:3c9f5bd909ae 32344:0b288e0efcfa
   251   main: MAKEOVERRIDES :=
   251   main: MAKEOVERRIDES :=
   252 
   252 
   253   main: $(INIT_TARGETS)
   253   main: $(INIT_TARGETS)
   254         ifneq ($(SEQUENTIAL_TARGETS)$(PARALLEL_TARGETS), )
   254         ifneq ($(SEQUENTIAL_TARGETS)$(PARALLEL_TARGETS), )
   255 	  $(call RotateLogFiles)
   255 	  $(call RotateLogFiles)
       
   256 	  $(call PrepareFailureLogs)
   256 	  $(BUILD_LOG_WRAPPER) $(PRINTF) "Building $(TARGET_DESCRIPTION)\n"
   257 	  $(BUILD_LOG_WRAPPER) $(PRINTF) "Building $(TARGET_DESCRIPTION)\n"
   257           ifneq ($(SEQUENTIAL_TARGETS), )
   258           ifneq ($(SEQUENTIAL_TARGETS), )
   258             # Don't touch build output dir since we might be cleaning. That
   259             # Don't touch build output dir since we might be cleaning. That
   259             # means no log wrapper.
   260             # means no log wrapper.
   260 	    ( cd $(TOPDIR) && \
   261 	    ( cd $(TOPDIR) && \
   264           ifneq ($(PARALLEL_TARGETS), )
   265           ifneq ($(PARALLEL_TARGETS), )
   265 	    $(call StartGlobalTimer)
   266 	    $(call StartGlobalTimer)
   266 	    $(call PrepareSmartJavac)
   267 	    $(call PrepareSmartJavac)
   267 	    ( cd $(TOPDIR) && \
   268 	    ( cd $(TOPDIR) && \
   268 	        $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) $(OUTPUT_SYNC_FLAG) \
   269 	        $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) $(OUTPUT_SYNC_FLAG) \
   269 	        -j $(JOBS) -f make/Main.gmk $(USER_MAKE_VARS) \
   270 	            -j $(JOBS) -f make/Main.gmk $(USER_MAKE_VARS) \
   270 	        $(PARALLEL_TARGETS) || \
   271 	            $(PARALLEL_TARGETS) || \
   271 	        ( exitcode=$$? && $(BUILD_LOG_WRAPPER) $(PRINTF) "\nERROR: Build failed for $(TARGET_DESCRIPTION) (exit code $$exitcode) \n" && \
   272 	        ( exitcode=$$? && $(BUILD_LOG_WRAPPER) \
   272 	        $(PRINTF) "Hint: If caused by a warning, try configure --disable-warnings-as-errors \n\n" && exit $$exitcode ) )
   273 	        $(PRINTF) "\nERROR: Build failed for $(TARGET_DESCRIPTION) (exit code $$exitcode) \n" && \
       
   274 	        cd $(TOPDIR) && $(MAKE) $(MAKE_ARGS) -j 1 -f make/Init.gmk \
       
   275 	            HAS_SPEC=true on-failure ; \
       
   276 	        exit $$exitcode ) )
   273 	    $(call CleanupSmartJavac)
   277 	    $(call CleanupSmartJavac)
   274 	    $(call StopGlobalTimer)
   278 	    $(call StopGlobalTimer)
   275 	    $(call ReportBuildTimes)
   279 	    $(call ReportBuildTimes)
   276           endif
   280           endif
   277 	  $(BUILD_LOG_WRAPPER) $(PRINTF) "Finished building $(TARGET_DESCRIPTION)\n"
   281 	  $(BUILD_LOG_WRAPPER) $(PRINTF) "Finished building $(TARGET_DESCRIPTION)\n"
   278         endif
   282         endif
   279 
   283 
   280   .PHONY: print-targets print-modules reconfigure main
   284     on-failure:
       
   285         ifneq ($(wildcard $(MAKESUPPORT_OUTPUTDIR)/failure-logs/*), )
       
   286 	  $(PRINTF) "=== Output from failing command(s) repeated here ===\n"
       
   287 	  $(foreach logfile, $(sort $(wildcard $(MAKESUPPORT_OUTPUTDIR)/failure-logs/*)), \
       
   288 	      $(PRINTF) "* For target $(notdir $(basename $(logfile))):\n" $(NEWLINE) \
       
   289 	      $(CAT) $(logfile) | $(GREP) -v -e "^Note: including file:" $(NEWLINE) \
       
   290 	  )
       
   291 	  $(PRINTF) "=== End of repeated output ===\n"
       
   292         endif
       
   293 	if $(GREP) -q "recipe for target .* failed" $(BUILD_LOG) 2> /dev/null; then  \
       
   294 	  $(PRINTF) "=== Make failure sequence repeated here ===\n" ; \
       
   295 	  $(GREP) "recipe for target .* failed" $(BUILD_LOG) ; \
       
   296 	  $(PRINTF) "=== End of repeated output ===\n" ; \
       
   297 	  $(PRINTF) "Hint: Try searching the build log for the name of the first failed target.\n" ; \
       
   298 	else \
       
   299 	  $(PRINTF) "No indication of failed target found.\n" ; \
       
   300 	  $(PRINTF) "Hint: Try searching the build log for '] Error'.\n" ; \
       
   301 	fi
       
   302 	$(PRINTF) "Hint: If caused by a warning, try configure --disable-warnings-as-errors.\n\n"
       
   303 
       
   304   .PHONY: print-targets print-modules reconfigure main on-failure
   281 endif
   305 endif