2
# Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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.
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
26
$(eval $(call IncludeCustomExtension, hotspot/lib/CompileGtest.gmk))
28
GTEST_TEST_SRC += $(TOPDIR)/test/hotspot/gtest
30
ifeq ($(ASAN_ENABLED), true)
31
GTEST_LAUNCHER_EXTRA_FILES += $(TOPDIR)/make/data/asan/asan_default_options.cpp
34
ifeq ($(LSAN_ENABLED), true)
35
GTEST_LAUNCHER_EXTRA_FILES += $(TOPDIR)/make/data/lsan/lsan_default_options.cpp
38
# On Windows, there are no internal debug symbols so must set copying to true
40
ifeq ($(call isTargetOs, windows), true)
41
GTEST_COPY_DEBUG_SYMBOLS := true
43
GTEST_COPY_DEBUG_SYMBOLS := false
46
################################################################################
48
################################################################################
50
$(eval $(call SetupJdkLibrary, BUILD_GTEST_LIBGTEST, \
52
TYPE := STATIC_LIBRARY, \
54
OUTPUT_DIR := $(JVM_OUTPUTDIR)/libgtest, \
55
OBJECT_DIR := $(JVM_OUTPUTDIR)/libgtest/objs, \
57
$(GTEST_FRAMEWORK_SRC)/googletest/src \
58
$(GTEST_FRAMEWORK_SRC)/googlemock/src, \
59
INCLUDE_FILES := gtest-all.cc gmock-all.cc, \
60
DISABLED_WARNINGS_gcc := undef unused-result format-nonliteral maybe-uninitialized, \
61
DISABLED_WARNINGS_clang := undef unused-result format-nonliteral, \
62
DEFAULT_CFLAGS := false, \
63
CFLAGS := $(JVM_CFLAGS) \
64
-I$(GTEST_FRAMEWORK_SRC)/googletest \
65
-I$(GTEST_FRAMEWORK_SRC)/googletest/include \
66
-I$(GTEST_FRAMEWORK_SRC)/googlemock \
67
-I$(GTEST_FRAMEWORK_SRC)/googlemock/include, \
68
CFLAGS_windows := -EHsc, \
69
CFLAGS_macosx := -DGTEST_OS_MAC=1, \
70
OPTIMIZATION := $(JVM_OPTIMIZATION), \
71
COPY_DEBUG_SYMBOLS := $(GTEST_COPY_DEBUG_SYMBOLS), \
72
ZIP_EXTERNAL_DEBUG_SYMBOLS := false, \
73
STRIP_SYMBOLS := false, \
76
TARGETS += $(BUILD_GTEST_LIBGTEST)
78
################################################################################
79
## Build libjvm (for gtest)
80
################################################################################
82
# Additional disabled warnings are due to code in the test source.
83
$(eval $(call SetupJdkLibrary, BUILD_GTEST_LIBJVM, \
86
OUTPUT_DIR := $(JVM_OUTPUTDIR)/gtest, \
87
OBJECT_DIR := $(JVM_OUTPUTDIR)/gtest/objs, \
88
SRC := $(GTEST_TEST_SRC), \
89
EXCLUDES := $(JVM_EXCLUDES), \
90
EXCLUDE_FILES := gtestLauncher.cpp, \
91
EXCLUDE_PATTERNS := $(JVM_EXCLUDE_PATTERNS), \
92
EXTRA_OBJECT_FILES := $(BUILD_LIBJVM_ALL_OBJS), \
93
DEFAULT_CFLAGS := false, \
94
CFLAGS := $(JVM_CFLAGS) \
95
-I$(GTEST_FRAMEWORK_SRC)/googletest/include \
96
-I$(GTEST_FRAMEWORK_SRC)/googlemock/include \
97
$(addprefix -I,$(GTEST_TEST_SRC)), \
98
CFLAGS_windows := -EHsc, \
99
CFLAGS_macosx := -DGTEST_OS_MAC=1, \
100
DISABLED_WARNINGS_gcc := $(DISABLED_WARNINGS_gcc) \
101
undef stringop-overflow, \
102
DISABLED_WARNINGS_gcc_test_threadCpuLoad.cpp := address, \
103
DISABLED_WARNINGS_clang := $(DISABLED_WARNINGS_clang) \
104
undef switch format-nonliteral tautological-undefined-compare \
105
self-assign-overloaded, \
106
DISABLED_WARNINGS_clang_test_g1ServiceThread.cpp := delete-abstract-non-virtual-dtor, \
107
DISABLED_WARNINGS_clang_test_logDecorations.cpp := missing-field-initializers, \
108
DISABLED_WARNINGS_microsoft := $(DISABLED_WARNINGS_microsoft), \
109
LD_SET_ORIGIN := false, \
110
DEFAULT_LDFLAGS := false, \
111
LDFLAGS := $(JVM_LDFLAGS), \
112
JDK_LIBS := gtest:libgtest, \
113
LIBS := $(JVM_LIBS), \
114
OPTIMIZATION := $(JVM_OPTIMIZATION), \
115
COPY_DEBUG_SYMBOLS := $(GTEST_COPY_DEBUG_SYMBOLS), \
116
ZIP_EXTERNAL_DEBUG_SYMBOLS := false, \
117
STRIP_SYMBOLS := false, \
118
PRECOMPILED_HEADER := $(JVM_PRECOMPILED_HEADER), \
119
PRECOMPILED_HEADER_EXCLUDE := gtestMain.cpp, \
122
$(BUILD_GTEST_LIBJVM) : $(BUILD_GTEST_LIBGTEST)
124
ifeq ($(call isTargetOs, windows), true)
125
$(BUILD_GTEST_LIBJVM_TARGET): $(WIN_EXPORT_FILE)
129
TARGETS += $(BUILD_GTEST_LIBJVM)
131
################################################################################
132
## Build gtestLauncher
133
################################################################################
135
$(eval $(call SetupJdkExecutable, BUILD_GTEST_LAUNCHER, \
136
NAME := gtestLauncher, \
137
TYPE := EXECUTABLE, \
139
OUTPUT_DIR := $(JVM_OUTPUTDIR)/gtest, \
140
SRC := $(TOPDIR)/test/hotspot/gtest, \
141
INCLUDE_FILES := gtestLauncher.cpp, \
142
EXTRA_FILES := $(GTEST_LAUNCHER_EXTRA_FILES), \
143
OBJECT_DIR := $(JVM_OUTPUTDIR)/gtest/launcher-objs, \
144
DEFAULT_CFLAGS := false, \
145
CFLAGS := $(JVM_CFLAGS) \
146
-I$(GTEST_FRAMEWORK_SRC)/googletest \
147
-I$(GTEST_FRAMEWORK_SRC)/googletest/include \
148
-I$(GTEST_FRAMEWORK_SRC)/googlemock \
149
-I$(GTEST_FRAMEWORK_SRC)/googlemock/include, \
150
LD_SET_ORIGIN := false, \
151
LDFLAGS_unix := $(call SET_SHARED_LIBRARY_ORIGIN), \
152
JDK_LIBS := gtest:libjvm, \
153
COPY_DEBUG_SYMBOLS := $(GTEST_COPY_DEBUG_SYMBOLS), \
154
ZIP_EXTERNAL_DEBUG_SYMBOLS := false, \
157
TARGETS += $(BUILD_GTEST_LAUNCHER)
159
################################################################################