8201320: Allow PrintFailureReports to be turned off
authorihse
Tue, 10 Apr 2018 23:32:54 +0200
changeset 49568 3e9cb3562d83
parent 49567 e6c069766d46
child 49569 d4d2f634b72f
8201320: Allow PrintFailureReports to be turned off Reviewed-by: erikj
make/Init.gmk
make/InitSupport.gmk
make/autoconf/basics.m4
make/autoconf/configure.ac
make/autoconf/spec.gmk.in
--- a/make/Init.gmk	Tue Apr 10 14:16:13 2018 -0700
+++ b/make/Init.gmk	Tue Apr 10 23:32:54 2018 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012, 2018, 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
@@ -226,6 +226,15 @@
   # Parse COMPARE_BUILD (for makefile development)
   $(eval $(call ParseCompareBuild))
 
+  # If no LOG= was given on command line, but we have a non-standard default
+  # value, use that instead and re-parse log level.
+  ifeq ($(LOG), )
+    ifneq ($(DEFAULT_LOG), )
+      override LOG := $(DEFAULT_LOG)
+      $(eval $(call ParseLogLevel))
+    endif
+  endif
+
   ifeq ($(LOG_NOFILE), true)
     # Disable build log if LOG=[level,]nofile was given
     override BUILD_LOG_PIPE :=
--- a/make/InitSupport.gmk	Tue Apr 10 14:16:13 2018 -0700
+++ b/make/InitSupport.gmk	Tue Apr 10 23:32:54 2018 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2018, 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
@@ -131,73 +131,6 @@
     endif
   endef
 
-  # Look for a given option in the LOG variable, and if found, set a variable
-  # and remove the option from the LOG variable
-  # $1: The option to look for
-  # $2: The option to set to "true" if the option is found
-  define ParseLogOption
-    ifneq ($$(findstring $1, $$(LOG)),)
-      $2 := true
-      # COMMA is defined in spec.gmk, but that is not included yet
-      COMMA := ,
-      # First try to remove ",<option>" if it exists, otherwise just remove "<option>"
-      LOG_STRIPPED := $$(subst $1,, $$(subst $$(COMMA)$(strip $1),, $$(LOG)))
-      # We might have ended up with a leading comma. Remove it. Need override
-      # since LOG is set from the command line.
-      override LOG := $$(strip $$(patsubst $$(COMMA)%, %, $$(LOG_STRIPPED)))
-    endif
-  endef
-
-  define ParseLogLevel
-    # Catch old-style VERBOSE= command lines.
-    ifneq ($$(origin VERBOSE), undefined)
-      $$(info Error: VERBOSE is deprecated. Use LOG=<warn|info|debug|trace> instead.)
-      $$(error Cannot continue)
-    endif
-
-    # Setup logging according to LOG
-
-    # If the "nofile" argument is given, act on it and strip it away
-    $$(eval $$(call ParseLogOption, nofile, LOG_NOFILE))
-
-    # If the "cmdline" argument is given, act on it and strip it away
-    $$(eval $$(call ParseLogOption, cmdlines, LOG_CMDLINES))
-
-    # If the "profile-to-log" argument is given, write shell times in build log
-    $$(eval $$(call ParseLogOption, profile-to-log, LOG_PROFILE_TIMES_LOG))
-
-    # If the "profile" argument is given, write shell times in separate log file
-    # IMPORTANT: $(ParseLogOption profile-to-log) should go first. Otherwise
-    # parsing of 'LOG=debug,profile-to-log,nofile' ends up in the following error:
-    # Error: LOG contains unknown option or log level: debug-to-log.
-    $$(eval $$(call ParseLogOption, profile, LOG_PROFILE_TIMES_FILE))
-
-    # Treat LOG=profile-to-log as if it were LOG=profile,profile-to-log
-    LOG_PROFILE_TIMES_FILE := $$(firstword $$(LOG_PROFILE_TIMES_FILE) $$(LOG_PROFILE_TIMES_LOG))
-
-    LOG_LEVEL := $$(LOG)
-
-    ifeq ($$(LOG_LEVEL),)
-      # Set LOG to "warn" as default if not set
-      LOG_LEVEL := warn
-    endif
-
-    ifeq ($$(LOG_LEVEL), warn)
-      MAKE_LOG_FLAGS := -s
-    else ifeq ($$(LOG_LEVEL), info)
-      MAKE_LOG_FLAGS := -s
-    else ifeq ($$(LOG_LEVEL), debug)
-      MAKE_LOG_FLAGS :=
-    else ifeq ($$(LOG_LEVEL), trace)
-      MAKE_LOG_FLAGS :=
-    else
-      $$(info Error: LOG contains unknown option or log level: $$(LOG).)
-      $$(info LOG can be <level>[,<opt>[...]] where <opt> is nofile | cmdlines | profile | profile-to-log)
-      $$(info and <level> is warn | info | debug | trace)
-      $$(error Cannot continue)
-    endif
-  endef
-
   define ParseConfAndSpec
     ifneq ($$(origin SPEC), undefined)
       # We have been given a SPEC, check that it works out properly
@@ -477,30 +410,38 @@
   endef
 
   define PrintFailureReports
-	$(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) \
+	$(if $(filter none, $(LOG_REPORT)), , \
+	  $(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) \
+	        $(if $(filter all, $(LOG_REPORT)), \
+	          $(GREP) -v -e "^Note: including file:" <  $(logfile) || true $(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" \
 	  ) \
-	  $(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) "\n=== Make failed targets repeated here ===\n" ; \
-	  $(GREP) "recipe for target .* failed" $(BUILD_LOG) ; \
-	  $(PRINTF) "=== End of repeated output ===\n" ; \
-	  $(PRINTF) "\nHint: Try searching the build log for the name of the first failed target.\n" ; \
-	else \
-	  $(PRINTF) "\nNo indication of failed target found.\n" ; \
-	  $(PRINTF) "Hint: Try searching the build log for '] Error'.\n" ; \
-	fi
+	$(if $(filter none, $(LOG_REPORT)), , \
+	  if $(GREP) -q "recipe for target .* failed" $(BUILD_LOG) 2> /dev/null; then  \
+	    $(PRINTF) "\n=== Make failed targets repeated here ===\n" ; \
+	    $(GREP) "recipe for target .* failed" $(BUILD_LOG) ; \
+	    $(PRINTF) "=== End of repeated output ===\n" ; \
+	    $(PRINTF) "\nHint: Try searching the build log for the name of the first failed target.\n" ; \
+	  else \
+	    $(PRINTF) "\nNo indication of failed target found.\n" ; \
+	    $(PRINTF) "Hint: Try searching the build log for '] Error'.\n" ; \
+	  fi \
+	)
   endef
 
   define RotateLogFiles
@@ -583,8 +524,107 @@
 
 endif # HAS_SPEC
 
+# Look for a given option in the LOG variable, and if found, set a variable
+# and remove the option from the LOG variable
+# $1: The option to look for
+# $2: The variable to set to "true" if the option is found
+define ParseLogOption
+  ifneq ($$(findstring $1, $$(LOG)),)
+    override $2 := true
+    # COMMA is defined in spec.gmk, but that is not included yet
+    COMMA := ,
+    # First try to remove ",<option>" if it exists, otherwise just remove "<option>"
+    LOG_STRIPPED := $$(subst $1,, $$(subst $$(COMMA)$$(strip $1),, $$(LOG)))
+    # We might have ended up with a leading comma. Remove it. Need override
+    # since LOG is set from the command line.
+    override LOG := $$(strip $$(patsubst $$(COMMA)%, %, $$(LOG_STRIPPED)))
+  endif
+endef
+
+# Look for a given option with an assignment in the LOG variable, and if found,
+# set a variable to that value and remove the option from the LOG variable
+# $1: The option to look for
+# $2: The variable to set to the value of the option, if found
+define ParseLogValue
+  ifneq ($$(findstring $1=, $$(LOG)),)
+    # Make words of out comma-separated list and find the one with opt=val
+    value := $$(strip $$(subst $$(strip $1)=,, $$(filter $$(strip $1)=%, $$(subst $$(COMMA), , $$(LOG)))))
+    override $2 := $$(value)
+    # COMMA is defined in spec.gmk, but that is not included yet
+    COMMA := ,
+    # First try to remove ",<option>" if it exists, otherwise just remove "<option>"
+    LOG_STRIPPED := $$(subst $$(strip $1)=$$(value),, \
+        $$(subst $$(COMMA)$$(strip $1)=$$(value),, $$(LOG)))
+    # We might have ended up with a leading comma. Remove it. Need override
+    # since LOG is set from the command line.
+    override LOG := $$(strip $$(patsubst $$(COMMA)%, %, $$(LOG_STRIPPED)))
+  endif
+endef
+
+
+define ParseLogLevel
+  # Catch old-style VERBOSE= command lines.
+  ifneq ($$(origin VERBOSE), undefined)
+    $$(info Error: VERBOSE is deprecated. Use LOG=<warn|info|debug|trace> instead.)
+    $$(error Cannot continue)
+  endif
+
+  # Setup logging according to LOG
+
+  # If "nofile" is present, do not log to a file
+  $$(eval $$(call ParseLogOption, nofile, LOG_NOFILE))
+
+  # If "cmdline" is present, print all executes "important" command lines.
+  $$(eval $$(call ParseLogOption, cmdlines, LOG_CMDLINES))
+
+  # If "report" is present, use non-standard reporting options at build failure.
+  $$(eval $$(call ParseLogValue, report, LOG_REPORT))
+  ifneq ($$(LOG_REPORT), )
+    ifeq ($$(filter $$(LOG_REPORT), none all default), )
+      $$(info Error: LOG=report has invalid value: $$(LOG_REPORT).)
+      $$(info Valid values: LOG=report=<none>|<all>|<default>)
+      $$(error Cannot continue)
+    endif
+  endif
+
+  # If "profile-to-log" is present, write shell times in build log
+  $$(eval $$(call ParseLogOption, profile-to-log, LOG_PROFILE_TIMES_LOG))
+
+  # If "profile" is present, write shell times in separate log file
+  # IMPORTANT: $(ParseLogOption profile-to-log) should go first. Otherwise
+  # parsing of 'LOG=debug,profile-to-log,nofile' ends up in the following error:
+  # Error: LOG contains unknown option or log level: debug-to-log.
+  $$(eval $$(call ParseLogOption, profile, LOG_PROFILE_TIMES_FILE))
+
+  # Treat LOG=profile-to-log as if it were LOG=profile,profile-to-log
+  LOG_PROFILE_TIMES_FILE := $$(firstword $$(LOG_PROFILE_TIMES_FILE) $$(LOG_PROFILE_TIMES_LOG))
+
+  override LOG_LEVEL := $$(LOG)
+
+  ifeq ($$(LOG_LEVEL),)
+    # Set LOG to "warn" as default if not set
+    override LOG_LEVEL := warn
+  endif
+
+  ifeq ($$(LOG_LEVEL), warn)
+    override MAKE_LOG_FLAGS := -s
+  else ifeq ($$(LOG_LEVEL), info)
+    override MAKE_LOG_FLAGS := -s
+  else ifeq ($$(LOG_LEVEL), debug)
+    override MAKE_LOG_FLAGS :=
+  else ifeq ($$(LOG_LEVEL), trace)
+    override MAKE_LOG_FLAGS :=
+  else
+    $$(info Error: LOG contains unknown option or log level: $$(LOG).)
+    $$(info LOG can be <level>[,<opt>[...]] where <opt> is nofile | cmdlines | profile | profile-to-log)
+    $$(info and <level> is warn | info | debug | trace)
+    $$(error Cannot continue)
+  endif
+endef
+
 MAKE_LOG_VARS = $(foreach v, \
-    LOG_LEVEL LOG_NOFILE LOG_CMDLINES LOG_PROFILE_TIMES_LOG LOG_PROFILE_TIMES_FILE, \
+    LOG_LEVEL LOG_NOFILE LOG_CMDLINES LOG_REPORT LOG_PROFILE_TIMES_LOG \
+    LOG_PROFILE_TIMES_FILE, \
     $v=$($v) \
 )
 
--- a/make/autoconf/basics.m4	Tue Apr 10 14:16:13 2018 -0700
+++ b/make/autoconf/basics.m4	Tue Apr 10 23:32:54 2018 +0200
@@ -1260,6 +1260,24 @@
   AC_SUBST(DEFAULT_MAKE_TARGET)
 ])
 
+# Setup the default value for LOG=
+#
+AC_DEFUN_ONCE([BASIC_SETUP_DEFAULT_LOG],
+[
+  AC_ARG_WITH(log, [AS_HELP_STRING([--with-log],
+      [[default vaue for make LOG argument [warn]]])])
+  AC_MSG_CHECKING([for default LOG value])
+  if test "x$with_log" = x; then
+    DEFAULT_LOG=""
+  else
+    # Syntax for valid LOG options is a bit too complex for it to be worth
+    # implementing a test for correctness in configure. Just accept it.
+    DEFAULT_LOG=$with_log
+  fi
+  AC_MSG_RESULT([$DEFAULT_LOG])
+  AC_SUBST(DEFAULT_LOG)
+])
+
 # Code to run after AC_OUTPUT
 AC_DEFUN_ONCE([BASIC_POST_CONFIG_OUTPUT],
 [
--- a/make/autoconf/configure.ac	Tue Apr 10 14:16:13 2018 -0700
+++ b/make/autoconf/configure.ac	Tue Apr 10 23:32:54 2018 +0200
@@ -120,6 +120,7 @@
 
 # Misc basic settings
 BASIC_SETUP_DEFAULT_MAKE_TARGET
+BASIC_SETUP_DEFAULT_LOG
 
 ###############################################################################
 #
--- a/make/autoconf/spec.gmk.in	Tue Apr 10 14:16:13 2018 -0700
+++ b/make/autoconf/spec.gmk.in	Tue Apr 10 23:32:54 2018 +0200
@@ -332,6 +332,7 @@
 
 # Default make target
 DEFAULT_MAKE_TARGET:=@DEFAULT_MAKE_TARGET@
+DEFAULT_LOG:=@DEFAULT_LOG@
 
 FREETYPE_TO_USE:=@FREETYPE_TO_USE@
 FREETYPE_LIBS:=@FREETYPE_LIBS@