< prev index next >

make/common/MakeBase.gmk

Print this page




  28 # Setup common utility functions.
  29 #
  30 ################################################################
  31 
  32 ifndef _MAKEBASE_GMK
  33 _MAKEBASE_GMK := 1
  34 
  35 ifeq ($(wildcard $(SPEC)),)
  36   $(error MakeBase.gmk needs SPEC set to a proper spec.gmk)
  37 endif
  38 
  39 # By defining this pseudo target, make will automatically remove targets
  40 # if their recipe fails so that a rebuild is automatically triggered on the
  41 # next make invocation.
  42 .DELETE_ON_ERROR:
  43 
  44 ##############################
  45 # Functions
  46 ##############################
  47 





  48 
  49 ### Functions for timers
  50 
  51 # Store the build times in this directory.
  52 BUILDTIMESDIR=$(OUTPUT_ROOT)/make-support/build-times
  53 
  54 # Record starting time for build of a sub repository.
  55 define RecordStartTime
  56         $(MKDIR) -p $(BUILDTIMESDIR)
  57         $(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)
  58         $(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_start_$(strip $1)_human_readable
  59 endef
  60 
  61 # Record ending time and calculate the difference and store it in a
  62 # easy to read format. Handles builds that cross midnight. Expects
  63 # that a build will never take 24 hours or more.
  64 define RecordEndTime
  65         $(DATE) '+%Y %m %d %H %M %S' | $(NAWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_end_$(strip $1)
  66         $(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_end_$(strip $1)_human_readable
  67         $(ECHO) `$(CAT) $(BUILDTIMESDIR)/build_time_start_$(strip $1)` `$(CAT) $(BUILDTIMESDIR)/build_time_end_$(strip $1)` $1 | \


 540 ################################################################################
 541 # Convenience functions for working around make's limitations with $(filter ).
 542 containing = \
 543     $(strip $(foreach v,$(strip $2),$(if $(findstring $(strip $1),$v),$v)))
 544 not-containing = \
 545     $(strip $(foreach v,$(strip $2),$(if $(findstring $(strip $1),$v),,$v)))
 546 
 547 # Filter out duplicate sub strings while preserving order. Keeps the first occurance.
 548 uniq = \
 549     $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
 550 
 551 # Return a list of all string elements that are duplicated in $1.
 552 dups = \
 553     $(strip $(foreach v, $(sort $1), $(if $(filter-out 1, \
 554         $(words $(filter $v, $1))), $v)))
 555 
 556 # String equals
 557 equals = \
 558     $(and $(findstring $(strip $1),$(strip $2)),\
 559         $(findstring $(strip $2),$(strip $1)))







 560 
 561 ################################################################################
 562 
 563 ifneq ($(DISABLE_CACHE_FIND), true)
 564   # In Cygwin, finds are very costly, both because of expensive forks and because
 565   # of bad file system caching. Find is used extensively in $(shell) commands to
 566   # find source files. This makes rerunning make with no or few changes rather
 567   # expensive. To speed this up, these two macros are used to cache the results
 568   # of simple find commands for reuse.
 569   #
 570   # Runs a find and stores both the directories where it was run and the results.
 571   # This macro can be called multiple times to add to the cache. Only finds files
 572   # with no filters.
 573   #
 574   # Needs to be called with $(eval )
 575   #
 576   # Even if the performance benifit is negligible on other platforms, keep the
 577   # functionality active unless explicitly disabled to exercise it more.
 578   #
 579   # Initialize FIND_CACHE_DIRS with := to make it a non recursively-expanded variable




  28 # Setup common utility functions.
  29 #
  30 ################################################################
  31 
  32 ifndef _MAKEBASE_GMK
  33 _MAKEBASE_GMK := 1
  34 
  35 ifeq ($(wildcard $(SPEC)),)
  36   $(error MakeBase.gmk needs SPEC set to a proper spec.gmk)
  37 endif
  38 
  39 # By defining this pseudo target, make will automatically remove targets
  40 # if their recipe fails so that a rebuild is automatically triggered on the
  41 # next make invocation.
  42 .DELETE_ON_ERROR:
  43 
  44 ##############################
  45 # Functions
  46 ##############################
  47 
  48 ### Debug functions
  49 
  50 # Prints the name and value of a variable
  51 PrintVar = \
  52     $(info $(strip $1) >$($(strip $1))<)
  53 
  54 ### Functions for timers
  55 
  56 # Store the build times in this directory.
  57 BUILDTIMESDIR=$(OUTPUT_ROOT)/make-support/build-times
  58 
  59 # Record starting time for build of a sub repository.
  60 define RecordStartTime
  61         $(MKDIR) -p $(BUILDTIMESDIR)
  62         $(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)
  63         $(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_start_$(strip $1)_human_readable
  64 endef
  65 
  66 # Record ending time and calculate the difference and store it in a
  67 # easy to read format. Handles builds that cross midnight. Expects
  68 # that a build will never take 24 hours or more.
  69 define RecordEndTime
  70         $(DATE) '+%Y %m %d %H %M %S' | $(NAWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_end_$(strip $1)
  71         $(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_end_$(strip $1)_human_readable
  72         $(ECHO) `$(CAT) $(BUILDTIMESDIR)/build_time_start_$(strip $1)` `$(CAT) $(BUILDTIMESDIR)/build_time_end_$(strip $1)` $1 | \


 545 ################################################################################
 546 # Convenience functions for working around make's limitations with $(filter ).
 547 containing = \
 548     $(strip $(foreach v,$(strip $2),$(if $(findstring $(strip $1),$v),$v)))
 549 not-containing = \
 550     $(strip $(foreach v,$(strip $2),$(if $(findstring $(strip $1),$v),,$v)))
 551 
 552 # Filter out duplicate sub strings while preserving order. Keeps the first occurance.
 553 uniq = \
 554     $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
 555 
 556 # Return a list of all string elements that are duplicated in $1.
 557 dups = \
 558     $(strip $(foreach v, $(sort $1), $(if $(filter-out 1, \
 559         $(words $(filter $v, $1))), $v)))
 560 
 561 # String equals
 562 equals = \
 563     $(and $(findstring $(strip $1),$(strip $2)),\
 564         $(findstring $(strip $2),$(strip $1)))
 565 
 566 # Remove a whole list of prefixes
 567 # $1 - List of prefixes
 568 # $2 - List of elements to process
 569 remove-prefixes = \
 570     $(strip $(if $1,$(patsubst $(firstword $1)%,%,\
 571       $(call remove-prefixes,$(filter-out $(firstword $1),$1),$2)),$2))
 572 
 573 ################################################################################
 574 
 575 ifneq ($(DISABLE_CACHE_FIND), true)
 576   # In Cygwin, finds are very costly, both because of expensive forks and because
 577   # of bad file system caching. Find is used extensively in $(shell) commands to
 578   # find source files. This makes rerunning make with no or few changes rather
 579   # expensive. To speed this up, these two macros are used to cache the results
 580   # of simple find commands for reuse.
 581   #
 582   # Runs a find and stores both the directories where it was run and the results.
 583   # This macro can be called multiple times to add to the cache. Only finds files
 584   # with no filters.
 585   #
 586   # Needs to be called with $(eval )
 587   #
 588   # Even if the performance benifit is negligible on other platforms, keep the
 589   # functionality active unless explicitly disabled to exercise it more.
 590   #
 591   # Initialize FIND_CACHE_DIRS with := to make it a non recursively-expanded variable


< prev index next >