annotate make/SourceRevision.gmk @ 52350:51a3e729535c

8212941: Loosen the range of JapaneseEra Reviewed-by: rriggs
author naoto
date Tue, 30 Oct 2018 10:32:54 -0700
parents 867acd5a4140
children
rev   line source
erikj@39110 1 #
twisti@51570 2 # Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
erikj@39110 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
erikj@39110 4 #
erikj@39110 5 # This code is free software; you can redistribute it and/or modify it
erikj@39110 6 # under the terms of the GNU General Public License version 2 only, as
erikj@39110 7 # published by the Free Software Foundation. Oracle designates this
erikj@39110 8 # particular file as subject to the "Classpath" exception as provided
erikj@39110 9 # by Oracle in the LICENSE file that accompanied this code.
erikj@39110 10 #
erikj@39110 11 # This code is distributed in the hope that it will be useful, but WITHOUT
erikj@39110 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
erikj@39110 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
erikj@39110 14 # version 2 for more details (a copy is included in the LICENSE file that
erikj@39110 15 # accompanied this code).
erikj@39110 16 #
erikj@39110 17 # You should have received a copy of the GNU General Public License version
erikj@39110 18 # 2 along with this work; if not, write to the Free Software Foundation,
erikj@39110 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
erikj@39110 20 #
erikj@39110 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
erikj@39110 22 # or visit www.oracle.com if you need additional information or have any
erikj@39110 23 # questions.
erikj@39110 24 #
erikj@39110 25
erikj@39110 26 include $(SPEC)
erikj@39110 27 include MakeBase.gmk
erikj@39110 28
twisti@51570 29 $(eval $(call IncludeCustomExtension, SourceRevision-pre.gmk))
erikj@47217 30
ihse@42282 31 ################################################################################
ihse@42282 32 # Keep track of what source revision is used to create the build, by creating
ihse@42282 33 # a tracker file in the output directory. This tracker file is included in the
erikj@51694 34 # source image, and can be used to recreate the source revision used.
ihse@42282 35 #
erikj@51694 36 # We're either building directly from an SCM repository, and if so, use the
erikj@51694 37 # current revision from that SCM. Otherwise, we are building from a source
erikj@51694 38 # bundle. As a part of creating this source bundle, the current SCM revisions of
erikj@51694 39 # all repos will be stored in a file in the top dir, which is then used when
erikj@51694 40 # creating the tracker file.
erikj@39110 41
ihse@42282 42 STORED_SOURCE_REVISION := $(TOPDIR)/.src-rev
ihse@42282 43
erikj@51694 44 USE_SCM := false
ihse@42282 45 ifneq ($(and $(HG), $(wildcard $(TOPDIR)/.hg)), )
erikj@51694 46 USE_SCM := true
erikj@51694 47 SCM_DIR := .hg
erikj@51694 48 ID_COMMAND := $(PRINTF) "hg:%s" "$$($(HG) id -i)"
erikj@51694 49 else ifneq ($(and $(GIT), $(wildcard $(TOPDIR)/.git)), )
erikj@51694 50 USE_SCM := true
erikj@51694 51 SCM_DIR := .git
erikj@51694 52 ID_COMMAND := $(PRINTF) "git:%s%s\n" \
erikj@51694 53 "$$(git log -n1 --format=%H | cut -c1-12)" \
erikj@51694 54 "$$(if test -n "$$(git status --porcelain)"; then printf '+'; fi)"
erikj@51694 55 endif
erikj@51694 56
erikj@51694 57 ifeq ($(USE_SCM), true)
ihse@42282 58
ihse@42282 59 # Verify that the entire forest is consistent
ihse@42282 60 $(foreach repo, $(call FindAllReposRel), \
erikj@51694 61 $(if $(wildcard $(TOPDIR)/$(repo)/$(SCM_DIR)),, \
erikj@51694 62 $(error Inconsistent revision control: $(repo) is missing $(SCM_DIR) directory)) \
ihse@42282 63 )
ihse@42282 64
ihse@42282 65 # Replace "." with "_top" and "/" with "-"
ihse@42282 66 MakeFilenameFromRepo = \
ihse@42282 67 $(strip $(subst .,top, $(subst /,-, $1)))
ihse@42282 68
ihse@42282 69 ################################################################################
ihse@42282 70 # SetupGetRevisionForRepo defines a make rule for creating a file containing
erikj@51694 71 # the name of the repository and the output of the scm command for that
erikj@51694 72 # repository.
erikj@51694 73 #
ihse@42282 74 # Argument 1 is the relative path to the repository from the top dir.
ihse@42282 75 #
ihse@42282 76 SetupGetRevisionForRepo = $(NamedParamsMacroTemplate)
ihse@42282 77 define SetupGetRevisionForRepoBody
ihse@42282 78 $1_REPO_PATH := $$(TOPDIR)/$$(strip $1)
ihse@42282 79 $1_FILENAME := $$(call MakeFilenameFromRepo, $1)
ihse@42282 80
ihse@42282 81 $$(SUPPORT_OUTPUTDIR)/src-rev/$$($1_FILENAME): FRC
ihse@42283 82 $$(call MakeDir, $$(@D))
erikj@51694 83 $$(ECHO) $$(strip $1):`$$(CD) $$($1_REPO_PATH) && $$(ID_COMMAND)` > $$@
ihse@42282 84
ihse@42282 85 REPO_REVISIONS += $$(SUPPORT_OUTPUTDIR)/src-rev/$$($1_FILENAME)
ihse@42282 86 endef
ihse@42282 87
ihse@42282 88 # Setup rules for all repos. This makes sure all the "hg id" calls are made
ihse@42282 89 # in parallel.
ihse@42282 90 $(foreach repo, $(call FindAllReposRel), \
ihse@42282 91 $(eval $(call SetupGetRevisionForRepo, $(repo))) \
ihse@42282 92 )
ihse@42282 93
ihse@42282 94 # Create a complete source revision output file from all repos
ihse@42282 95 # Param 1: The output file
ihse@42282 96 define CreateSourceRevisionFile
ihse@42282 97 $1: $$(REPO_REVISIONS)
ihse@42283 98 $$(call MakeDir, $$(@D))
ihse@42282 99 $$(ECHO) `$$(CAT) $$(REPO_REVISIONS)` > $$@.tmp
ihse@42282 100 if [ ! -f $$@ ] || [ "`$$(CAT) $$@`" != "`$$(CAT) $$@.tmp`" ]; then \
ihse@42282 101 $$(MV) $$@.tmp $$@ ; \
erikj@39110 102 else \
ihse@42282 103 $$(RM) $$@.tmp ; \
erikj@39110 104 fi
ihse@42282 105 endef
erikj@39110 106
ihse@42282 107 $(eval $(call CreateSourceRevisionFile, $(STORED_SOURCE_REVISION)))
erikj@39110 108
erikj@51694 109 scm-store-source-revision: $(STORED_SOURCE_REVISION)
erikj@39110 110
ihse@42282 111 $(eval $(call CreateSourceRevisionFile, $(SOURCE_REVISION_TRACKER)))
erikj@39110 112
erikj@51694 113 scm-create-source-revision-tracker: $(SOURCE_REVISION_TRACKER)
twisti@51570 114
erikj@51694 115 STORE_SOURCE_REVISION_TARGET := scm-store-source-revision
erikj@51694 116 CREATE_SOURCE_REVISION_TRACKER_TARGET := scm-create-source-revision-tracker
erikj@51694 117
erikj@51694 118 .PHONY: scm-store-source-revision scm-create-source-revision-tracker
erikj@39110 119
ihse@42282 120 else
erikj@51694 121 # Not using any SCM
erikj@39110 122
ihse@42282 123 ifneq ($(wildcard $(STORED_SOURCE_REVISION)), )
ihse@42282 124 # We have a stored source revision (.src-rev)
ihse@42282 125
twisti@51570 126 src-store-source-revision:
erikj@51694 127 $(call LogInfo, No SCM configuration present$(COMMA) not updating .src-rev)
ihse@42282 128
ihse@42282 129 $(SOURCE_REVISION_TRACKER): $(STORED_SOURCE_REVISION)
ihse@42282 130 $(install-file)
ihse@42282 131
twisti@51570 132 src-create-source-revision-tracker: $(SOURCE_REVISION_TRACKER)
ihse@42282 133 else
ihse@42282 134 # We don't have a stored source revision. Can't do anything, really.
ihse@42282 135
twisti@51570 136 src-store-source-revision:
erikj@51694 137 $(call LogWarn, Error: No SCM configuration present$(COMMA) cannot create .src-rev)
ihse@42282 138 exit 2
ihse@42282 139
twisti@51570 140 src-create-source-revision-tracker:
erikj@51694 141 $(call LogWarn, Warning: No SCM configuration present and no .src-rev)
ihse@42282 142 endif
ihse@42282 143
twisti@51570 144 STORE_SOURCE_REVISION_TARGET := src-store-source-revision
twisti@51570 145 CREATE_SOURCE_REVISION_TRACKER_TARGET := src-create-source-revision-tracker
twisti@51570 146
erikj@51694 147 .PHONY: src-store-source-revision src-create-source-revision-tracker
erikj@51694 148
ihse@42282 149 endif
ihse@42282 150
twisti@51570 151 ################################################################################
twisti@51570 152
twisti@51570 153 $(eval $(call IncludeCustomExtension, SourceRevision-post.gmk))
twisti@51570 154
twisti@51570 155 ################################################################################
twisti@51570 156
twisti@51570 157 store-source-revision: $(STORE_SOURCE_REVISION_TARGET)
twisti@51570 158
twisti@51570 159 create-source-revision-tracker: $(CREATE_SOURCE_REVISION_TRACKER_TARGET)
ihse@42282 160
ihse@42282 161 FRC: # Force target
ihse@42282 162
twisti@51570 163 .PHONY: store-source-revision create-source-revision-tracker