changeset 4040:dc63c52bc61f

6631003: Add hg tip changeset to build image Reviewed-by: mduigou
author ohair
date Tue, 26 Apr 2011 16:27:40 -0700
parents 4530d9301ce0
children 55d40eea52bb
files .hgignore make/common/Release.gmk make/common/shared/Defs-utils.gmk make/common/shared/Defs.gmk
diffstat 4 files changed, 46 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Mon Apr 25 21:16:54 2011 -0700
+++ b/.hgignore	Tue Apr 26 16:27:40 2011 -0700
@@ -3,3 +3,4 @@
 /nbproject/private/
 ^make/netbeans/.*/build/
 ^make/netbeans/.*/dist/
+^.hgtip
--- a/make/common/Release.gmk	Mon Apr 25 21:16:54 2011 -0700
+++ b/make/common/Release.gmk	Tue Apr 26 16:27:40 2011 -0700
@@ -1118,6 +1118,10 @@
 MINIMUM_OS_NAME    := $(REQUIRED_OS_NAME)
 MINIMUM_OS_VERSION := $(REQUIRED_OS_VERSION)
 MINIMUM_OS_ARCH    := $(ARCH)
+ALL_SOURCE_TIPS     = $(shell \
+  if [ -f $(SOURCE_TIPS) ] ; then \
+    $(CAT) $(SOURCE_TIPS) ; \
+  fi)
 
 $(JDK_INFO_FILE): FRC
 	$(prep-target)
@@ -1125,6 +1129,7 @@
 	$(call info-file-item, "OS_NAME",      "$(MINIMUM_OS_NAME)")
 	$(call info-file-item, "OS_VERSION",   "$(MINIMUM_OS_VERSION)")
 	$(call info-file-item, "OS_ARCH",      "$(MINIMUM_OS_ARCH)")
+	$(call info-file-item, "SOURCE",       "$(ALL_SOURCE_TIPS)")
 
 # Create release file to identify this image
 identify-image-jdk:: $(JDK_INFO_FILE)
@@ -1135,6 +1140,7 @@
 	$(call info-file-item, "OS_NAME",      "$(MINIMUM_OS_NAME)")
 	$(call info-file-item, "OS_VERSION",   "$(MINIMUM_OS_VERSION)")
 	$(call info-file-item, "OS_ARCH",      "$(MINIMUM_OS_ARCH)")
+	$(call info-file-item, "SOURCE",       "$(ALL_SOURCE_TIPS)")
 
 # Create release file to identify this image
 identify-image-jre:: $(JRE_INFO_FILE)
--- a/make/common/shared/Defs-utils.gmk	Mon Apr 25 21:16:54 2011 -0700
+++ b/make/common/shared/Defs-utils.gmk	Tue Apr 26 16:27:40 2011 -0700
@@ -110,6 +110,7 @@
 GREP           = $(UTILS_COMMAND_PATH)grep
 GUNZIP         = $(UTILS_COMMAND_PATH)gunzip
 HEAD           = $(UTILS_USR_BIN_PATH)head
+HG             = hg
 ID             = $(UTILS_COMMAND_PATH)id
 ISAINFO        = $(UTILS_COMMAND_PATH)isainfo
 KSH            = $(UTILS_COMMAND_PATH)ksh
--- a/make/common/shared/Defs.gmk	Mon Apr 25 21:16:54 2011 -0700
+++ b/make/common/shared/Defs.gmk	Tue Apr 26 16:27:40 2011 -0700
@@ -612,6 +612,44 @@
   COPYRIGHT_YEAR = $(shell $(DATE) '+%Y')
 endif
 
+# Create file with source information
+SOURCE_TIPS=$(ABS_OUTPUTDIR)/source_tips
+
+# The source tips can come from the Mercurial repository, or in the files
+#   $(HGTIP_FILENAME) which contains the tip but is also positioned in the same
+#   directory as the original $(HGDIR) directory.
+#   These should not be := assignments, only used from the root Makefile.
+HG_VERSION = $(shell $(HG) version 2> $(DEV_NULL))
+HG_DIRECTORY=.hg
+HGTIP_FILENAME=.hgtip
+HG_SEARCH = ./REPO ./*/REPO ./*/*/REPO ./*/*/*/REPO
+REPO_LIST = $(patsubst ./%,%,$(patsubst %/,%,$(sort $(dir \
+    $(shell ( $(LS) -d $(HG_SEARCH:%/REPO=%/$(HG_DIRECTORY)) ; \
+              $(LS)    $(HG_SEARCH:%/REPO=%/$(HGTIP_FILENAME)) ) \
+	        2> $(DEV_NULL))))))
+
+# Emit the repo:tip pairs to $@
+define GetSourceTips
+for i in $(REPO_LIST) IGNORE ; do \
+  if [ "$${i}" = "IGNORE" ] ; then \
+    continue; \
+  elif [ -d $${i}/$(HG_DIRECTORY) -a "$(HG_VERSION)" != "" ] ; then \
+    $(PRINTF) " %s:%s" \
+      "$${i}" `$(HG) tip --repository $${i} --template '{node|short}\n'` ; \
+  elif [ -f $${i}/$(HGTIP_FILENAME) ] ; then \
+    $(PRINTF) " %s:%s" \
+      "$${i}" `$(CAT) $${i}/$(HGTIP_FILENAME)` ; \
+  fi; \
+done >> $@
+$(PRINTF) "\n" >> $@
+endef
+
+# Create the HGTIP_FILENAME file
+define CreateHgTip
+$(HG) tip --repository $1 --template '{node|short}\n' > $1/$(HGTIP_FILENAME)
+$(ECHO) $1/$(HGTIP_FILENAME)
+endef
+
 # Get the compiler specific settings (will run the compiler to find out)
 #   NOTE: COMPILER_PATH must be set by this time.
 #   Up until we include this file, we don't know what specific compiler