8136771: Implement the license-swap logic as a make target
authorerikj
Wed, 08 Jun 2016 15:13:19 +0200
changeset 39110 712f29ba8708
parent 39107 2a5697a98620
child 39111 d3f0656636f8
8136771: Implement the license-swap logic as a make target Reviewed-by: tbell
make/CreateHgtipFiles.gmk
make/GensrcModuleInfo.gmk
make/Main.gmk
make/common/MakeBase.gmk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/CreateHgtipFiles.gmk	Wed Jun 08 15:13:19 2016 +0200
@@ -0,0 +1,55 @@
+#
+# Copyright (c) 2016, 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
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+default: all
+
+include $(SPEC)
+include MakeBase.gmk
+
+define SetupCreateHgtip
+
+  $$(strip $1)/$(HGTIP_FILENAME): FRC
+	$(HG) tip --repository $$(strip $1) --template '{node|short}\n' > $$@.tmp
+	if [ ! -f $$@ ] || [ "`$(CAT) $$@`" != "`$(CAT) $$@.tmp`" ]; then \
+	  $(MV) $$@.tmp $$@ ; \
+	else \
+	  $(RM) $$@.tmp ; \
+	fi
+
+  TARGETS += $$(strip $1)/$(HGTIP_FILENAME)
+
+endef
+
+# Only try to create the tips if finding an actual hg repository. This will be
+# false if building from a source bundle.
+$(foreach r, $(call FindAllReposAbs), \
+  $(if $(wildcard $r/.hg), $(eval $(call SetupCreateHgtip, $r))) \
+)
+
+all: $(TARGETS)
+
+FRC:
+
+.PHONY: all
--- a/make/GensrcModuleInfo.gmk	Wed Jul 05 21:52:00 2017 +0200
+++ b/make/GensrcModuleInfo.gmk	Wed Jun 08 15:13:19 2016 +0200
@@ -95,6 +95,7 @@
       $(strip $(wildcard $(addsuffix $(subst .,/,/$(strip $1)), \
           $(MODULE_CLASSES_DIRS) \
           $(addsuffix /$(MODULE), $(IMPORT_MODULES_CLASSES)) \
+          $(JDK_OUTPUTDIR)/modules/$(MODULE) \
       )))
 
   # Convert the modification lines into arguments for the modification tool.
--- a/make/Main.gmk	Wed Jul 05 21:52:00 2017 +0200
+++ b/make/Main.gmk	Wed Jun 08 15:13:19 2016 +0200
@@ -301,13 +301,16 @@
 ################################################################################
 # Images targets
 
-# Stores the tips for each repository. This file is be used when constructing the jdk image and can be
-# used to track the exact sources used to build that image.
+# Stores the tips for each repository. This file is be used when constructing
+# the jdk image and can be used to track the exact sources used to build that
+# image.
 source-tips: $(SUPPORT_OUTPUTDIR)/source_tips
 $(SUPPORT_OUTPUTDIR)/source_tips: FRC
 	$(call MakeDir, $(@D))
-	@$(RM) $@
-	@$(call GetSourceTips)
+	$(call GetSourceTips)
+
+create-hgtip-files:
+	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f CreateHgtipFiles.gmk)
 
 BOOTCYCLE_TARGET := product-images
 bootcycle-images:
@@ -337,8 +340,8 @@
 mac-bundles-jdk:
 	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f MacBundles.gmk)
 
-ALL_TARGETS += source-tips bootcycle-images zip-security zip-source \
-    jrtfs-jar jimages profiles mac-bundles-jdk
+ALL_TARGETS += source-tips create-hgtip-files bootcycle-images zip-security \
+     zip-source jrtfs-jar jimages profiles mac-bundles-jdk
 
 ################################################################################
 # Docs targets
--- a/make/common/MakeBase.gmk	Wed Jul 05 21:52:00 2017 +0200
+++ b/make/common/MakeBase.gmk	Wed Jun 08 15:13:19 2016 +0200
@@ -335,25 +335,27 @@
 ################################################################################
 # 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 $(CD) $(SRC_ROOT) ; \
-        $(LS) -d $(HG_SEARCH:%/REPO=%/$(HG_DIRECTORY)) \
-            $(HG_SEARCH:%/REPO=%/$(HGTIP_FILENAME)) \
-        2> /dev/null)))))
+# directory as the original .hg directory. The hgtip files are created in
+# CreateHgtipFiles.gmk.
+HGTIP_FILENAME := .hgtip
+FindAllReposAbs = \
+    $(strip $(sort $(dir $(filter-out $(SRC_ROOT)/build/%, $(wildcard \
+        $(addprefix $(SRC_ROOT)/, \
+            .hg */.hg */*/.hg */*/.hg */*/*/.hg \
+            .hgtip */.hgtip */*/.hgtip */*/.hgtip */*/*/.hgtip \
+        ) \
+    )))))
+
+FindAllReposRel = \
+    $(strip $(subst $(SRC_ROOT)/,.,$(patsubst $(SRC_ROOT)/%/, %, $(FindAllReposAbs))))
 
 # Emit the repo:tip pairs to $@, but only if they changed since last time
 define GetSourceTips
 	$(CD) $(SRC_ROOT) ; \
-	for i in $(REPO_LIST) IGNORE ; do \
+	for i in $(FindAllReposRel) IGNORE ; do \
 	  if [ "$${i}" = "IGNORE" ] ; then \
 	    continue; \
-	  elif [ -d $${i}/$(HG_DIRECTORY) -a "$(HG_VERSION)" != "" ] ; then \
+	  elif [ -d $${i}/.hg -a "$(HG)" != "" ] ; then \
 	    $(PRINTF) " %s:%s" \
 	        "$${i}" `$(HG) tip --repository $${i} --template '{node|short}\n'` ; \
 	  elif [ -f $${i}/$(HGTIP_FILENAME) ] ; then \
@@ -369,12 +371,6 @@
 	fi
 endef
 
-# Create the HGTIP_FILENAME file. Called from closed/make/SourceBundles.gmk
-define CreateHgTip
-	$(HG) tip --repository $1 --template '{node|short}\n' > $1/$(HGTIP_FILENAME); \
-	$(ECHO) $1/$(HGTIP_FILENAME)
-endef
-
 ################################################################################
 
 define SetupLogging