author | zgu |
Fri, 15 Nov 2019 15:33:34 -0500 | |
changeset 59113 | 700a2ad8fc19 |
parent 58747 | c6fd655677ec |
permissions | -rw-r--r-- |
29156 | 1 |
# |
54380 | 2 |
# Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
29156 | 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 |
||
36 |
# Setup make rules for creating a set of native test files (libraries or |
|
37 |
# executables). This will locate native files matching a certain pattern, |
|
38 |
# and compile these into libraries or executables. |
|
39 |
# |
|
40 |
# Parameter 1 is the name of the rule. This name is used as variable prefix, |
|
41 |
# and the targets generated are listed in a variable by that name. |
|
42 |
# |
|
43 |
# Remaining parameters are named arguments. These include: |
|
44 |
# TYPE Must be either PROGRAM or LIBRARY. |
|
45 |
# SOURCE_DIRS A list of source directories to search |
|
46 |
# OUTPUT_DIR Where to put the resulting files |
|
49253
26f624b33218
8199681: Remove boilerplate code from creating native jtreg tests
ihse
parents:
49244
diff
changeset
|
47 |
# EXCLUDE A list of filenames to exclude from compilation |
29312
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29305
diff
changeset
|
48 |
SetupTestFilesCompilation = $(NamedParamsMacroTemplate) |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29305
diff
changeset
|
49 |
define SetupTestFilesCompilationBody |
29156 | 50 |
|
51 |
# Check for duplicate base file names. That would have failed later anyhow, but |
|
52 |
# this gives a better error message. |
|
53 |
$1_DUPLICATED_NAMES := $$(call dups, $$(notdir $$($1_FILE_LIST))) |
|
54 |
ifneq ($$($1_DUPLICATED_NAMES), ) |
|
55 |
$$(error There are duplicate test file names for $1: $$($1_DUPLICATED_NAMES)) |
|
56 |
endif |
|
57 |
||
58 |
# The list to depend on starts out empty |
|
59 |
$1 := |
|
60 |
ifeq ($$($1_TYPE), LIBRARY) |
|
61 |
$1_PREFIX = lib |
|
62 |
$1_OUTPUT_SUBDIR := lib |
|
51814 | 63 |
$1_BASE_CFLAGS := $(CFLAGS_JDKLIB) |
64 |
$1_BASE_CXXFLAGS := $(CXXFLAGS_JDKLIB) |
|
58275
2dedeaa537a2
8210794: Incorrect escaping of in native test libraries
erikj
parents:
54824
diff
changeset
|
65 |
$1_LDFLAGS := $(LDFLAGS_JDKLIB) $$(call SET_SHARED_LIBRARY_ORIGIN) |
49070
d7859531621b
8198751: Refactor SetupNativeCompilation to take NAME and TYPE
ihse
parents:
41260
diff
changeset
|
66 |
$1_COMPILATION_TYPE := LIBRARY |
29156 | 67 |
else ifeq ($$($1_TYPE), PROGRAM) |
68 |
$1_PREFIX = exe |
|
69 |
$1_OUTPUT_SUBDIR := bin |
|
51814 | 70 |
$1_BASE_CFLAGS := $(CFLAGS_JDKEXE) |
71 |
$1_BASE_CXXFLAGS := $(CXXFLAGS_JDKEXE) |
|
72 |
$1_LDFLAGS := $(LDFLAGS_JDKEXE) $(LDFLAGS_TESTEXE) |
|
49070
d7859531621b
8198751: Refactor SetupNativeCompilation to take NAME and TYPE
ihse
parents:
41260
diff
changeset
|
73 |
$1_COMPILATION_TYPE := EXECUTABLE |
29156 | 74 |
else |
75 |
$$(error Unknown type: $$($1_TYPE)) |
|
76 |
endif |
|
77 |
||
78 |
# Locate all files with the matching prefix |
|
79 |
$1_FILE_LIST := \ |
|
54380 | 80 |
$$(call FindFiles, $$($1_SOURCE_DIRS), $$($1_PREFIX)*.c $$($1_PREFIX)*.cpp) |
29156 | 81 |
|
49253
26f624b33218
8199681: Remove boilerplate code from creating native jtreg tests
ihse
parents:
49244
diff
changeset
|
82 |
$1_EXCLUDE_PATTERN := $$(addprefix %/, $$($1_EXCLUDE)) |
26f624b33218
8199681: Remove boilerplate code from creating native jtreg tests
ihse
parents:
49244
diff
changeset
|
83 |
$1_FILTERED_FILE_LIST := $$(filter-out $$($1_EXCLUDE_PATTERN), $$($1_FILE_LIST)) |
26f624b33218
8199681: Remove boilerplate code from creating native jtreg tests
ihse
parents:
49244
diff
changeset
|
84 |
|
29156 | 85 |
# Setup a compilation for each and every one of them |
49253
26f624b33218
8199681: Remove boilerplate code from creating native jtreg tests
ihse
parents:
49244
diff
changeset
|
86 |
$$(foreach file, $$($1_FILTERED_FILE_LIST),\ |
26f624b33218
8199681: Remove boilerplate code from creating native jtreg tests
ihse
parents:
49244
diff
changeset
|
87 |
$$(eval name := $$(strip $$(basename $$(notdir $$(file))))) \ |
26f624b33218
8199681: Remove boilerplate code from creating native jtreg tests
ihse
parents:
49244
diff
changeset
|
88 |
$$(eval unprefixed_name := $$(patsubst $$($1_PREFIX)%, %, $$(name))) \ |
29156 | 89 |
$$(eval $$(call SetupNativeCompilation, BUILD_TEST_$$(name), \ |
49253
26f624b33218
8199681: Remove boilerplate code from creating native jtreg tests
ihse
parents:
49244
diff
changeset
|
90 |
NAME := $$(unprefixed_name), \ |
49070
d7859531621b
8198751: Refactor SetupNativeCompilation to take NAME and TYPE
ihse
parents:
41260
diff
changeset
|
91 |
TYPE := $$($1_COMPILATION_TYPE), \ |
54076
4b4745d185eb
8220383: Incremental build is broken and inefficient
erikj
parents:
51853
diff
changeset
|
92 |
EXTRA_FILES := $$(file), \ |
49253
26f624b33218
8199681: Remove boilerplate code from creating native jtreg tests
ihse
parents:
49244
diff
changeset
|
93 |
OBJECT_DIR := $$($1_OUTPUT_DIR)/support/$$(name), \ |
29156 | 94 |
OUTPUT_DIR := $$($1_OUTPUT_DIR)/$$($1_OUTPUT_SUBDIR), \ |
51814 | 95 |
CFLAGS := $$($1_BASE_CFLAGS) $$($1_CFLAGS) $$($1_CFLAGS_$$(name)), \ |
96 |
CXXFLAGS := $$($1_BASE_CXXFLAGS) $$($1_CFLAGS) $$($1_CFLAGS_$$(name)), \ |
|
49253
26f624b33218
8199681: Remove boilerplate code from creating native jtreg tests
ihse
parents:
49244
diff
changeset
|
97 |
LDFLAGS := $$($1_LDFLAGS) $$($1_LDFLAGS_$$(name)), \ |
51853
ec62d6cab037
8211029: Have a common set of enabled warnings for all native libraries
ihse
parents:
51814
diff
changeset
|
98 |
DISABLED_WARNINGS_gcc := format undef unused-function unused-value, \ |
ec62d6cab037
8211029: Have a common set of enabled warnings for all native libraries
ihse
parents:
51814
diff
changeset
|
99 |
DISABLED_WARNINGS_clang := undef format-nonliteral \ |
ec62d6cab037
8211029: Have a common set of enabled warnings for all native libraries
ihse
parents:
51814
diff
changeset
|
100 |
missing-field-initializers sometimes-uninitialized, \ |
58747 | 101 |
DISABLED_WARNINGS_CXX_solstudio := wvarhidenmem doubunder, \ |
49253
26f624b33218
8199681: Remove boilerplate code from creating native jtreg tests
ihse
parents:
49244
diff
changeset
|
102 |
LIBS := $$($1_LIBS_$$(name)), \ |
51551 | 103 |
TOOLCHAIN := $(if $$(filter %.cpp, $$(file)), TOOLCHAIN_LINK_CXX, TOOLCHAIN_DEFAULT), \ |
51518
2e98c7737d8f
8208091: SA: jhsdb jstack --mixed throws UnmappedAddressException on i686
sgehwolf
parents:
49253
diff
changeset
|
104 |
OPTIMIZATION := $$(if $$($1_OPTIMIZATION_$$(name)),$$($1_OPTIMIZATION_$$(name)),LOW), \ |
41260 | 105 |
COPY_DEBUG_SYMBOLS := false, \ |
54824
adb3a3aa2e52
8214796: Create a jlink plugin for stripping debug info symbols from native libraries
sgehwolf
parents:
54380
diff
changeset
|
106 |
STRIP_SYMBOLS := $$(if $$($1_STRIP_SYMBOLS_$$(name)),$$($1_STRIP_SYMBOLS_$$(name)),false), \ |
35032 | 107 |
)) \ |
29156 | 108 |
$$(eval $1 += $$(BUILD_TEST_$$(name)) ) \ |
109 |
) |
|
110 |
||
111 |
endef |
|
112 |
||
113 |
endif # _TEST_FILES_COMPILATION_GMK |