< prev index next >
make/InitSupport.gmk
Print this page
@@ -1,7 +1,7 @@
#
-# 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
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
@@ -129,77 +129,10 @@
$$(info Error: CONF_CHECK must be one of: auto, fail or ignore.)
$$(error Cannot continue)
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
ifneq ($$(origin CONF), undefined)
# We also have a CONF argument. We can't have both.
@@ -475,34 +408,42 @@
-o $(OUTPUTDIR) $(COMPARE_BUILD_IGNORE_RESULT)) \
)
endef
define PrintFailureReports
+ $(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" \
+ ) \
)
endef
define PrintBuildLogFailures
+ $(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
+ fi \
+ )
endef
define RotateLogFiles
$(RM) $(BUILD_LOG).old 2> /dev/null && \
$(MV) $(BUILD_LOG) $(BUILD_LOG).old 2> /dev/null || true
@@ -581,11 +522,110 @@
)
endef
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) \
)
endif # _INITSUPPORT_GMK
< prev index next >