29156
|
1 |
#
|
|
2 |
# Copyright (c) 2015, 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 |
|
|
26 |
ifndef _TEST_FILES_COMPILATION_GMK
|
|
27 |
_TEST_FILES_COMPILATION_GMK := 1
|
|
28 |
|
|
29 |
ifeq (,$(_MAKEBASE_GMK))
|
|
30 |
$(error You must include MakeBase.gmk prior to including TestFilesCompilation.gmk)
|
|
31 |
endif
|
|
32 |
|
|
33 |
|
|
34 |
include NativeCompilation.gmk
|
|
35 |
# FIXME: This is a bad fix currently needed due to JDK-8064808 not being resolved.
|
|
36 |
include $(JDK_TOPDIR)/make/Tools.gmk
|
|
37 |
|
|
38 |
# Setup make rules for creating a set of native test files (libraries or
|
|
39 |
# executables). This will locate native files matching a certain pattern,
|
|
40 |
# and compile these into libraries or executables.
|
|
41 |
#
|
|
42 |
# Parameter 1 is the name of the rule. This name is used as variable prefix,
|
|
43 |
# and the targets generated are listed in a variable by that name.
|
|
44 |
#
|
|
45 |
# Remaining parameters are named arguments. These include:
|
|
46 |
# TYPE Must be either PROGRAM or LIBRARY.
|
|
47 |
# SOURCE_DIRS A list of source directories to search
|
|
48 |
# OUTPUT_DIR Where to put the resulting files
|
|
49 |
define SetupTestFilesCompilation
|
|
50 |
$(if $(27),$(error Internal makefile error: Too many arguments to SetupTestFilesCompilation, please update BuildJTRegNative.gmk))
|
|
51 |
$(call EvalDebugWrapper,$(strip $1),$(call SetupTestFilesCompilationInner,$(strip $1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15),$(16),$(17),$(18),$(19),$(20),$(21),$(22),$(23),$(24),$(25),$(26)))
|
|
52 |
endef
|
|
53 |
|
|
54 |
define SetupTestFilesCompilationInner
|
|
55 |
$(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 26, $(if $(strip $($i)),$1_$(strip $($i)))$(NEWLINE))
|
|
56 |
$(call LogSetupMacroEntry,SetupTestFileCompilation($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15),$(16),$(17),$(18),$(19),$(20),$(21),$(22),$(23),$(24),$(25),$(26))
|
|
57 |
$(if $(27),$(error Internal makefile error: Too many arguments to SetupTestFilesCompilation, please update BuildJTRegNative.gmk))
|
|
58 |
|
|
59 |
# Check for duplicate base file names. That would have failed later anyhow, but
|
|
60 |
# this gives a better error message.
|
|
61 |
$1_DUPLICATED_NAMES := $$(call dups, $$(notdir $$($1_FILE_LIST)))
|
|
62 |
ifneq ($$($1_DUPLICATED_NAMES), )
|
|
63 |
$$(error There are duplicate test file names for $1: $$($1_DUPLICATED_NAMES))
|
|
64 |
endif
|
|
65 |
|
|
66 |
# The list to depend on starts out empty
|
|
67 |
$1 :=
|
|
68 |
ifeq ($$($1_TYPE), LIBRARY)
|
|
69 |
$1_PREFIX = lib
|
|
70 |
$1_OUTPUT_SUBDIR := lib
|
|
71 |
$1_CFLAGS := $(CFLAGS_JDKLIB) $(CFLAGS_WARNINGS_ARE_ERRORS)
|
|
72 |
$1_LDFLAGS := $(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN)
|
|
73 |
else ifeq ($$($1_TYPE), PROGRAM)
|
|
74 |
$1_PREFIX = exe
|
|
75 |
$1_OUTPUT_SUBDIR := bin
|
|
76 |
$1_CFLAGS := $(CFLAGS_JDKEXE) $(CFLAGS_WARNINGS_ARE_ERRORS)
|
|
77 |
$1_LDFLAGS := $(LDFLAGS_JDKEXE)
|
|
78 |
else
|
|
79 |
$$(error Unknown type: $$($1_TYPE))
|
|
80 |
endif
|
|
81 |
|
|
82 |
# Locate all files with the matching prefix
|
|
83 |
$1_FILE_LIST := \
|
|
84 |
$$(shell $$(FIND) $$($1_SOURCE_DIRS) -type f -name "$$($1_PREFIX)*.c")
|
|
85 |
|
|
86 |
# Setup a compilation for each and every one of them
|
|
87 |
$$(foreach file, $$($1_FILE_LIST),\
|
|
88 |
$$(eval name := $$(strip $$(patsubst $$($1_PREFIX)%, %, $$(basename $$(notdir $$(file)))))) \
|
|
89 |
$$(eval $$(call SetupNativeCompilation, BUILD_TEST_$$(name), \
|
|
90 |
$$($1_TYPE) := $$(name), \
|
|
91 |
SRC := $$(patsubst %/,%,$$(dir $$(file))), \
|
|
92 |
INCLUDE_FILES := $$(notdir $$(file)), \
|
|
93 |
OBJECT_DIR := $$($1_OUTPUT_DIR)/support/$$($1_PREFIX)$$(name), \
|
|
94 |
OUTPUT_DIR := $$($1_OUTPUT_DIR)/$$($1_OUTPUT_SUBDIR), \
|
|
95 |
LANG := C, \
|
|
96 |
CFLAGS := $$($1_CFLAGS), \
|
|
97 |
LDFLAGS := $$($1_LDFLAGS), \
|
|
98 |
OPTIMIZATION := LOW, \
|
|
99 |
DEBUG_SYMBOLS := true)) \
|
|
100 |
$$(eval $1 += $$(BUILD_TEST_$$(name)) ) \
|
|
101 |
)
|
|
102 |
|
|
103 |
endef
|
|
104 |
|
|
105 |
endif # _TEST_FILES_COMPILATION_GMK
|