author | gadams |
Mon, 04 Mar 2019 08:45:05 -0500 | |
changeset 53988 | efa9bc147d50 |
parent 53829 | 56dc0b27536c |
child 54380 | e297c7bb6469 |
permissions | -rw-r--r-- |
12258
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
1 |
# |
53484 | 2 |
# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. |
12258
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
3 |
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
4 |
# |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
5 |
# This code is free software; you can redistribute it and/or modify it |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
6 |
# under the terms of the GNU General Public License version 2 only, as |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
7 |
# published by the Free Software Foundation. Oracle designates this |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
8 |
# particular file as subject to the "Classpath" exception as provided |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
9 |
# by Oracle in the LICENSE file that accompanied this code. |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
10 |
# |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
11 |
# This code is distributed in the hope that it will be useful, but WITHOUT |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
13 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
14 |
# version 2 for more details (a copy is included in the LICENSE file that |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
15 |
# accompanied this code). |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
16 |
# |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
17 |
# You should have received a copy of the GNU General Public License version |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
18 |
# 2 along with this work; if not, write to the Free Software Foundation, |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
19 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
20 |
# |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
21 |
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
22 |
# or visit www.oracle.com if you need additional information or have any |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
23 |
# questions. |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
24 |
# |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
25 |
|
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
26 |
################################################################ |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
27 |
# |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
28 |
# Setup common utility functions. |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
29 |
# |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
30 |
################################################################ |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
31 |
|
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
32 |
ifndef _MAKEBASE_GMK |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
33 |
_MAKEBASE_GMK := 1 |
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
34 |
|
29662 | 35 |
ifeq ($(wildcard $(SPEC)),) |
36 |
$(error MakeBase.gmk needs SPEC set to a proper spec.gmk) |
|
37 |
endif |
|
38 |
||
29861 | 39 |
# By defining this pseudo target, make will automatically remove targets |
40 |
# if their recipe fails so that a rebuild is automatically triggered on the |
|
41 |
# next make invocation. |
|
42 |
.DELETE_ON_ERROR: |
|
29662 | 43 |
|
32460
9e9bffb3029a
8065912: Better handling of classpath in build-infra
ihse
parents:
32344
diff
changeset
|
44 |
################################################################################ |
9e9bffb3029a
8065912: Better handling of classpath in build-infra
ihse
parents:
32344
diff
changeset
|
45 |
# Definitions for special characters |
9e9bffb3029a
8065912: Better handling of classpath in build-infra
ihse
parents:
32344
diff
changeset
|
46 |
################################################################################ |
9e9bffb3029a
8065912: Better handling of classpath in build-infra
ihse
parents:
32344
diff
changeset
|
47 |
|
9e9bffb3029a
8065912: Better handling of classpath in build-infra
ihse
parents:
32344
diff
changeset
|
48 |
# When calling macros, the spaces between arguments are |
9e9bffb3029a
8065912: Better handling of classpath in build-infra
ihse
parents:
32344
diff
changeset
|
49 |
# often semantically important! Sometimes we need to subst |
9e9bffb3029a
8065912: Better handling of classpath in build-infra
ihse
parents:
32344
diff
changeset
|
50 |
# spaces and commas, therefore we need the following macros. |
9e9bffb3029a
8065912: Better handling of classpath in build-infra
ihse
parents:
32344
diff
changeset
|
51 |
X:= |
9e9bffb3029a
8065912: Better handling of classpath in build-infra
ihse
parents:
32344
diff
changeset
|
52 |
SPACE:=$(X) $(X) |
9e9bffb3029a
8065912: Better handling of classpath in build-infra
ihse
parents:
32344
diff
changeset
|
53 |
COMMA:=, |
9e9bffb3029a
8065912: Better handling of classpath in build-infra
ihse
parents:
32344
diff
changeset
|
54 |
DOLLAR:=$$ |
9e9bffb3029a
8065912: Better handling of classpath in build-infra
ihse
parents:
32344
diff
changeset
|
55 |
HASH:=\# |
9e9bffb3029a
8065912: Better handling of classpath in build-infra
ihse
parents:
32344
diff
changeset
|
56 |
LEFT_PAREN:=( |
9e9bffb3029a
8065912: Better handling of classpath in build-infra
ihse
parents:
32344
diff
changeset
|
57 |
RIGHT_PAREN:=) |
9e9bffb3029a
8065912: Better handling of classpath in build-infra
ihse
parents:
32344
diff
changeset
|
58 |
SQUOTE:=' |
9e9bffb3029a
8065912: Better handling of classpath in build-infra
ihse
parents:
32344
diff
changeset
|
59 |
#' |
9e9bffb3029a
8065912: Better handling of classpath in build-infra
ihse
parents:
32344
diff
changeset
|
60 |
DQUOTE:=" |
9e9bffb3029a
8065912: Better handling of classpath in build-infra
ihse
parents:
32344
diff
changeset
|
61 |
#" |
9e9bffb3029a
8065912: Better handling of classpath in build-infra
ihse
parents:
32344
diff
changeset
|
62 |
define NEWLINE |
9e9bffb3029a
8065912: Better handling of classpath in build-infra
ihse
parents:
32344
diff
changeset
|
63 |
|
9e9bffb3029a
8065912: Better handling of classpath in build-infra
ihse
parents:
32344
diff
changeset
|
64 |
|
9e9bffb3029a
8065912: Better handling of classpath in build-infra
ihse
parents:
32344
diff
changeset
|
65 |
endef |
9e9bffb3029a
8065912: Better handling of classpath in build-infra
ihse
parents:
32344
diff
changeset
|
66 |
|
32807
20386e6d858f
8136385: Various build speed improvements for windows
erikj
parents:
32553
diff
changeset
|
67 |
# In GNU Make 4.0 and higher, there is a file function for writing to files. |
20386e6d858f
8136385: Various build speed improvements for windows
erikj
parents:
32553
diff
changeset
|
68 |
ifeq (4.0, $(firstword $(sort 4.0 $(MAKE_VERSION)))) |
20386e6d858f
8136385: Various build speed improvements for windows
erikj
parents:
32553
diff
changeset
|
69 |
HAS_FILE_FUNCTION := true |
49270 | 70 |
CORRECT_FUNCTION_IN_RECIPE_EVALUATION := true |
32807
20386e6d858f
8136385: Various build speed improvements for windows
erikj
parents:
32553
diff
changeset
|
71 |
endif |
20386e6d858f
8136385: Various build speed improvements for windows
erikj
parents:
32553
diff
changeset
|
72 |
|
29662 | 73 |
|
53484 | 74 |
# For convenience, MakeBase.gmk continues to include these separate files, at |
75 |
# least for now. |
|
30095
0034766ccb09
8079344: Allow custom or platform specific java source to automatically override shared source
erikj
parents:
29866
diff
changeset
|
76 |
|
53484 | 77 |
include $(TOPDIR)/make/common/Utils.gmk |
78 |
include $(TOPDIR)/make/common/MakeIO.gmk |
|
79 |
include $(TOPDIR)/make/common/CopyFiles.gmk |
|
29662 | 80 |
|
53484 | 81 |
################################################################################ |
82 |
# Functions for timers |
|
83 |
################################################################################ |
|
29662 | 84 |
|
85 |
# Store the build times in this directory. |
|
47253
92fd0e04e0e1
8187544: Replace BUILD_OUTPUT and OUTPUT_ROOT with OUTPUTDIR
ihse
parents:
47217
diff
changeset
|
86 |
BUILDTIMESDIR=$(OUTPUTDIR)/make-support/build-times |
29662 | 87 |
|
88 |
# Record starting time for build of a sub repository. |
|
89 |
define RecordStartTime |
|
35008 | 90 |
$(DATE) '+%Y %m %d %H %M %S' | $(NAWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_start_$(strip $1) && \ |
29662 | 91 |
$(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_start_$(strip $1)_human_readable |
92 |
endef |
|
93 |
||
94 |
# Record ending time and calculate the difference and store it in a |
|
95 |
# easy to read format. Handles builds that cross midnight. Expects |
|
96 |
# that a build will never take 24 hours or more. |
|
97 |
define RecordEndTime |
|
98 |
$(DATE) '+%Y %m %d %H %M %S' | $(NAWK) '{ print $$1,$$2,$$3,$$4,$$5,$$6,($$4*3600+$$5*60+$$6) }' > $(BUILDTIMESDIR)/build_time_end_$(strip $1) |
|
99 |
$(DATE) '+%Y-%m-%d %H:%M:%S' > $(BUILDTIMESDIR)/build_time_end_$(strip $1)_human_readable |
|
100 |
$(ECHO) `$(CAT) $(BUILDTIMESDIR)/build_time_start_$(strip $1)` `$(CAT) $(BUILDTIMESDIR)/build_time_end_$(strip $1)` $1 | \ |
|
101 |
$(NAWK) '{ F=$$7; T=$$14; if (F > T) { T+=3600*24 }; D=T-F; H=int(D/3600); \ |
|
102 |
M=int((D-H*3600)/60); S=D-H*3600-M*60; printf("%02d:%02d:%02d %s\n",H,M,S,$$15); }' \ |
|
103 |
> $(BUILDTIMESDIR)/build_time_diff_$(strip $1) |
|
104 |
endef |
|
105 |
||
106 |
# Hook to be called when starting to execute a top-level target |
|
107 |
define TargetEnter |
|
108 |
$(PRINTF) "## Starting $(patsubst %-only,%,$@)\n" |
|
109 |
$(call RecordStartTime,$(patsubst %-only,%,$@)) |
|
110 |
endef |
|
111 |
||
112 |
# Hook to be called when finish executing a top-level target |
|
113 |
define TargetExit |
|
114 |
$(call RecordEndTime,$(patsubst %-only,%,$@)) |
|
115 |
$(PRINTF) "## Finished $(patsubst %-only,%,$@) (build time %s)\n\n" \ |
|
116 |
"`$(CAT) $(BUILDTIMESDIR)/build_time_diff_$(patsubst %-only,%,$@) | $(CUT) -f 1 -d ' '`" |
|
117 |
endef |
|
118 |
||
25854 | 119 |
################################################################################ |
42282
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
42134
diff
changeset
|
120 |
|
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
42134
diff
changeset
|
121 |
# A file containing a way to uniquely identify the source code revision that |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
42134
diff
changeset
|
122 |
# the build was created from |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
42134
diff
changeset
|
123 |
SOURCE_REVISION_TRACKER := $(SUPPORT_OUTPUTDIR)/src-rev/source-revision-tracker |
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
42134
diff
changeset
|
124 |
|
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
42134
diff
changeset
|
125 |
# Locate all hg repositories included in the forest, as absolute paths |
39110
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
37972
diff
changeset
|
126 |
FindAllReposAbs = \ |
47217 | 127 |
$(strip $(sort $(dir $(filter-out $(TOPDIR)/build/%, $(wildcard \ |
128 |
$(addprefix $(TOPDIR)/, .hg */.hg */*/.hg */*/*/.hg */*/*/*/.hg) \ |
|
51676
5a1be00ea4f6
8210283: Support git as an SCM alternative in the build
erikj
parents:
51069
diff
changeset
|
129 |
$(addprefix $(TOPDIR)/, .git */.git */*/.git */*/*/.git */*/*/*/.git) \ |
39110
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
37972
diff
changeset
|
130 |
))))) |
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
37972
diff
changeset
|
131 |
|
42282
faf3b6722c44
8031567: Better model for storing source revision information
ihse
parents:
42134
diff
changeset
|
132 |
# Locate all hg repositories included in the forest, as relative paths |
39110
712f29ba8708
8136771: Implement the license-swap logic as a make target
erikj
parents:
37972
diff
changeset
|
133 |
FindAllReposRel = \ |
47217 | 134 |
$(strip $(subst $(TOPDIR)/,.,$(patsubst $(TOPDIR)/%/, %, $(FindAllReposAbs)))) |
12801 | 135 |
|
35008 | 136 |
################################################################################ |
137 |
||
12801 | 138 |
define SetupLogging |
44465
26fabd8abee9
8177770: Need more precise control on build system logging
asemenyuk
parents:
44027
diff
changeset
|
139 |
ifeq ($$(LOG_PROFILE_TIMES_FILE), true) |
26fabd8abee9
8177770: Need more precise control on build system logging
asemenyuk
parents:
44027
diff
changeset
|
140 |
ifeq ($$(IS_GNU_TIME), yes) |
47217 | 141 |
SHELL := $$(BASH) $$(TOPDIR)/make/scripts/shell-profiler.sh \ |
44465
26fabd8abee9
8177770: Need more precise control on build system logging
asemenyuk
parents:
44027
diff
changeset
|
142 |
gnutime $$(TIME) \ |
47253
92fd0e04e0e1
8187544: Replace BUILD_OUTPUT and OUTPUT_ROOT with OUTPUTDIR
ihse
parents:
47217
diff
changeset
|
143 |
$$(OUTPUTDIR)/build-profile.log $$(SHELL) |
44465
26fabd8abee9
8177770: Need more precise control on build system logging
asemenyuk
parents:
44027
diff
changeset
|
144 |
else ifneq ($$(FLOCK), ) |
47217 | 145 |
SHELL := $$(BASH) $$(TOPDIR)/make/scripts/shell-profiler.sh \ |
44465
26fabd8abee9
8177770: Need more precise control on build system logging
asemenyuk
parents:
44027
diff
changeset
|
146 |
flock $$(FLOCK) \ |
47253
92fd0e04e0e1
8187544: Replace BUILD_OUTPUT and OUTPUT_ROOT with OUTPUTDIR
ihse
parents:
47217
diff
changeset
|
147 |
$$(OUTPUTDIR)/build-profile.log $$(SHELL) |
44465
26fabd8abee9
8177770: Need more precise control on build system logging
asemenyuk
parents:
44027
diff
changeset
|
148 |
endif |
26fabd8abee9
8177770: Need more precise control on build system logging
asemenyuk
parents:
44027
diff
changeset
|
149 |
endif |
26fabd8abee9
8177770: Need more precise control on build system logging
asemenyuk
parents:
44027
diff
changeset
|
150 |
|
29662 | 151 |
ifeq ($$(LOG_LEVEL), trace) |
44465
26fabd8abee9
8177770: Need more precise control on build system logging
asemenyuk
parents:
44027
diff
changeset
|
152 |
SHELL_NO_RECURSE := $$(SHELL) |
20363 | 153 |
# Shell redefinition trick inspired by http://www.cmcrossroads.com/ask-mr-make/6535-tracing-rule-execution-in-gnu-make |
154 |
# For each target executed, will print |
|
155 |
# Building <TARGET> (from <FIRST PREREQUISITE>) (<ALL NEWER PREREQUISITES> newer) |
|
156 |
# but with a limit of 20 on <ALL NEWER PREREQUISITES>, to avoid cluttering logs too much |
|
157 |
# (and causing a crash on Cygwin). |
|
44465
26fabd8abee9
8177770: Need more precise control on build system logging
asemenyuk
parents:
44027
diff
changeset
|
158 |
SHELL = $$(warning $$(if $$@,Building $$@,Running shell command) $$(if $$<, (from $$<))$$(if $$?, ($$(wordlist 1, 20, $$?) $$(if $$(wordlist 21, 22, $$?), ... [in total $$(words $$?) files]) newer)))$$(SHELL_NO_RECURSE) -x |
20363 | 159 |
endif |
44465
26fabd8abee9
8177770: Need more precise control on build system logging
asemenyuk
parents:
44027
diff
changeset
|
160 |
|
35444 | 161 |
# The warn level can never be turned off |
162 |
LogWarn = $$(info $$(strip $$1)) |
|
29662 | 163 |
LOG_WARN := |
164 |
ifneq ($$(findstring $$(LOG_LEVEL), info debug trace),) |
|
34596
e8328ce5b64e
8142907: Integration of minor fixes from the build-infra project
ihse
parents:
33394
diff
changeset
|
165 |
LogInfo = $$(info $$(strip $$1)) |
29662 | 166 |
LOG_INFO := |
20363 | 167 |
else |
34596
e8328ce5b64e
8142907: Integration of minor fixes from the build-infra project
ihse
parents:
33394
diff
changeset
|
168 |
LogInfo = |
29662 | 169 |
LOG_INFO := > /dev/null |
20363 | 170 |
endif |
29662 | 171 |
ifneq ($$(findstring $$(LOG_LEVEL), debug trace),) |
34596
e8328ce5b64e
8142907: Integration of minor fixes from the build-infra project
ihse
parents:
33394
diff
changeset
|
172 |
LogDebug = $$(info $$(strip $$1)) |
29662 | 173 |
LOG_DEBUG := |
20363 | 174 |
else |
34596
e8328ce5b64e
8142907: Integration of minor fixes from the build-infra project
ihse
parents:
33394
diff
changeset
|
175 |
LogDebug = |
29662 | 176 |
LOG_DEBUG := > /dev/null |
20363 | 177 |
endif |
29662 | 178 |
ifneq ($$(findstring $$(LOG_LEVEL), trace),) |
34596
e8328ce5b64e
8142907: Integration of minor fixes from the build-infra project
ihse
parents:
33394
diff
changeset
|
179 |
LogTrace = $$(info $$(strip $$1)) |
29662 | 180 |
LOG_TRACE := |
20363 | 181 |
else |
34596
e8328ce5b64e
8142907: Integration of minor fixes from the build-infra project
ihse
parents:
33394
diff
changeset
|
182 |
LogTrace = |
29662 | 183 |
LOG_TRACE := > /dev/null |
20363 | 184 |
endif |
12801 | 185 |
endef |
186 |
||
187 |
# Make sure logging is setup for everyone that includes MakeBase.gmk. |
|
188 |
$(eval $(call SetupLogging)) |
|
189 |
||
29312
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
190 |
################################################################################ |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
191 |
|
49024
953b3fd36b08
8196997: VS2017 The non-Standard std::tr1 namespace and TR1-only machinery are deprecated and will be removed
lfoltan
parents:
48078
diff
changeset
|
192 |
MAX_PARAMS := 36 |
29312
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
193 |
PARAM_SEQUENCE := $(call sequence, 2, $(MAX_PARAMS)) |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
194 |
|
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
195 |
# Template for creating a macro taking named parameters. To use it, assign the |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
196 |
# template to a variable with the name you want for your macro, using '=' |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
197 |
# assignment. Then define a macro body with the suffix "Body". The Body macro |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
198 |
# should take 1 parameter which should be a unique string for that invocation |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
199 |
# of the macro. |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
200 |
# Ex: |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
201 |
# SetupFoo = $(NamedParamsMacroTemplate) |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
202 |
# define SetupFooBody |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
203 |
# # do something |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
204 |
# # access parameters as $$($1_BAR) |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
205 |
# endef |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
206 |
# Call it like this |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
207 |
# $(eval $(call SetupFoo, BUILD_SOMETHING, \ |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
208 |
# BAR := some parameter value, \ |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
209 |
# )) |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
210 |
define NamedParamsMacroTemplate |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
211 |
$(if $($(MAX_PARAMS)),$(error Internal makefile error: \ |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
212 |
Too many named arguments to macro, please update MAX_PARAMS in MakeBase.gmk)) |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
213 |
# Iterate over 2 3 4... and evaluate the named parameters with $1_ as prefix |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
214 |
$(foreach i,$(PARAM_SEQUENCE), $(if $(strip $($i)),\ |
43044 | 215 |
$(strip $1)_$(strip $(call EscapeHash, $(call DoubleDollar, $($i))))$(NEWLINE))) |
29312
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
216 |
# Debug print all named parameter names and values |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
217 |
$(if $(findstring $(LOG_LEVEL),debug trace), \ |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
218 |
$(info $0 $(strip $1) $(foreach i,$(PARAM_SEQUENCE), \ |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
219 |
$(if $(strip $($i)),$(NEWLINE) $(strip [$i] $(if $(filter $(LOG_LEVEL), trace), \ |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
220 |
$($i), $(wordlist 1, 20, $($(i))) $(if $(word 21, $($(i))), ...))))))) |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
221 |
|
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
222 |
$(if $(DEBUG_$(strip $1)), |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
223 |
$(info -------- <<< Begin expansion of $(strip $1)) \ |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
224 |
$(info $(call $(0)Body,$(strip $1))) \ |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
225 |
$(info -------- >>> End expansion of $(strip $1)) \ |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
226 |
) |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
227 |
|
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
228 |
$(call $(0)Body,$(strip $1)) |
14111 | 229 |
endef |
230 |
||
29312
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
231 |
################################################################################ |
47751
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
232 |
# Make directory without forking mkdir if not needed. |
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
233 |
# |
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
234 |
# If a directory with an encoded space is provided, the wildcard function |
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
235 |
# sometimes returns false answers (typically if the dir existed when the |
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
236 |
# makefile was parsed, but was deleted by a previous rule). In that case, always |
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
237 |
# call mkdir regardless of what wildcard says. |
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
238 |
# |
35008 | 239 |
# 1: List of directories to create |
28600
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
240 |
MakeDir = \ |
35444 | 241 |
$(strip \ |
47751
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
242 |
$(eval MakeDir_dirs_to_make := $(strip $(foreach d, $1, \ |
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
243 |
$(if $(findstring ?, $d), '$(call DecodeSpace, $d)', \ |
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
244 |
$(if $(wildcard $d), , $d) \ |
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
245 |
) \ |
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
246 |
))) \ |
35444 | 247 |
$(if $(MakeDir_dirs_to_make), $(shell $(MKDIR) -p $(MakeDir_dirs_to_make))) \ |
248 |
) |
|
14111 | 249 |
|
47751
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
250 |
# Make directory for target file. Should handle spaces in filenames. Just |
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
251 |
# calling $(call MakeDir $(@D)) will not work if the directory contains a space |
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
252 |
# and the target file already exists. In that case, the target file will have |
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
253 |
# its wildcard ? resolved and the $(@D) will evaluate each space separated dir |
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
254 |
# part on its own. |
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
255 |
MakeTargetDir = \ |
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
256 |
$(call MakeDir, $(dir $(call EncodeSpace, $@))) |
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
257 |
|
29312
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
258 |
################################################################################ |
47334
09d386ddaa42
8189095: Import JMC from artifactory using Jib and main makefiles
erikj
parents:
47314
diff
changeset
|
259 |
# All install-file and related macros automatically call DecodeSpace when needed. |
29312
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
260 |
|
53683 | 261 |
ifeq ($(call isTargetOs, solaris), true) |
20363 | 262 |
# On Solaris, if the target is a symlink and exists, cp won't overwrite. |
263 |
# Cp has to operate in recursive mode to allow for -P flag, to preserve soft links. If the |
|
264 |
# name of the target file differs from the source file, rename after copy. |
|
23168
d20a4165e3d2
8036948: Solaris builds broken by fix for 8036611: Cleanup of handling of properties ...
erikj
parents:
21759
diff
changeset
|
265 |
# If the source and target parent directories are the same, recursive copy doesn't work |
d20a4165e3d2
8036948: Solaris builds broken by fix for 8036611: Cleanup of handling of properties ...
erikj
parents:
21759
diff
changeset
|
266 |
# so we fall back on regular copy, which isn't preserving symlinks. |
20363 | 267 |
define install-file |
47751
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
268 |
$(call MakeTargetDir) |
47348
504e70cd64ad
8189324: install-file macro no longer handles files with $ in them
erikj
parents:
47334
diff
changeset
|
269 |
$(RM) '$(call DecodeSpace, $@)' |
49205
d1a19a08389a
8199428: install-file macro fails on filenames with space on Solaris
erikj
parents:
49067
diff
changeset
|
270 |
if [ '$(call DecodeSpace, $(dir $(call EncodeSpace, $@)))' != \ |
47348
504e70cd64ad
8189324: install-file macro no longer handles files with $ in them
erikj
parents:
47334
diff
changeset
|
271 |
'$(call DecodeSpace, $(dir $(call EncodeSpace, $<)))' ]; then \ |
49205
d1a19a08389a
8199428: install-file macro fails on filenames with space on Solaris
erikj
parents:
49067
diff
changeset
|
272 |
$(CP) -f -r -P '$(call DecodeSpace, $<)' \ |
d1a19a08389a
8199428: install-file macro fails on filenames with space on Solaris
erikj
parents:
49067
diff
changeset
|
273 |
'$(call DecodeSpace, $(dir $(call EncodeSpace, $@)))'; \ |
d1a19a08389a
8199428: install-file macro fails on filenames with space on Solaris
erikj
parents:
49067
diff
changeset
|
274 |
if [ '$(call DecodeSpace, $(notdir $(call EncodeSpace, $@)))' != \ |
47348
504e70cd64ad
8189324: install-file macro no longer handles files with $ in them
erikj
parents:
47334
diff
changeset
|
275 |
'$(call DecodeSpace, $(notdir $(call EncodeSpace, $(<))))' ]; then \ |
49205
d1a19a08389a
8199428: install-file macro fails on filenames with space on Solaris
erikj
parents:
49067
diff
changeset
|
276 |
$(MV) '$(call DecodeSpace, $(dir $(call EncodeSpace, $@))/$(notdir $(call EncodeSpace, $<)))' \ |
d1a19a08389a
8199428: install-file macro fails on filenames with space on Solaris
erikj
parents:
49067
diff
changeset
|
277 |
'$(call DecodeSpace, $@)'; \ |
23168
d20a4165e3d2
8036948: Solaris builds broken by fix for 8036611: Cleanup of handling of properties ...
erikj
parents:
21759
diff
changeset
|
278 |
fi; \ |
d20a4165e3d2
8036948: Solaris builds broken by fix for 8036611: Cleanup of handling of properties ...
erikj
parents:
21759
diff
changeset
|
279 |
else \ |
47348
504e70cd64ad
8189324: install-file macro no longer handles files with $ in them
erikj
parents:
47334
diff
changeset
|
280 |
if [ -L '$(call DecodeSpace, $<)' ]; then \ |
23168
d20a4165e3d2
8036948: Solaris builds broken by fix for 8036611: Cleanup of handling of properties ...
erikj
parents:
21759
diff
changeset
|
281 |
$(ECHO) "Source file is a symlink and target is in the same directory: $< $@" ; \ |
d20a4165e3d2
8036948: Solaris builds broken by fix for 8036611: Cleanup of handling of properties ...
erikj
parents:
21759
diff
changeset
|
282 |
exit 1; \ |
d20a4165e3d2
8036948: Solaris builds broken by fix for 8036611: Cleanup of handling of properties ...
erikj
parents:
21759
diff
changeset
|
283 |
fi; \ |
47348
504e70cd64ad
8189324: install-file macro no longer handles files with $ in them
erikj
parents:
47334
diff
changeset
|
284 |
$(CP) -f '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'; \ |
23168
d20a4165e3d2
8036948: Solaris builds broken by fix for 8036611: Cleanup of handling of properties ...
erikj
parents:
21759
diff
changeset
|
285 |
fi |
20363 | 286 |
endef |
53683 | 287 |
else ifeq ($(call isTargetOs, macosx), true) |
20363 | 288 |
# On mac, extended attributes sometimes creep into the source files, which may later |
289 |
# cause the creation of ._* files which confuses testing. Clear these with xattr if |
|
290 |
# set. Some files get their write permissions removed after being copied to the |
|
291 |
# output dir. When these are copied again to images, xattr would fail. By only clearing |
|
292 |
# attributes when they are present, failing on this is avoided. |
|
37972 | 293 |
# |
294 |
# If copying a soft link to a directory, need to delete the target first to avoid |
|
295 |
# weird errors. |
|
20363 | 296 |
define install-file |
47751
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
297 |
$(call MakeTargetDir) |
47348
504e70cd64ad
8189324: install-file macro no longer handles files with $ in them
erikj
parents:
47334
diff
changeset
|
298 |
$(RM) '$(call DecodeSpace, $@)' |
48912 | 299 |
# Work around a weirdness with cp on Macosx. When copying a symlink, if |
300 |
# the target of the link is write protected (e.g. 444), cp will add |
|
301 |
# write permission for the user on the target file (644). Avoid this by |
|
302 |
# using ln to create a new link instead. |
|
303 |
if [ -h '$(call DecodeSpace, $<)' ]; then \ |
|
304 |
$(LN) -s "`$(READLINK) '$(call DecodeSpace, $<)'`" '$(call DecodeSpace, $@)'; \ |
|
305 |
else \ |
|
306 |
$(CP) -fRP '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'; \ |
|
307 |
fi |
|
308 |
if [ -n "`$(XATTR) -ls '$(call DecodeSpace, $@)'`" ]; then \ |
|
309 |
$(XATTR) -cs '$(call DecodeSpace, $@)'; \ |
|
310 |
fi |
|
20363 | 311 |
endef |
14111 | 312 |
else |
20363 | 313 |
define install-file |
47751
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
314 |
$(call MakeTargetDir) |
47348
504e70cd64ad
8189324: install-file macro no longer handles files with $ in them
erikj
parents:
47334
diff
changeset
|
315 |
$(CP) -fP '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)' |
20363 | 316 |
endef |
14111 | 317 |
endif |
318 |
||
42425 | 319 |
# Variant of install file that does not preserve symlinks |
320 |
define install-file-nolink |
|
47751
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
321 |
$(call MakeTargetDir) |
47348
504e70cd64ad
8189324: install-file macro no longer handles files with $ in them
erikj
parents:
47334
diff
changeset
|
322 |
$(CP) -f '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)' |
42425 | 323 |
endef |
324 |
||
29312
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
325 |
################################################################################ |
41658
14de1ab85d25
8062810: Examine src.zip in JDK image and decide if source classes should be organized by module
erikj
parents:
41260
diff
changeset
|
326 |
# link-file-* works similarly to install-file but creates a symlink instead. |
14de1ab85d25
8062810: Examine src.zip in JDK image and decide if source classes should be organized by module
erikj
parents:
41260
diff
changeset
|
327 |
# There are two versions, either creating a relative or an absolute link. Be |
14de1ab85d25
8062810: Examine src.zip in JDK image and decide if source classes should be organized by module
erikj
parents:
41260
diff
changeset
|
328 |
# careful when using this on Windows since the symlink created is only valid in |
14de1ab85d25
8062810: Examine src.zip in JDK image and decide if source classes should be organized by module
erikj
parents:
41260
diff
changeset
|
329 |
# the unix emulation environment. |
14de1ab85d25
8062810: Examine src.zip in JDK image and decide if source classes should be organized by module
erikj
parents:
41260
diff
changeset
|
330 |
define link-file-relative |
47751
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
331 |
$(call MakeTargetDir) |
47348
504e70cd64ad
8189324: install-file macro no longer handles files with $ in them
erikj
parents:
47334
diff
changeset
|
332 |
$(RM) '$(call DecodeSpace, $@)' |
504e70cd64ad
8189324: install-file macro no longer handles files with $ in them
erikj
parents:
47334
diff
changeset
|
333 |
$(LN) -s '$(call DecodeSpace, $(call RelativePath, $<, $(@D)))' '$(call DecodeSpace, $@)' |
41658
14de1ab85d25
8062810: Examine src.zip in JDK image and decide if source classes should be organized by module
erikj
parents:
41260
diff
changeset
|
334 |
endef |
41260 | 335 |
|
41658
14de1ab85d25
8062810: Examine src.zip in JDK image and decide if source classes should be organized by module
erikj
parents:
41260
diff
changeset
|
336 |
define link-file-absolute |
47751
f7e430cbfe34
8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents:
47715
diff
changeset
|
337 |
$(call MakeTargetDir) |
47348
504e70cd64ad
8189324: install-file macro no longer handles files with $ in them
erikj
parents:
47334
diff
changeset
|
338 |
$(RM) '$(call DecodeSpace, $@)' |
504e70cd64ad
8189324: install-file macro no longer handles files with $ in them
erikj
parents:
47334
diff
changeset
|
339 |
$(LN) -s '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)' |
41658
14de1ab85d25
8062810: Examine src.zip in JDK image and decide if source classes should be organized by module
erikj
parents:
41260
diff
changeset
|
340 |
endef |
41260 | 341 |
|
342 |
################################################################################ |
|
29312
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29304
diff
changeset
|
343 |
|
23170
51e606ecede5
8037281: Improve CacheFind and enable on all platforms
erikj
parents:
23169
diff
changeset
|
344 |
ifneq ($(DISABLE_CACHE_FIND), true) |
23984 | 345 |
# In Cygwin, finds are very costly, both because of expensive forks and because |
346 |
# of bad file system caching. Find is used extensively in $(shell) commands to |
|
347 |
# find source files. This makes rerunning make with no or few changes rather |
|
348 |
# expensive. To speed this up, these two macros are used to cache the results |
|
349 |
# of simple find commands for reuse. |
|
350 |
# |
|
351 |
# Runs a find and stores both the directories where it was run and the results. |
|
352 |
# This macro can be called multiple times to add to the cache. Only finds files |
|
353 |
# with no filters. |
|
354 |
# |
|
47334
09d386ddaa42
8189095: Import JMC from artifactory using Jib and main makefiles
erikj
parents:
47314
diff
changeset
|
355 |
# Files containing space will get spaces replaced with ? because GNU Make |
09d386ddaa42
8189095: Import JMC from artifactory using Jib and main makefiles
erikj
parents:
47314
diff
changeset
|
356 |
# cannot handle lists of files with space in them. By using ?, make will match |
09d386ddaa42
8189095: Import JMC from artifactory using Jib and main makefiles
erikj
parents:
47314
diff
changeset
|
357 |
# the wildcard to space in many situations so we don't need to replace back |
09d386ddaa42
8189095: Import JMC from artifactory using Jib and main makefiles
erikj
parents:
47314
diff
changeset
|
358 |
# to space on every use. While not a complete solution it does allow some uses |
09d386ddaa42
8189095: Import JMC from artifactory using Jib and main makefiles
erikj
parents:
47314
diff
changeset
|
359 |
# of CacheFind to function with spaces in file names, including for |
09d386ddaa42
8189095: Import JMC from artifactory using Jib and main makefiles
erikj
parents:
47314
diff
changeset
|
360 |
# SetupCopyFiles. |
09d386ddaa42
8189095: Import JMC from artifactory using Jib and main makefiles
erikj
parents:
47314
diff
changeset
|
361 |
# |
23984 | 362 |
# Needs to be called with $(eval ) |
363 |
# |
|
23170
51e606ecede5
8037281: Improve CacheFind and enable on all platforms
erikj
parents:
23169
diff
changeset
|
364 |
# Even if the performance benifit is negligible on other platforms, keep the |
51e606ecede5
8037281: Improve CacheFind and enable on all platforms
erikj
parents:
23169
diff
changeset
|
365 |
# functionality active unless explicitly disabled to exercise it more. |
51e606ecede5
8037281: Improve CacheFind and enable on all platforms
erikj
parents:
23169
diff
changeset
|
366 |
# |
51e606ecede5
8037281: Improve CacheFind and enable on all platforms
erikj
parents:
23169
diff
changeset
|
367 |
# Initialize FIND_CACHE_DIRS with := to make it a non recursively-expanded variable |
51e606ecede5
8037281: Improve CacheFind and enable on all platforms
erikj
parents:
23169
diff
changeset
|
368 |
FIND_CACHE_DIRS := |
23984 | 369 |
# Param 1 - Dirs to find in |
370 |
# Param 2 - (optional) specialization. Normally "-a \( ... \)" expression. |
|
20363 | 371 |
define FillCacheFind |
23984 | 372 |
# Filter out already cached dirs. The - is needed when FIND_CACHE_DIRS is empty |
23170
51e606ecede5
8037281: Improve CacheFind and enable on all platforms
erikj
parents:
23169
diff
changeset
|
373 |
# since filter out will then return empty. |
51e606ecede5
8037281: Improve CacheFind and enable on all platforms
erikj
parents:
23169
diff
changeset
|
374 |
FIND_CACHE_NEW_DIRS := $$(filter-out $$(addsuffix /%,\ |
51e606ecede5
8037281: Improve CacheFind and enable on all platforms
erikj
parents:
23169
diff
changeset
|
375 |
- $(FIND_CACHE_DIRS)) $(FIND_CACHE_DIRS), $1) |
51e606ecede5
8037281: Improve CacheFind and enable on all platforms
erikj
parents:
23169
diff
changeset
|
376 |
ifneq ($$(FIND_CACHE_NEW_DIRS), ) |
51e606ecede5
8037281: Improve CacheFind and enable on all platforms
erikj
parents:
23169
diff
changeset
|
377 |
# Remove any trailing slash from dirs in the cache dir list |
51e606ecede5
8037281: Improve CacheFind and enable on all platforms
erikj
parents:
23169
diff
changeset
|
378 |
FIND_CACHE_DIRS += $$(patsubst %/,%, $$(FIND_CACHE_NEW_DIRS)) |
47364 | 379 |
FIND_CACHE := $$(sort $$(FIND_CACHE) \ |
380 |
$$(shell $(FIND) $$(wildcard $$(FIND_CACHE_NEW_DIRS)) \ |
|
381 |
\( -type f -o -type l \) $2 | $(TR) ' ' '?')) |
|
23170
51e606ecede5
8037281: Improve CacheFind and enable on all platforms
erikj
parents:
23169
diff
changeset
|
382 |
endif |
20363 | 383 |
endef |
15051
d32ad37472e6
8005540: build-infra: Improve incremental build speed on windows by caching find results
erikj
parents:
14279
diff
changeset
|
384 |
|
23984 | 385 |
# Mimics find by looking in the cache if all of the directories have been cached. |
386 |
# Otherwise reverts to shell find. This is safe to call on all platforms, even if |
|
387 |
# cache is deactivated. |
|
388 |
# |
|
25854 | 389 |
# $1 can be either a directory or a file. If it's a directory, make |
390 |
# sure we have exactly one trailing slash before the wildcard. |
|
23984 | 391 |
# The extra - is needed when FIND_CACHE_DIRS is empty but should be harmless. |
392 |
# |
|
393 |
# Param 1 - Dirs to find in |
|
394 |
# Param 2 - (optional) specialization. Normally "-a \( ... \)" expression. |
|
53829
56dc0b27536c
8211016: make images does not update jdk/lib/src.zip with latest changes
erikj
parents:
53683
diff
changeset
|
395 |
# Param 3 - (optional) options to find. |
23984 | 396 |
define CacheFind |
44725
8747b14eb49c
8172312: Update docs target and image for new combined docs
ihse
parents:
44027
diff
changeset
|
397 |
$(if $(filter-out $(addsuffix /%,- $(FIND_CACHE_DIRS)) $(FIND_CACHE_DIRS),$1), \ |
53829
56dc0b27536c
8211016: make images does not update jdk/lib/src.zip with latest changes
erikj
parents:
53683
diff
changeset
|
398 |
$(if $(wildcard $1), $(shell $(FIND) $3 $(wildcard $1) \( -type f -o -type l \) $2 \ |
47334
09d386ddaa42
8189095: Import JMC from artifactory using Jib and main makefiles
erikj
parents:
47314
diff
changeset
|
399 |
| $(TR) ' ' '?')), \ |
44725
8747b14eb49c
8172312: Update docs target and image for new combined docs
ihse
parents:
44027
diff
changeset
|
400 |
$(filter $(addsuffix /%,$(patsubst %/,%,$1)) $1,$(FIND_CACHE))) |
23984 | 401 |
endef |
25854 | 402 |
|
23170
51e606ecede5
8037281: Improve CacheFind and enable on all platforms
erikj
parents:
23169
diff
changeset
|
403 |
else |
51e606ecede5
8037281: Improve CacheFind and enable on all platforms
erikj
parents:
23169
diff
changeset
|
404 |
# If CacheFind is disabled, just run the find command. |
23984 | 405 |
# Param 1 - Dirs to find in |
406 |
# Param 2 - (optional) specialization. Normally "-a \( ... \)" expression. |
|
23170
51e606ecede5
8037281: Improve CacheFind and enable on all platforms
erikj
parents:
23169
diff
changeset
|
407 |
define CacheFind |
47364 | 408 |
$(if $(wildcard $1, \ |
409 |
$(shell $(FIND) $(wildcard $1) \( -type f -o -type l \) $2 | $(TR) ' ' '?') \ |
|
410 |
) |
|
23170
51e606ecede5
8037281: Improve CacheFind and enable on all platforms
erikj
parents:
23169
diff
changeset
|
411 |
endef |
51e606ecede5
8037281: Improve CacheFind and enable on all platforms
erikj
parents:
23169
diff
changeset
|
412 |
endif |
15051
d32ad37472e6
8005540: build-infra: Improve incremental build speed on windows by caching find results
erikj
parents:
14279
diff
changeset
|
413 |
|
d32ad37472e6
8005540: build-infra: Improve incremental build speed on windows by caching find results
erikj
parents:
14279
diff
changeset
|
414 |
################################################################################ |
44027 | 415 |
# FixPath |
416 |
# |
|
417 |
# On Windows, converts a path from cygwin/unix style (e.g. /bin/foo) into |
|
418 |
# "mixed mode" (e.g. c:/cygwin/bin/foo). On other platforms, return the path |
|
419 |
# unchanged. |
|
420 |
# This is normally not needed since we use the FIXPATH prefix for command lines, |
|
421 |
# but might be needed in certain circumstances. |
|
53683 | 422 |
ifeq ($(call isTargetOs, windows), true) |
44027 | 423 |
FixPath = \ |
424 |
$(shell $(CYGPATH) -m $1) |
|
425 |
else |
|
426 |
FixPath = \ |
|
427 |
$1 |
|
428 |
endif |
|
429 |
||
430 |
################################################################################ |
|
28600
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
431 |
# DependOnVariable |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
432 |
# |
29156
bd932374081c
8072842: Add support for building native JTReg tests
ihse
parents:
28906
diff
changeset
|
433 |
# This macro takes a variable name and puts the value in a file only if the |
bd932374081c
8072842: Add support for building native JTReg tests
ihse
parents:
28906
diff
changeset
|
434 |
# value has changed since last. The name of the file is returned. This can be |
28600
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
435 |
# used to create rule dependencies on make variable values. The following |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
436 |
# example would get rebuilt if the value of SOME_VAR was changed: |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
437 |
# |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
438 |
# path/to/some-file: $(call DependOnVariable, SOME_VAR) |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
439 |
# echo $(SOME_VAR) > $@ |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
440 |
# |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
441 |
# Note that leading and trailing white space in the value is ignored. |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
442 |
# |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
443 |
|
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
444 |
# Defines the sub directory structure to store variable value file in |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
445 |
DependOnVariableDirName = \ |
36506 | 446 |
$(strip $(addsuffix $(if $(MODULE),/$(MODULE)), \ |
47217 | 447 |
$(subst $(TOPDIR)/,, $(if $(filter /%, $(firstword $(MAKEFILE_LIST))), \ |
28600
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
448 |
$(firstword $(MAKEFILE_LIST)), \ |
36506 | 449 |
$(CURDIR)/$(firstword $(MAKEFILE_LIST)))))) |
28600
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
450 |
|
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
451 |
# Defines the name of the file to store variable value in. Generates a name |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
452 |
# unless parameter 2 is given. |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
453 |
# Param 1 - Name of variable |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
454 |
# Param 2 - (optional) name of file to store value in |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
455 |
DependOnVariableFileName = \ |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
456 |
$(strip $(if $(strip $2), $2, \ |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
457 |
$(MAKESUPPORT_OUTPUTDIR)/vardeps/$(DependOnVariableDirName)/$(strip $1).vardeps)) |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
458 |
|
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
459 |
# Does the actual work with parameters stripped. |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
460 |
# If the file exists AND the contents is the same as the variable, do nothing |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
461 |
# else print a new file. |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
462 |
# Always returns the name of the file where the value was printed. |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
463 |
# Param 1 - Name of variable |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
464 |
# Param 2 - (optional) name of file to store value in |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
465 |
DependOnVariableHelper = \ |
32807
20386e6d858f
8136385: Various build speed improvements for windows
erikj
parents:
32553
diff
changeset
|
466 |
$(strip \ |
20386e6d858f
8136385: Various build speed improvements for windows
erikj
parents:
32553
diff
changeset
|
467 |
$(eval -include $(call DependOnVariableFileName, $1, $2)) \ |
20386e6d858f
8136385: Various build speed improvements for windows
erikj
parents:
32553
diff
changeset
|
468 |
$(if $(call equals, $(strip $($1)), $(strip $($1_old))),,\ |
20386e6d858f
8136385: Various build speed improvements for windows
erikj
parents:
32553
diff
changeset
|
469 |
$(call MakeDir, $(dir $(call DependOnVariableFileName, $1, $2))) \ |
20386e6d858f
8136385: Various build speed improvements for windows
erikj
parents:
32553
diff
changeset
|
470 |
$(if $(findstring $(LOG_LEVEL), trace), \ |
20386e6d858f
8136385: Various build speed improvements for windows
erikj
parents:
32553
diff
changeset
|
471 |
$(info NewVariable $1: >$(strip $($1))<) \ |
20386e6d858f
8136385: Various build speed improvements for windows
erikj
parents:
32553
diff
changeset
|
472 |
$(info OldVariable $1: >$(strip $($1_old))<)) \ |
42134
bbcdb49521b1
8169860: Clean up and unify the refactored Javadoc generation
ihse
parents:
41875
diff
changeset
|
473 |
$(call WriteFile, $1_old:=$(call DoubleDollar,$(call EscapeHash,$($1))), \ |
33054
bcb9f5ea5761
8140484: Vardeps broken when variable value contains '$'
erikj
parents:
32812
diff
changeset
|
474 |
$(call DependOnVariableFileName, $1, $2))) \ |
32807
20386e6d858f
8136385: Various build speed improvements for windows
erikj
parents:
32553
diff
changeset
|
475 |
$(call DependOnVariableFileName, $1, $2) \ |
20386e6d858f
8136385: Various build speed improvements for windows
erikj
parents:
32553
diff
changeset
|
476 |
) |
28600
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
477 |
|
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
478 |
# Main macro |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
479 |
# Param 1 - Name of variable |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
480 |
# Param 2 - (optional) name of file to store value in |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
481 |
DependOnVariable = \ |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
482 |
$(call DependOnVariableHelper,$(strip $1),$(strip $2)) |
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
483 |
|
35444 | 484 |
# LogCmdlines is only intended to be used by ExecuteWithLog |
485 |
ifeq ($(LOG_CMDLINES), true) |
|
486 |
LogCmdlines = $(info $(strip $1)) |
|
487 |
else |
|
488 |
LogCmdlines = |
|
489 |
endif |
|
490 |
||
28600
09dd1740f176
8069261: Create make dependencies on make variable values
erikj
parents:
27595
diff
changeset
|
491 |
################################################################################ |
35444 | 492 |
# ExecuteWithLog will run a command and log the output appropriately. This is |
493 |
# meant to be used by commands that do "real" work, like a compilation. |
|
494 |
# The output is stored in a specified log file, which is displayed at the end |
|
495 |
# of the build in case of failure. The command line itself is stored in a file, |
|
496 |
# and also logged to stdout if the LOG=cmdlines option has been given. |
|
32344
0b288e0efcfa
8062618: Create a build failure summary at end of build log
ihse
parents:
31312
diff
changeset
|
497 |
# |
39607
ace2c0283dce
8158629: bash >(...) construct still causes race conditions
erikj
parents:
39110
diff
changeset
|
498 |
# NOTE: If the command redirects stdout, the caller needs to wrap it in a |
ace2c0283dce
8158629: bash >(...) construct still causes race conditions
erikj
parents:
39110
diff
changeset
|
499 |
# subshell (by adding parentheses around it), otherwise the redirect to the |
ace2c0283dce
8158629: bash >(...) construct still causes race conditions
erikj
parents:
39110
diff
changeset
|
500 |
# subshell tee process will create a race condition where the target file may |
ace2c0283dce
8158629: bash >(...) construct still causes race conditions
erikj
parents:
39110
diff
changeset
|
501 |
# not be fully written when the make recipe is done. |
ace2c0283dce
8158629: bash >(...) construct still causes race conditions
erikj
parents:
39110
diff
changeset
|
502 |
# |
35444 | 503 |
# Param 1 - The path to base the name of the log file / command line file on |
504 |
# Param 2 - The command to run |
|
505 |
ExecuteWithLog = \ |
|
506 |
$(call LogCmdlines, Exececuting: [$(strip $2)]) \ |
|
48912 | 507 |
$(call MakeDir, $(dir $(strip $1))) \ |
35444 | 508 |
$(call WriteFile, $2, $(strip $1).cmdline) \ |
51069
d5d5f6658b12
8207001: *.obj.log files get truncated causing unreliable incremental builds on Windows
erikj
parents:
50590
diff
changeset
|
509 |
( $(RM) $(strip $1).log && $(strip $2) > >($(TEE) -a $(strip $1).log) 2> >($(TEE) -a $(strip $1).log >&2) || \ |
35444 | 510 |
( exitcode=$(DOLLAR)? && \ |
47253
92fd0e04e0e1
8187544: Replace BUILD_OUTPUT and OUTPUT_ROOT with OUTPUTDIR
ihse
parents:
47217
diff
changeset
|
511 |
$(CP) $(strip $1).log $(MAKESUPPORT_OUTPUTDIR)/failure-logs/$(subst /,_,$(patsubst $(OUTPUTDIR)/%,%,$(strip $1))).log && \ |
92fd0e04e0e1
8187544: Replace BUILD_OUTPUT and OUTPUT_ROOT with OUTPUTDIR
ihse
parents:
47217
diff
changeset
|
512 |
$(CP) $(strip $1).cmdline $(MAKESUPPORT_OUTPUTDIR)/failure-logs/$(subst /,_,$(patsubst $(OUTPUTDIR)/%,%,$(strip $1))).cmdline && \ |
39607
ace2c0283dce
8158629: bash >(...) construct still causes race conditions
erikj
parents:
39110
diff
changeset
|
513 |
exit $(DOLLAR)exitcode ) ) |
32344
0b288e0efcfa
8062618: Create a build failure summary at end of build log
ihse
parents:
31312
diff
changeset
|
514 |
|
0b288e0efcfa
8062618: Create a build failure summary at end of build log
ihse
parents:
31312
diff
changeset
|
515 |
################################################################################ |
25854 | 516 |
|
517 |
# Hook to include the corresponding custom file, if present. |
|
47314 | 518 |
$(eval $(call IncludeCustomExtension, common/MakeBase.gmk)) |
25854 | 519 |
|
12258
6ec26f6cc53e
7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff
changeset
|
520 |
endif # _MAKEBASE_GMK |