forked from AdoptOpenJDK/openjdk-jdk12u
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
8031567: Better model for storing source revision information
Reviewed-by: erikj
- Loading branch information
ihse
committed
Nov 28, 2016
1 parent
825fe7f
commit a4168a7
Showing
6 changed files
with
155 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,7 @@ | |
^.idea/ | ||
nbproject/private/ | ||
^webrev | ||
^.hgtip | ||
^.bridge2 | ||
^.src-rev$ | ||
^.jib/ | ||
.DS_Store | ||
.metadata/ | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
# | ||
# 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 | ||
|
||
################################################################################ | ||
# Keep track of what source revision is used to create the build, by creating | ||
# a tracker file in the output directory. This tracker file is included in the | ||
# image, and can be used to recreate the source revision used. | ||
# | ||
# We're either building directly from a mercurial forest, and if so, use the | ||
# current revision from mercurial. Otherwise, we are building from a source | ||
# bundle. As a part of creating this source bundle, the current mercurial | ||
# revisions of all repos will be stored in a file in the top dir, which is then | ||
# used when creating the tracker file. | ||
|
||
STORED_SOURCE_REVISION := $(TOPDIR)/.src-rev | ||
|
||
# Are we using mercurial? | ||
ifneq ($(and $(HG), $(wildcard $(TOPDIR)/.hg)), ) | ||
|
||
# Verify that the entire forest is consistent | ||
$(foreach repo, $(call FindAllReposRel), \ | ||
$(if $(wildcard $(TOPDIR)/$(repo)/.hg),, \ | ||
$(error Inconsistent revision control: $(repo) is missing .hg directory)) \ | ||
) | ||
|
||
# Replace "." with "_top" and "/" with "-" | ||
MakeFilenameFromRepo = \ | ||
$(strip $(subst .,top, $(subst /,-, $1))) | ||
|
||
################################################################################ | ||
# SetupGetRevisionForRepo defines a make rule for creating a file containing | ||
# the name of the repository and the output of "hg id" for that repository. | ||
# Argument 1 is the relative path to the repository from the top dir. | ||
# | ||
SetupGetRevisionForRepo = $(NamedParamsMacroTemplate) | ||
define SetupGetRevisionForRepoBody | ||
$1_REPO_PATH := $$(TOPDIR)/$$(strip $1) | ||
$1_FILENAME := $$(call MakeFilenameFromRepo, $1) | ||
|
||
$$(SUPPORT_OUTPUTDIR)/src-rev/$$($1_FILENAME): FRC | ||
$(call MakeDir $$(@D)) | ||
$(ECHO) $$(strip $1):`$(HG) id -i --repository $$($1_REPO_PATH)` > $$@ | ||
|
||
REPO_REVISIONS += $$(SUPPORT_OUTPUTDIR)/src-rev/$$($1_FILENAME) | ||
endef | ||
|
||
# Setup rules for all repos. This makes sure all the "hg id" calls are made | ||
# in parallel. | ||
$(foreach repo, $(call FindAllReposRel), \ | ||
$(eval $(call SetupGetRevisionForRepo, $(repo))) \ | ||
) | ||
|
||
# Create a complete source revision output file from all repos | ||
# Param 1: The output file | ||
define CreateSourceRevisionFile | ||
$1: $$(REPO_REVISIONS) | ||
$(call MakeDir $$(@D)) | ||
$$(ECHO) `$$(CAT) $$(REPO_REVISIONS)` > [email protected] | ||
if [ ! -f $$@ ] || [ "`$$(CAT) $$@`" != "`$$(CAT) [email protected]`" ]; then \ | ||
$$(MV) [email protected] $$@ ; \ | ||
else \ | ||
$$(RM) [email protected] ; \ | ||
fi | ||
endef | ||
|
||
$(eval $(call CreateSourceRevisionFile, $(STORED_SOURCE_REVISION))) | ||
|
||
store-source-revision: $(STORED_SOURCE_REVISION) | ||
|
||
$(eval $(call CreateSourceRevisionFile, $(SOURCE_REVISION_TRACKER))) | ||
|
||
create-source-revision-tracker: $(SOURCE_REVISION_TRACKER) | ||
|
||
else | ||
# Not using HG | ||
|
||
ifneq ($(wildcard $(STORED_SOURCE_REVISION)), ) | ||
# We have a stored source revision (.src-rev) | ||
|
||
store-source-revision: | ||
$(call LogWarn, Warning: No mercurial configuration present, not updating .src-rev) | ||
|
||
$(SOURCE_REVISION_TRACKER): $(STORED_SOURCE_REVISION) | ||
$(install-file) | ||
|
||
create-source-revision-tracker: $(SOURCE_REVISION_TRACKER) | ||
else | ||
# We don't have a stored source revision. Can't do anything, really. | ||
|
||
store-source-revision: | ||
$(call LogWarn, Error: No mercurial configuration present, cannot create .src-rev) | ||
exit 2 | ||
|
||
create-source-revision-tracker: | ||
$(call LogWarn, Error: No mercurial configuration present and no .src-rev) | ||
exit 2 | ||
endif | ||
|
||
endif | ||
|
||
all: store-source-revision create-source-revision-tracker | ||
|
||
FRC: # Force target | ||
|
||
.PHONY: all store-source-revision create-source-revision-tracker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -337,44 +337,21 @@ else # HAS_FILE_FUNCTION = false | |
endif # HAS_FILE_FUNCTION | ||
|
||
################################################################################ | ||
# 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 .hg directory. The hgtip files are created in | ||
# CreateHgtipFiles.gmk. | ||
HGTIP_FILENAME := .hgtip | ||
|
||
# A file containing a way to uniquely identify the source code revision that | ||
# the build was created from | ||
SOURCE_REVISION_TRACKER := $(SUPPORT_OUTPUTDIR)/src-rev/source-revision-tracker | ||
|
||
# Locate all hg repositories included in the forest, as absolute paths | ||
FindAllReposAbs = \ | ||
$(strip $(sort $(dir $(filter-out $(SRC_ROOT)/build/%, $(wildcard \ | ||
$(addprefix $(SRC_ROOT)/, \ | ||
.hg */.hg */*/.hg */*/.hg */*/*/.hg \ | ||
.hgtip */.hgtip */*/.hgtip */*/.hgtip */*/*/.hgtip \ | ||
) \ | ||
$(addprefix $(SRC_ROOT)/, .hg */.hg */*/.hg */*/*/.hg) \ | ||
))))) | ||
|
||
# Locate all hg repositories included in the forest, as relative paths | ||
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 $(FindAllReposRel) IGNORE ; do \ | ||
if [ "$${i}" = "IGNORE" ] ; then \ | ||
continue; \ | ||
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 \ | ||
$(PRINTF) " %s:%s" \ | ||
"$${i}" `$(CAT) $${i}/$(HGTIP_FILENAME)` ; \ | ||
fi; \ | ||
done > [email protected] | ||
$(PRINTF) "\n" >> [email protected] | ||
if [ ! -f $@ ] || [ "`$(CAT) $@`" != "`$(CAT) [email protected]`" ]; then \ | ||
$(MV) [email protected] $@ ; \ | ||
else \ | ||
$(RM) [email protected] ; \ | ||
fi | ||
endef | ||
|
||
################################################################################ | ||
|
||
define SetupLogging | ||
|