make/common/MakeBase.gmk
changeset 39110 712f29ba8708
parent 37972 e1fa5c2e62a0
child 39607 ace2c0283dce
equal deleted inserted replaced
39107:2a5697a98620 39110:712f29ba8708
   333 endif # HAS_FILE_FUNCTION
   333 endif # HAS_FILE_FUNCTION
   334 
   334 
   335 ################################################################################
   335 ################################################################################
   336 # The source tips can come from the Mercurial repository, or in the files
   336 # The source tips can come from the Mercurial repository, or in the files
   337 # $(HGTIP_FILENAME) which contains the tip but is also positioned in the same
   337 # $(HGTIP_FILENAME) which contains the tip but is also positioned in the same
   338 # directory as the original $(HGDIR) directory.
   338 # directory as the original .hg directory. The hgtip files are created in
   339 # These should not be := assignments, only used from the root Makefile.
   339 # CreateHgtipFiles.gmk.
   340 HG_VERSION = $(shell $(HG) version 2> /dev/null)
   340 HGTIP_FILENAME := .hgtip
   341 HG_DIRECTORY=.hg
   341 FindAllReposAbs = \
   342 HGTIP_FILENAME=.hgtip
   342     $(strip $(sort $(dir $(filter-out $(SRC_ROOT)/build/%, $(wildcard \
   343 HG_SEARCH = ./REPO ./*/REPO ./*/*/REPO ./*/*/*/REPO
   343         $(addprefix $(SRC_ROOT)/, \
   344 REPO_LIST = $(patsubst ./%,%,$(patsubst %/,%,$(sort $(dir \
   344             .hg */.hg */*/.hg */*/.hg */*/*/.hg \
   345     $(shell $(CD) $(SRC_ROOT) ; \
   345             .hgtip */.hgtip */*/.hgtip */*/.hgtip */*/*/.hgtip \
   346         $(LS) -d $(HG_SEARCH:%/REPO=%/$(HG_DIRECTORY)) \
   346         ) \
   347             $(HG_SEARCH:%/REPO=%/$(HGTIP_FILENAME)) \
   347     )))))
   348         2> /dev/null)))))
   348 
       
   349 FindAllReposRel = \
       
   350     $(strip $(subst $(SRC_ROOT)/,.,$(patsubst $(SRC_ROOT)/%/, %, $(FindAllReposAbs))))
   349 
   351 
   350 # Emit the repo:tip pairs to $@, but only if they changed since last time
   352 # Emit the repo:tip pairs to $@, but only if they changed since last time
   351 define GetSourceTips
   353 define GetSourceTips
   352 	$(CD) $(SRC_ROOT) ; \
   354 	$(CD) $(SRC_ROOT) ; \
   353 	for i in $(REPO_LIST) IGNORE ; do \
   355 	for i in $(FindAllReposRel) IGNORE ; do \
   354 	  if [ "$${i}" = "IGNORE" ] ; then \
   356 	  if [ "$${i}" = "IGNORE" ] ; then \
   355 	    continue; \
   357 	    continue; \
   356 	  elif [ -d $${i}/$(HG_DIRECTORY) -a "$(HG_VERSION)" != "" ] ; then \
   358 	  elif [ -d $${i}/.hg -a "$(HG)" != "" ] ; then \
   357 	    $(PRINTF) " %s:%s" \
   359 	    $(PRINTF) " %s:%s" \
   358 	        "$${i}" `$(HG) tip --repository $${i} --template '{node|short}\n'` ; \
   360 	        "$${i}" `$(HG) tip --repository $${i} --template '{node|short}\n'` ; \
   359 	  elif [ -f $${i}/$(HGTIP_FILENAME) ] ; then \
   361 	  elif [ -f $${i}/$(HGTIP_FILENAME) ] ; then \
   360 	    $(PRINTF) " %s:%s" \
   362 	    $(PRINTF) " %s:%s" \
   361 	        "$${i}" `$(CAT) $${i}/$(HGTIP_FILENAME)` ; \
   363 	        "$${i}" `$(CAT) $${i}/$(HGTIP_FILENAME)` ; \
   365 	if [ ! -f $@ ] || [ "`$(CAT) $@`" != "`$(CAT) $@.tmp`" ]; then \
   367 	if [ ! -f $@ ] || [ "`$(CAT) $@`" != "`$(CAT) $@.tmp`" ]; then \
   366 	  $(MV) $@.tmp $@ ; \
   368 	  $(MV) $@.tmp $@ ; \
   367 	else \
   369 	else \
   368 	  $(RM) $@.tmp ; \
   370 	  $(RM) $@.tmp ; \
   369 	fi
   371 	fi
   370 endef
       
   371 
       
   372 # Create the HGTIP_FILENAME file. Called from closed/make/SourceBundles.gmk
       
   373 define CreateHgTip
       
   374 	$(HG) tip --repository $1 --template '{node|short}\n' > $1/$(HGTIP_FILENAME); \
       
   375 	$(ECHO) $1/$(HGTIP_FILENAME)
       
   376 endef
   372 endef
   377 
   373 
   378 ################################################################################
   374 ################################################################################
   379 
   375 
   380 define SetupLogging
   376 define SetupLogging