author | iignatyev |
Wed, 27 Jun 2018 16:19:28 -0700 | |
changeset 50855 | 9ca5f18240b2 |
parent 47314 | 743814386712 |
child 51553 | 867acd5a4140 |
permissions | -rw-r--r-- |
39110
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
1 |
# |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
2 |
# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
3 |
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
4 |
# |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
5 |
# This code is free software; you can redistribute it and/or modify it |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
6 |
# under the terms of the GNU General Public License version 2 only, as |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
7 |
# published by the Free Software Foundation. Oracle designates this |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
8 |
# particular file as subject to the "Classpath" exception as provided |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
9 |
# by Oracle in the LICENSE file that accompanied this code. |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
10 |
# |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
11 |
# This code is distributed in the hope that it will be useful, but WITHOUT |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
13 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
14 |
# version 2 for more details (a copy is included in the LICENSE file that |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
15 |
# accompanied this code). |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
16 |
# |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
17 |
# You should have received a copy of the GNU General Public License version |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
18 |
# 2 along with this work; if not, write to the Free Software Foundation, |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
19 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
20 |
# |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
21 |
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
22 |
# or visit www.oracle.com if you need additional information or have any |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
23 |
# questions. |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
24 |
# |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
25 |
|
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
26 |
default: all |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
27 |
|
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
28 |
include $(SPEC) |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
29 |
include MakeBase.gmk |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
30 |
|
47314 | 31 |
$(eval $(call IncludeCustomExtension, SourceRevision.gmk)) |
47217 | 32 |
|
42282
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
33 |
################################################################################ |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
34 |
# Keep track of what source revision is used to create the build, by creating |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
35 |
# a tracker file in the output directory. This tracker file is included in the |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
36 |
# image, and can be used to recreate the source revision used. |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
37 |
# |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
38 |
# We're either building directly from a mercurial forest, and if so, use the |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
39 |
# current revision from mercurial. Otherwise, we are building from a source |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
40 |
# bundle. As a part of creating this source bundle, the current mercurial |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
41 |
# revisions of all repos will be stored in a file in the top dir, which is then |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
42 |
# used when creating the tracker file. |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
43 |
|
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
44 |
STORED_SOURCE_REVISION := $(TOPDIR)/.src-rev |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
45 |
|
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
46 |
# Are we using mercurial? |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
47 |
ifneq ($(and $(HG), $(wildcard $(TOPDIR)/.hg)), ) |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
48 |
|
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
49 |
# Verify that the entire forest is consistent |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
50 |
$(foreach repo, $(call FindAllReposRel), \ |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
51 |
$(if $(wildcard $(TOPDIR)/$(repo)/.hg),, \ |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
52 |
$(error Inconsistent revision control: $(repo) is missing .hg directory)) \ |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
53 |
) |
39110
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
54 |
|
42282
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
55 |
# Replace "." with "_top" and "/" with "-" |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
56 |
MakeFilenameFromRepo = \ |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
57 |
$(strip $(subst .,top, $(subst /,-, $1))) |
39110
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
58 |
|
42282
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
59 |
################################################################################ |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
60 |
# SetupGetRevisionForRepo defines a make rule for creating a file containing |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
61 |
# the name of the repository and the output of "hg id" for that repository. |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
62 |
# Argument 1 is the relative path to the repository from the top dir. |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
63 |
# |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
64 |
SetupGetRevisionForRepo = $(NamedParamsMacroTemplate) |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
65 |
define SetupGetRevisionForRepoBody |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
66 |
$1_REPO_PATH := $$(TOPDIR)/$$(strip $1) |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
67 |
$1_FILENAME := $$(call MakeFilenameFromRepo, $1) |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
68 |
|
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
69 |
$$(SUPPORT_OUTPUTDIR)/src-rev/$$($1_FILENAME): FRC |
42283 | 70 |
$$(call MakeDir, $$(@D)) |
71 |
$$(ECHO) $$(strip $1):`$$(HG) id -i --repository $$($1_REPO_PATH)` > $$@ |
|
42282
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
72 |
|
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
73 |
REPO_REVISIONS += $$(SUPPORT_OUTPUTDIR)/src-rev/$$($1_FILENAME) |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
74 |
endef |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
75 |
|
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
76 |
# Setup rules for all repos. This makes sure all the "hg id" calls are made |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
77 |
# in parallel. |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
78 |
$(foreach repo, $(call FindAllReposRel), \ |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
79 |
$(eval $(call SetupGetRevisionForRepo, $(repo))) \ |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
80 |
) |
39110
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
81 |
|
42282
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
82 |
# Create a complete source revision output file from all repos |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
83 |
# Param 1: The output file |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
84 |
define CreateSourceRevisionFile |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
85 |
$1: $$(REPO_REVISIONS) |
42283 | 86 |
$$(call MakeDir, $$(@D)) |
42282
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
87 |
$$(ECHO) `$$(CAT) $$(REPO_REVISIONS)` > $$@.tmp |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
88 |
if [ ! -f $$@ ] || [ "`$$(CAT) $$@`" != "`$$(CAT) $$@.tmp`" ]; then \ |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
89 |
$$(MV) $$@.tmp $$@ ; \ |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
90 |
else \ |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
91 |
$$(RM) $$@.tmp ; \ |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
92 |
fi |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
93 |
endef |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
94 |
|
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
95 |
$(eval $(call CreateSourceRevisionFile, $(STORED_SOURCE_REVISION))) |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
96 |
|
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
97 |
store-source-revision: $(STORED_SOURCE_REVISION) |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
98 |
|
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
99 |
$(eval $(call CreateSourceRevisionFile, $(SOURCE_REVISION_TRACKER))) |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
100 |
|
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
101 |
create-source-revision-tracker: $(SOURCE_REVISION_TRACKER) |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
102 |
|
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
103 |
else |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
104 |
# Not using HG |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
105 |
|
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
106 |
ifneq ($(wildcard $(STORED_SOURCE_REVISION)), ) |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
107 |
# We have a stored source revision (.src-rev) |
39110
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
108 |
|
42282
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
109 |
store-source-revision: |
42848
27ad8b2418f7
8170741: Enable uploading of built artifacts through Jib
erikj
parents:
42284
diff
changeset
|
110 |
$(call LogInfo, No mercurial configuration present$(COMMA) not updating .src-rev) |
42282
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
111 |
|
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
112 |
$(SOURCE_REVISION_TRACKER): $(STORED_SOURCE_REVISION) |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
113 |
$(install-file) |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
114 |
|
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
115 |
create-source-revision-tracker: $(SOURCE_REVISION_TRACKER) |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
116 |
else |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
117 |
# We don't have a stored source revision. Can't do anything, really. |
39110
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
118 |
|
42282
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
119 |
store-source-revision: |
42848
27ad8b2418f7
8170741: Enable uploading of built artifacts through Jib
erikj
parents:
42284
diff
changeset
|
120 |
$(call LogWarn, Error: No mercurial configuration present$(COMMA) cannot create .src-rev) |
42282
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
121 |
exit 2 |
39110
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
122 |
|
42282
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
123 |
create-source-revision-tracker: |
42284
38f8784217d0
8170392: JDK-8031567 broke builds from source bundles
erikj
parents:
42283
diff
changeset
|
124 |
$(call LogWarn, Warning: No mercurial configuration present and no .src-rev) |
42282
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
125 |
endif |
39110
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
diff
changeset
|
126 |
|
42282
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
127 |
endif |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
128 |
|
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
129 |
all: store-source-revision create-source-revision-tracker |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
130 |
|
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
131 |
FRC: # Force target |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
132 |
|
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
39110
diff
changeset
|
133 |
.PHONY: all store-source-revision create-source-revision-tracker |