author | njian |
Thu, 15 Mar 2018 14:05:48 +0800 | |
changeset 49457 | fa30cdd2d3b8 |
parent 49070 | d7859531621b |
child 49137 | 50f5ea3292f1 |
permissions | -rw-r--r-- |
29156 | 1 |
# |
49070
d7859531621b
8198751: Refactor SetupNativeCompilation to take NAME and TYPE
ihse
parents:
41260
diff
changeset
|
2 |
# Copyright (c) 2015, 2018, 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 |
|
29312
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29305
diff
changeset
|
47 |
SetupTestFilesCompilation = $(NamedParamsMacroTemplate) |
f3f859137ce6
8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents:
29305
diff
changeset
|
48 |
define SetupTestFilesCompilationBody |
29156 | 49 |
|
50 |
# Check for duplicate base file names. That would have failed later anyhow, but |
|
51 |
# this gives a better error message. |
|
52 |
$1_DUPLICATED_NAMES := $$(call dups, $$(notdir $$($1_FILE_LIST))) |
|
53 |
ifneq ($$($1_DUPLICATED_NAMES), ) |
|
54 |
$$(error There are duplicate test file names for $1: $$($1_DUPLICATED_NAMES)) |
|
55 |
endif |
|
56 |
||
57 |
# The list to depend on starts out empty |
|
58 |
$1 := |
|
59 |
ifeq ($$($1_TYPE), LIBRARY) |
|
60 |
$1_PREFIX = lib |
|
61 |
$1_OUTPUT_SUBDIR := lib |
|
29305
4ddc6faf7842
8073021: add native code coverage target into makefiles
erikj
parents:
29156
diff
changeset
|
62 |
$1_CFLAGS := $(CFLAGS_TESTLIB) $(CFLAGS_WARNINGS_ARE_ERRORS) |
4ddc6faf7842
8073021: add native code coverage target into makefiles
erikj
parents:
29156
diff
changeset
|
63 |
$1_LDFLAGS := $(LDFLAGS_TESTLIB) $(call SET_SHARED_LIBRARY_ORIGIN) |
49070
d7859531621b
8198751: Refactor SetupNativeCompilation to take NAME and TYPE
ihse
parents:
41260
diff
changeset
|
64 |
$1_COMPILATION_TYPE := LIBRARY |
29156 | 65 |
else ifeq ($$($1_TYPE), PROGRAM) |
66 |
$1_PREFIX = exe |
|
67 |
$1_OUTPUT_SUBDIR := bin |
|
29305
4ddc6faf7842
8073021: add native code coverage target into makefiles
erikj
parents:
29156
diff
changeset
|
68 |
$1_CFLAGS := $(CFLAGS_TESTEXE) $(CFLAGS_WARNINGS_ARE_ERRORS) |
4ddc6faf7842
8073021: add native code coverage target into makefiles
erikj
parents:
29156
diff
changeset
|
69 |
$1_LDFLAGS := $(LDFLAGS_TESTEXE) |
49070
d7859531621b
8198751: Refactor SetupNativeCompilation to take NAME and TYPE
ihse
parents:
41260
diff
changeset
|
70 |
$1_COMPILATION_TYPE := EXECUTABLE |
29156 | 71 |
else |
72 |
$$(error Unknown type: $$($1_TYPE)) |
|
73 |
endif |
|
74 |
||
75 |
# Locate all files with the matching prefix |
|
76 |
$1_FILE_LIST := \ |
|
77 |
$$(shell $$(FIND) $$($1_SOURCE_DIRS) -type f -name "$$($1_PREFIX)*.c") |
|
78 |
||
79 |
# Setup a compilation for each and every one of them |
|
80 |
$$(foreach file, $$($1_FILE_LIST),\ |
|
81 |
$$(eval name := $$(strip $$(patsubst $$($1_PREFIX)%, %, $$(basename $$(notdir $$(file)))))) \ |
|
82 |
$$(eval $$(call SetupNativeCompilation, BUILD_TEST_$$(name), \ |
|
49070
d7859531621b
8198751: Refactor SetupNativeCompilation to take NAME and TYPE
ihse
parents:
41260
diff
changeset
|
83 |
NAME := $$(name), \ |
d7859531621b
8198751: Refactor SetupNativeCompilation to take NAME and TYPE
ihse
parents:
41260
diff
changeset
|
84 |
TYPE := $$($1_COMPILATION_TYPE), \ |
29156 | 85 |
SRC := $$(patsubst %/,%,$$(dir $$(file))), \ |
86 |
INCLUDE_FILES := $$(notdir $$(file)), \ |
|
87 |
OBJECT_DIR := $$($1_OUTPUT_DIR)/support/$$($1_PREFIX)$$(name), \ |
|
88 |
OUTPUT_DIR := $$($1_OUTPUT_DIR)/$$($1_OUTPUT_SUBDIR), \ |
|
89 |
LANG := C, \ |
|
31220
8a9b0fe3f23c
8081471: Allow SetupTestFilesCompilation to set LDFLAGS for individual tests
ihse
parents:
29312
diff
changeset
|
90 |
CFLAGS := $$($1_CFLAGS) $$($1_CFLAGS_$$($1_PREFIX)$$(name)), \ |
8a9b0fe3f23c
8081471: Allow SetupTestFilesCompilation to set LDFLAGS for individual tests
ihse
parents:
29312
diff
changeset
|
91 |
LDFLAGS := $$($1_LDFLAGS) $$($1_LDFLAGS_$$($1_PREFIX)$$(name)), \ |
40613
0140daccc66f
8164297: Jtreg test exeinvoke fails to link on Ubuntu
erikj
parents:
35032
diff
changeset
|
92 |
LIBS := $$($1_LIBS_$$($1_PREFIX)$$(name)), \ |
29156 | 93 |
OPTIMIZATION := LOW, \ |
41260 | 94 |
COPY_DEBUG_SYMBOLS := false, \ |
95 |
STRIP_SYMBOLS := false, \ |
|
35032 | 96 |
)) \ |
29156 | 97 |
$$(eval $1 += $$(BUILD_TEST_$$(name)) ) \ |
98 |
) |
|
99 |
||
100 |
endef |
|
101 |
||
102 |
endif # _TEST_FILES_COMPILATION_GMK |