make/common/MakeBase.gmk
changeset 35008 ef0cd710989f
parent 34596 e8328ce5b64e
child 35370 f9b430645a18
equal deleted inserted replaced
35005:2dc4c11fe488 35008:ef0cd710989f
    84 # Store the build times in this directory.
    84 # Store the build times in this directory.
    85 BUILDTIMESDIR=$(OUTPUT_ROOT)/make-support/build-times
    85 BUILDTIMESDIR=$(OUTPUT_ROOT)/make-support/build-times
    86 
    86 
    87 # Record starting time for build of a sub repository.
    87 # Record starting time for build of a sub repository.
    88 define RecordStartTime
    88 define RecordStartTime
    89 	$(MKDIR) -p $(BUILDTIMESDIR)
    89 	$(DATE) '+%Y %m %d %H %M %S' | $(NAWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_start_$(strip $1) && \
    90 	$(DATE) '+%Y %m %d %H %M %S' | $(NAWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_start_$(strip $1)
       
    91 	$(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_start_$(strip $1)_human_readable
    90 	$(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_start_$(strip $1)_human_readable
    92 endef
    91 endef
    93 
    92 
    94 # Record ending time and calculate the difference and store it in a
    93 # Record ending time and calculate the difference and store it in a
    95 # easy to read format. Handles builds that cross midnight. Expects
    94 # easy to read format. Handles builds that cross midnight. Expects
   231     $$(call ListPathsSafely_IfPrintf,$1,$2,9501,9750)
   230     $$(call ListPathsSafely_IfPrintf,$1,$2,9501,9750)
   232     $$(call ListPathsSafely_IfPrintf,$1,$2,9751,10000)
   231     $$(call ListPathsSafely_IfPrintf,$1,$2,9751,10000)
   233   endef
   232   endef
   234 endif # HAS_FILE_FUNCTION
   233 endif # HAS_FILE_FUNCTION
   235 
   234 
       
   235 ################################################################################
   236 # The source tips can come from the Mercurial repository, or in the files
   236 # The source tips can come from the Mercurial repository, or in the files
   237 # $(HGTIP_FILENAME) which contains the tip but is also positioned in the same
   237 # $(HGTIP_FILENAME) which contains the tip but is also positioned in the same
   238 # directory as the original $(HGDIR) directory.
   238 # directory as the original $(HGDIR) directory.
   239 # These should not be := assignments, only used from the root Makefile.
   239 # These should not be := assignments, only used from the root Makefile.
   240 HG_VERSION = $(shell $(HG) version 2> /dev/null)
   240 HG_VERSION = $(shell $(HG) version 2> /dev/null)
   262 	  fi; \
   262 	  fi; \
   263 	done >> $@
   263 	done >> $@
   264 	$(PRINTF) "\n" >> $@
   264 	$(PRINTF) "\n" >> $@
   265 endef
   265 endef
   266 
   266 
   267 # Create the HGTIP_FILENAME file. Called from jdk/make/closed/bundles.gmk
   267 # Create the HGTIP_FILENAME file. Called from closed/make/SourceBundles.gmk
   268 define CreateHgTip
   268 define CreateHgTip
   269 	$(HG) tip --repository $1 --template '{node|short}\n' > $1/$(HGTIP_FILENAME); \
   269 	$(HG) tip --repository $1 --template '{node|short}\n' > $1/$(HGTIP_FILENAME); \
   270 	$(ECHO) $1/$(HGTIP_FILENAME)
   270 	$(ECHO) $1/$(HGTIP_FILENAME)
   271 endef
   271 endef
       
   272 
       
   273 ################################################################################
   272 
   274 
   273 define SetupLogging
   275 define SetupLogging
   274   ifeq ($$(LOG_LEVEL), trace)
   276   ifeq ($$(LOG_LEVEL), trace)
   275     # Shell redefinition trick inspired by http://www.cmcrossroads.com/ask-mr-make/6535-tracing-rule-execution-in-gnu-make
   277     # Shell redefinition trick inspired by http://www.cmcrossroads.com/ask-mr-make/6535-tracing-rule-execution-in-gnu-make
   276     # For each target executed, will print
   278     # For each target executed, will print
   366   $(call $(0)Body,$(strip $1))
   368   $(call $(0)Body,$(strip $1))
   367 endef
   369 endef
   368 
   370 
   369 ################################################################################
   371 ################################################################################
   370 # Make directory without forking mkdir if not needed
   372 # Make directory without forking mkdir if not needed
       
   373 # 1: List of directories to create
   371 MakeDir = \
   374 MakeDir = \
   372     $(strip $(if $(subst $(wildcard $1 $2 $3 $4 $5 $6 $7 $8 $9),,$(strip $1 $2 $3 $4 $5 $6 $7 $8 $9)),\
   375     $(strip $(if $(wildcard $1), , $(shell $(MKDIR) -p $1)))
   373       $(shell $(MKDIR) -p $1 $2 $3 $4 $5 $6 $7 $8 $9)))
       
   374 
   376 
   375 ################################################################################
   377 ################################################################################
   376 # Assign a variable only if it is empty
   378 # Assign a variable only if it is empty
   377 # Param 1 - Variable to assign
   379 # Param 1 - Variable to assign
   378 # Param 2 - Value to assign
   380 # Param 2 - Value to assign
   416   endef
   418   endef
   417 else
   419 else
   418   # Running mkdir and cp in the same shell speeds up copy intensive tasks in Cygwin
   420   # Running mkdir and cp in the same shell speeds up copy intensive tasks in Cygwin
   419   # significantly.
   421   # significantly.
   420   define install-file
   422   define install-file
   421 	$(MKDIR) -p '$(@D)' && $(CP) -fP '$<' '$@'
   423 	$(call MakeDir, $(@D))
       
   424 	$(CP) -fP '$<' '$@'
   422   endef
   425   endef
   423 endif
   426 endif
   424 
   427 
   425 ################################################################################
   428 ################################################################################
   426 # Filter out duplicate sub strings while preserving order. Keeps the first occurance.
   429 # Filter out duplicate sub strings while preserving order. Keeps the first occurance.
   516   # The extra - is needed when FIND_CACHE_DIRS is empty but should be harmless.
   519   # The extra - is needed when FIND_CACHE_DIRS is empty but should be harmless.
   517   #
   520   #
   518   # Param 1 - Dirs to find in
   521   # Param 1 - Dirs to find in
   519   # Param 2 - (optional) specialization. Normally "-a \( ... \)" expression.
   522   # Param 2 - (optional) specialization. Normally "-a \( ... \)" expression.
   520   define CacheFind
   523   define CacheFind
   521     $(if $(filter-out $(addsuffix /%,- $(FIND_CACHE_DIRS)) $(FIND_CACHE_DIRS),$1), \
   524       $(if $(filter-out $(addsuffix /%,- $(FIND_CACHE_DIRS)) $(FIND_CACHE_DIRS),$1), \
   522     $(shell $(FIND) $1 \( -type f -o -type l \) $2), \
   525     $(shell $(FIND) $1 \( -type f -o -type l \) $2), \
   523     $(filter $(addsuffix /%,$(patsubst %/,%,$1)) $1,$(FIND_CACHE)))
   526         $(filter $(addsuffix /%,$(patsubst %/,%,$1)) $1,$(FIND_CACHE)))
   524   endef
   527   endef
   525 
   528 
   526 else
   529 else
   527   # If CacheFind is disabled, just run the find command.
   530   # If CacheFind is disabled, just run the find command.
   528   # Param 1 - Dirs to find in
   531   # Param 1 - Dirs to find in
   539   # 1 : Source file
   542   # 1 : Source file
   540   # 2 : Dest file
   543   # 2 : Dest file
   541   # 3 : Variable to add targets to
   544   # 3 : Variable to add targets to
   542   # 4 : Macro to call for copy operation
   545   # 4 : Macro to call for copy operation
   543   $2: $1
   546   $2: $1
   544 	$(ECHO) $(LOG_INFO) Copying $$(patsubst $(OUTPUT_ROOT)/%,%,$$@)
   547 	$$(call LogInfo, Copying $$(patsubst $(OUTPUT_ROOT)/%,%,$$@))
   545 	$$($$(strip $4))
   548 	$$($$(strip $4))
   546 
   549 
   547   $3 += $2
   550   $3 += $2
   548 endef
   551 endef
   549 
   552 
   684 # failure-logs directory.
   687 # failure-logs directory.
   685 # Param 1 - The log file of the failed command
   688 # Param 1 - The log file of the failed command
   686 # Param 2 - A compact but representative name to describe this command
   689 # Param 2 - A compact but representative name to describe this command
   687 # Param 3 - Command to run
   690 # Param 3 - Command to run
   688 LogFailures = \
   691 LogFailures = \
   689   ( ($(BASH) $(SRC_ROOT)/common/bin/logger.sh $1 $3 && $(RM) $1) || \
   692   ( $3 > >($(TEE) $1) 2> >($(TEE) $1 >&2) || \
   690   (exitcode=$(DOLLAR)$(DOLLAR)? && $(MV) $1 $(MAKESUPPORT_OUTPUTDIR)/failure-logs/$(strip $2).log && exit $(DOLLAR)$(DOLLAR)exitcode) )
   693       (exitcode=$(DOLLAR)$(DOLLAR)? && \
       
   694       $(CP) $1 $(MAKESUPPORT_OUTPUTDIR)/failure-logs/$(strip $2).log && \
       
   695       exit $(DOLLAR)$(DOLLAR)exitcode) )
   691 
   696 
   692 ################################################################################
   697 ################################################################################
   693 # Find lib dir for module
   698 # Find lib dir for module
   694 # Param 1 - module name
   699 # Param 1 - module name
   695 ifeq ($(OPENJDK_TARGET_OS_TYPE), unix)
   700 ifeq ($(OPENJDK_TARGET_OS_TYPE), unix)