author | ihse |
Tue, 05 Dec 2017 12:57:48 +0100 | |
branch | ihse-testmakefiles-branch |
changeset 55954 | 59d51a521c64 |
parent 55931 | 76a784951142 |
child 55967 | e2c47e2db0a5 |
permissions | -rw-r--r-- |
55881 | 1 |
# |
2 |
# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
|
3 |
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
# |
|
5 |
# This code is free software; you can redistribute it and/or modify it |
|
6 |
# under the terms of the GNU General Public License version 2 only, as |
|
7 |
# published by the Free Software Foundation. Oracle designates this |
|
8 |
# particular file as subject to the "Classpath" exception as provided |
|
9 |
# by Oracle in the LICENSE file that accompanied this code. |
|
10 |
# |
|
11 |
# This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
# version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
# accompanied this code). |
|
16 |
# |
|
17 |
# You should have received a copy of the GNU General Public License version |
|
18 |
# 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
# |
|
21 |
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
# or visit www.oracle.com if you need additional information or have any |
|
23 |
# questions. |
|
24 |
# |
|
25 |
||
55884 | 26 |
################################################################################ |
27 |
# Initial bootstrapping, copied and stripped down from Makefile and Init.gmk |
|
28 |
################################################################################ |
|
55881 | 29 |
|
30 |
# In Cygwin, the MAKE variable gets prepended with the current directory if the |
|
31 |
# make executable is called using a Windows mixed path (c:/cygwin/bin/make.exe). |
|
32 |
ifneq ($(findstring :, $(MAKE)), ) |
|
33 |
export MAKE := $(patsubst $(CURDIR)%, %, $(patsubst $(CURDIR)/%, %, $(MAKE))) |
|
34 |
endif |
|
35 |
||
36 |
# Locate this Makefile |
|
37 |
ifeq ($(filter /%, $(lastword $(MAKEFILE_LIST))),) |
|
38 |
makefile_path := $(CURDIR)/$(strip $(lastword $(MAKEFILE_LIST))) |
|
39 |
else |
|
40 |
makefile_path := $(lastword $(MAKEFILE_LIST)) |
|
41 |
endif |
|
55884 | 42 |
TOPDIR := $(strip $(patsubst %/make/, %, $(dir $(makefile_path)))) |
55881 | 43 |
|
44 |
################################################################################ |
|
55884 | 45 |
# Functions |
46 |
################################################################################ |
|
55881 | 47 |
|
55899 | 48 |
# Setup a required or optional variable, and/or check that it is properly |
49 |
# given. |
|
50 |
# Note: No spaces are allowed around the arguments. |
|
51 |
# |
|
52 |
# $1: The name of the argument |
|
53 |
# $2: The default value, if any, or OPTIONAL (do not provide a default but |
|
54 |
# do not exit if it is missing) |
|
55 |
# $3: If NO_CHECK, disable checking for target file/directory existence |
|
56 |
define SetupVariable |
|
55881 | 57 |
ifeq ($$($1), ) |
55884 | 58 |
ifeq ($2, ) |
55931 | 59 |
$$(info Error: Prebuilt variable $1 is missing, needed for run-tests-prebuilt) |
55884 | 60 |
$$(error Cannot continue.) |
55899 | 61 |
else ifeq ($2, OPTIONAL) |
55931 | 62 |
ifneq ($$(findstring $$(LOG), info debug trace), ) |
63 |
$$(info Prebuilt variable $1 is not provided) |
|
55899 | 64 |
endif |
55884 | 65 |
else |
55931 | 66 |
ifneq ($$(findstring $$(LOG), info debug trace), ) |
67 |
$$(info Prebuilt variable $1=$2 (default value)) |
|
68 |
endif |
|
55884 | 69 |
$1:=$2 |
70 |
endif |
|
55881 | 71 |
else |
55931 | 72 |
ifneq ($$(findstring $$(LOG), info debug trace), ) |
55889 | 73 |
$$(info Prebuilt variable $1=$$($1)) |
74 |
endif |
|
75 |
endif |
|
55899 | 76 |
# If $1 has a value (is not optional), and $3 is not set (to NO_CHECK), |
77 |
# and if wildcard is empty, then complain that the file is missing. |
|
78 |
ifeq ($$(strip $$(if $$($1), , OPTIONAL) $$(wildcard $$($1)) $3), ) |
|
55931 | 79 |
$$(info Error: Prebuilt variable $1 points to missing file/directory:) |
55899 | 80 |
$$(info '$$($1)') |
81 |
$$(error Cannot continue.) |
|
55881 | 82 |
endif |
83 |
endef |
|
84 |
||
55884 | 85 |
# Create an ephemeral spec file |
55899 | 86 |
# |
87 |
# $1: The output file name |
|
88 |
# $2..$N: The lines to output to the file |
|
55884 | 89 |
define CreateNewSpec |
55919
0ffb2cce1b19
Fix new exitcode code. Support more arguments in CreateNewSpec.
ihse
parents:
55914
diff
changeset
|
90 |
$(if $(strip $(26)), \ |
55884 | 91 |
$(error Internal makefile error: \ |
92 |
Too many arguments to macro, please update CreateNewSpec in RunTestsPrebuilt.gmk) \ |
|
93 |
) \ |
|
94 |
$(shell rm -f $1) \ |
|
55919
0ffb2cce1b19
Fix new exitcode code. Support more arguments in CreateNewSpec.
ihse
parents:
55914
diff
changeset
|
95 |
$(foreach i, 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25, \ |
55884 | 96 |
$(if $(strip $($i)), \ |
97 |
$(call AppendFile, $(strip $($i)), $1) \ |
|
98 |
) \ |
|
99 |
) |
|
100 |
endef |
|
101 |
||
102 |
################################################################################ |
|
55914 | 103 |
# Check input and setup basic buildsystem support |
55884 | 104 |
################################################################################ |
105 |
||
106 |
# Verify that user has given correct additional input. |
|
107 |
||
108 |
# These variables are absolutely necessary |
|
55899 | 109 |
$(eval $(call SetupVariable,OUTPUTDIR)) |
110 |
$(eval $(call SetupVariable,BOOT_JDK)) |
|
111 |
$(eval $(call SetupVariable,JT_HOME)) |
|
55884 | 112 |
|
113 |
# These can have default values based on the ones above |
|
55899 | 114 |
$(eval $(call SetupVariable,JDK_IMAGE_DIR,$(OUTPUTDIR)/images/jdk)) |
115 |
$(eval $(call SetupVariable,TEST_IMAGE_DIR,$(OUTPUTDIR)/images/test)) |
|
55881 | 116 |
|
55888 | 117 |
# Provide default values for tools that we need |
55899 | 118 |
$(eval $(call SetupVariable,MAKE,make,NO_CHECK)) |
119 |
$(eval $(call SetupVariable,BASH,bash,NO_CHECK)) |
|
55888 | 120 |
|
55889 | 121 |
# Check optional variables |
55899 | 122 |
$(eval $(call SetupVariable,JIB_JAR,OPTIONAL)) |
55889 | 123 |
|
55884 | 124 |
# Now that we have verified that we have the required variables available, we |
125 |
# can include the prebuilt spec file ourselves, without an ephemeral spec |
|
126 |
# wrapper. This is required so we can include MakeBase which is needed for |
|
127 |
# CreateNewSpec. |
|
55931 | 128 |
HAS_SPEC := |
129 |
include $(TOPDIR)/make/InitSupport.gmk |
|
130 |
||
131 |
$(eval $(call CheckDeprecatedEnvironment)) |
|
132 |
$(eval $(call CheckInvalidMakeFlags)) |
|
133 |
$(eval $(call ParseLogLevel)) |
|
134 |
||
55884 | 135 |
SPEC := $(TOPDIR)/make/RunTestsPrebuiltSpec.gmk |
136 |
include $(SPEC) |
|
137 |
include $(TOPDIR)/make/common/MakeBase.gmk |
|
138 |
||
55914 | 139 |
################################################################################ |
140 |
# Determine what platform we're running on |
|
141 |
################################################################################ |
|
142 |
UNAME := uname |
|
143 |
||
144 |
# Get OS name from uname (Cygwin inexplicably adds _NT-x.x) |
|
145 |
UNAME_OS := $(shell $(UNAME) -s | $(CUT) -f1 -d_) |
|
146 |
||
147 |
ifeq ($(UNAME_OS), CYGWIN) |
|
148 |
OPENJDK_TARGET_OS := windows |
|
149 |
OPENJDK_TARGET_OS_TYPE := windows |
|
150 |
OPENJDK_TARGET_OS_ENV := windows.cygwin |
|
151 |
else |
|
152 |
OPENJDK_TARGET_OS_TYPE:=unix |
|
153 |
ifeq ($(UNAME_OS), Linux) |
|
154 |
OPENJDK_TARGET_OS := linux |
|
155 |
else ifeq ($(UNAME_OS), Darwin) |
|
156 |
OPENJDK_TARGET_OS := macosx |
|
157 |
else ifeq ($(UNAME_OS), SunOS) |
|
158 |
OPENJDK_TARGET_OS := solaris |
|
159 |
else |
|
160 |
OPENJDK_TARGET_OS := $(UNAME_OS) |
|
161 |
endif |
|
162 |
OPENJDK_TARGET_OS_ENV := $(OPENJDK_TARGET_OS) |
|
163 |
endif |
|
164 |
||
165 |
# Assume little endian unless otherwise specified |
|
166 |
OPENJDK_TARGET_CPU_ENDIAN := little |
|
167 |
||
168 |
ifeq ($(OPENJDK_TARGET_OS), solaris) |
|
169 |
# On solaris, use uname -p |
|
170 |
UNAME_CPU := $(shell $(UNAME) -p) |
|
171 |
# Assume 64-bit platform |
|
172 |
OPENJDK_TARGET_CPU_BITS := 64 |
|
173 |
ifeq ($(UNAME_CPU), i386) |
|
174 |
OPENJDK_TARGET_CPU := x86_64 |
|
175 |
else ifeq ($(UNAME_CPU), sparc) |
|
176 |
OPENJDK_TARGET_CPU := sparcv9 |
|
177 |
OPENJDK_TARGET_CPU_ENDIAN := big |
|
178 |
else |
|
179 |
OPENJDK_TARGET_CPU := $(UNAME_CPU) |
|
180 |
endif |
|
181 |
else |
|
182 |
# ... all other user uname -m |
|
183 |
UNAME_CPU := $(shell $(UNAME) -m) |
|
184 |
ifeq ($(UNAME_CPU), i686) |
|
185 |
OPENJDK_TARGET_CPU := x86 |
|
186 |
OPENJDK_TARGET_CPU_BITS := 32 |
|
187 |
else |
|
188 |
# Assume all others are 64-bit. We use the same CPU name as uname for |
|
189 |
# at least x86_64 and aarch64. |
|
190 |
OPENJDK_TARGET_CPU := $(UNAME_CPU) |
|
191 |
OPENJDK_TARGET_CPU_BITS := 64 |
|
192 |
endif |
|
193 |
endif |
|
194 |
||
195 |
OPENJDK_TARGET_CPU_ARCH := $(OPENJDK_TARGET_CPU) |
|
196 |
ifeq ($(OPENJDK_TARGET_CPU), x86_64) |
|
197 |
OPENJDK_TARGET_CPU_ARCH := x86 |
|
198 |
else ifeq ($(OPENJDK_TARGET_CPU), sparcv9) |
|
199 |
OPENJDK_TARGET_CPU_ARCH := sparc |
|
200 |
endif |
|
201 |
||
202 |
ifeq ($(OPENJDK_TARGET_OS), windows) |
|
203 |
ifeq ($(wildcard $(TEST_IMAGE_DIR)/bin/fixpath.exe), ) |
|
204 |
$$(info Error: fixpath is missing from test image '$(TEST_IMAGE_DIR)') |
|
205 |
$$(error Cannot continue.) |
|
206 |
endif |
|
207 |
FIXPATH := $(TEST_IMAGE_DIR)/bin/fixpath.exe -c |
|
208 |
PATH_SEP:=; |
|
209 |
else |
|
210 |
FIXPATH := |
|
211 |
PATH_SEP:=: |
|
212 |
endif |
|
213 |
||
55954
59d51a521c64
Fix last FIXMEs in fake spec. Fix OPENJDK_BUILD_OS bug.
ihse
parents:
55931
diff
changeset
|
214 |
# Check number of cores |
59d51a521c64
Fix last FIXMEs in fake spec. Fix OPENJDK_BUILD_OS bug.
ihse
parents:
55931
diff
changeset
|
215 |
ifeq ($(OPENJDK_TARGET_OS), linux) |
59d51a521c64
Fix last FIXMEs in fake spec. Fix OPENJDK_BUILD_OS bug.
ihse
parents:
55931
diff
changeset
|
216 |
NUM_CORES := $(shell $(CAT) /proc/cpuinfo | $(GREP) -c processor) |
59d51a521c64
Fix last FIXMEs in fake spec. Fix OPENJDK_BUILD_OS bug.
ihse
parents:
55931
diff
changeset
|
217 |
else ifeq ($(OPENJDK_TARGET_OS), macosx) |
59d51a521c64
Fix last FIXMEs in fake spec. Fix OPENJDK_BUILD_OS bug.
ihse
parents:
55931
diff
changeset
|
218 |
NUM_CORES := $(shell /usr/sbin/sysctl -n hw.ncpu) |
59d51a521c64
Fix last FIXMEs in fake spec. Fix OPENJDK_BUILD_OS bug.
ihse
parents:
55931
diff
changeset
|
219 |
else ifeq ($(OPENJDK_TARGET_OS), solaris) |
59d51a521c64
Fix last FIXMEs in fake spec. Fix OPENJDK_BUILD_OS bug.
ihse
parents:
55931
diff
changeset
|
220 |
NUM_CORES := $(shell LC_MESSAGES=C /usr/sbin/psrinfo -v | $(GREP) -c on-line) |
59d51a521c64
Fix last FIXMEs in fake spec. Fix OPENJDK_BUILD_OS bug.
ihse
parents:
55931
diff
changeset
|
221 |
else ifeq ($(OPENJDK_TARGET_OS), windows) |
59d51a521c64
Fix last FIXMEs in fake spec. Fix OPENJDK_BUILD_OS bug.
ihse
parents:
55931
diff
changeset
|
222 |
NUM_CORES := $(NUMBER_OF_PROCESSORS) |
59d51a521c64
Fix last FIXMEs in fake spec. Fix OPENJDK_BUILD_OS bug.
ihse
parents:
55931
diff
changeset
|
223 |
else |
59d51a521c64
Fix last FIXMEs in fake spec. Fix OPENJDK_BUILD_OS bug.
ihse
parents:
55931
diff
changeset
|
224 |
NUM_CORES := 1 |
59d51a521c64
Fix last FIXMEs in fake spec. Fix OPENJDK_BUILD_OS bug.
ihse
parents:
55931
diff
changeset
|
225 |
endif |
59d51a521c64
Fix last FIXMEs in fake spec. Fix OPENJDK_BUILD_OS bug.
ihse
parents:
55931
diff
changeset
|
226 |
|
55914 | 227 |
################################################################################ |
228 |
# Generate the ephemeral spec file |
|
229 |
################################################################################ |
|
230 |
||
55884 | 231 |
# Now we can include additional custom support. |
232 |
# This might define CUSTOM_NEW_SPEC_LINE |
|
233 |
ifneq ($(CUSTOM_MAKE_DIR), ) |
|
234 |
include $(CUSTOM_MAKE_DIR)/RunTestsPrebuilt.gmk |
|
235 |
endif |
|
236 |
||
237 |
NEW_SPEC := $(OUTPUTDIR)/run-test-spec.gmk |
|
238 |
||
239 |
$(call CreateNewSpec, $(NEW_SPEC), \ |
|
55881 | 240 |
# Generated file -- do not edit!, \ |
241 |
SPEC := $(NEW_SPEC), \ |
|
55884 | 242 |
TOPDIR := $(TOPDIR), \ |
55882 | 243 |
OUTPUTDIR := $(OUTPUTDIR), \ |
55881 | 244 |
BOOT_JDK := $(BOOT_JDK), \ |
55888 | 245 |
JT_HOME := $(JT_HOME), \ |
55881 | 246 |
JDK_IMAGE_DIR := $(JDK_IMAGE_DIR), \ |
247 |
TEST_IMAGE_DIR := $(TEST_IMAGE_DIR), \ |
|
55888 | 248 |
MAKE := $(MAKE), \ |
249 |
BASH := $(BASH), \ |
|
55889 | 250 |
JIB_JAR := $(JIB_JAR), \ |
55914 | 251 |
FIXPATH := $(FIXPATH), \ |
252 |
PATH_SEP := $(PATH_SEP), \ |
|
253 |
OPENJDK_TARGET_OS := $(OPENJDK_TARGET_OS), \ |
|
254 |
OPENJDK_TARGET_OS_TYPE := $(OPENJDK_TARGET_OS_TYPE), \ |
|
255 |
OPENJDK_TARGET_OS_ENV := $(OPENJDK_TARGET_OS_ENV), \ |
|
256 |
OPENJDK_TARGET_CPU := $(OPENJDK_TARGET_CPU), \ |
|
257 |
OPENJDK_TARGET_CPU_ARCH := $(OPENJDK_TARGET_CPU_ARCH), \ |
|
258 |
OPENJDK_TARGET_CPU_BITS := $(OPENJDK_TARGET_CPU_BITS), \ |
|
259 |
OPENJDK_TARGET_CPU_ENDIAN := $(OPENJDK_TARGET_CPU_ENDIAN), \ |
|
55954
59d51a521c64
Fix last FIXMEs in fake spec. Fix OPENJDK_BUILD_OS bug.
ihse
parents:
55931
diff
changeset
|
260 |
NUM_CORES := $(NUM_CORES), \ |
55886
ff90766e3c60
Cleanup leftover custom stuff, include custom at the end.
ihse
parents:
55884
diff
changeset
|
261 |
include $(TOPDIR)/make/RunTestsPrebuiltSpec.gmk, \ |
55884 | 262 |
$(CUSTOM_NEW_SPEC_LINE), \ |
55881 | 263 |
) |
264 |
||
55884 | 265 |
################################################################################ |
266 |
# The run-test-prebuilt target |
|
55881 | 267 |
################################################################################ |
268 |
||
55931 | 269 |
SPEC := $(NEW_SPEC) |
270 |
||
55881 | 271 |
default: all |
272 |
||
55884 | 273 |
run-test-prebuilt: |
55881 | 274 |
@$(RM) -f $(MAKESUPPORT_OUTPUTDIR)/exit-with-error |
55931 | 275 |
@cd $(TOPDIR) && $(MAKE) $(MAKE_ARGS) -f make/RunTests.gmk run-test \ |
276 |
TEST="$(TEST)" |
|
55881 | 277 |
@if test -f $(MAKESUPPORT_OUTPUTDIR)/exit-with-error ; then \ |
278 |
exit 1 ; \ |
|
279 |
fi |
|
280 |
||
55884 | 281 |
all: run-test-prebuilt |
55881 | 282 |
|
283 |
.PHONY: default all |