19060e8cc1fceca1161225b7d3ddb62f9359b9e8
[platform/core/ml/nntrainer.git] / test / jni / googletest / Android.mk
1 #
2 # Copyright (C) 2016 The Android Open Source Project
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16
17 # Note that the platform modules are defined in the Android.bp. This file is
18 # used for the NDK.
19
20 # If we're being invoked from ndk-build, we'll have NDK_ROOT defined.
21 ifdef NDK_ROOT
22
23 LOCAL_PATH := $(call my-dir)
24
25 # Defines a test module.
26 #
27 # The upstream gtest configuration builds each of these as separate executables.
28 # It's a pain for how we run tests in the platform, but we can handle that with
29 # a test running script.
30 #
31 # $(1): Test name. test/$(1).cc will automatically be added to sources.
32 # $(2): Additional source files.
33 # $(3): "libgtest_main" or empty.
34 #
35 # Use -Wno-unnamed-type-template-args because gtest_unittest.cc wants anonymous enum type.
36 define gtest-unit-test
37     $(eval include $(CLEAR_VARS)) \
38     $(eval LOCAL_MODULE := $(1)) \
39     $(eval LOCAL_CPP_EXTENSION := .cc) \
40     $(eval LOCAL_SRC_FILES := test/$(strip $(1)).cc $(2)) \
41     $(eval LOCAL_C_INCLUDES := $(LOCAL_PATH)/include) \
42     $(eval LOCAL_CPP_FEATURES := rtti) \
43     $(eval LOCAL_CFLAGS := -Wall -Werror -Wno-sign-compare -Wno-unnamed-type-template-args) \
44     $(eval LOCAL_CFLAGS += -Wno-unused-private-field) \
45     $(eval LOCAL_STATIC_LIBRARIES := $(3) libgtest) \
46     $(eval include $(BUILD_EXECUTABLE))
47 endef
48
49 # Create modules for each test in the suite.
50 #
51 # The NDK variant of gtest-death-test_test is disabled because we don't have
52 # pthread_atfork on android-9.
53 define gtest-test-suite
54     $(eval $(call gtest-unit-test,googletest-death-test-test,,libgtest_main)) \
55     $(eval $(call gtest-unit-test,googletest-filepath-test,,libgtest_main)) \
56     $(eval $(call gtest-unit-test,googletest-listener-test,,libgtest_main)) \
57     $(eval $(call gtest-unit-test,googletest-message-test,,libgtest_main)) \
58     $(eval $(call gtest-unit-test,googletest-options-test,,libgtest_main)) \
59     $(eval $(call gtest-unit-test,googletest-param-test-test, \
60         test/googletest-param-test2-test.cc,)) \
61     $(eval $(call gtest-unit-test,googletest-port-test,,libgtest_main)) \
62     $(eval $(call gtest-unit-test,googletest-printers-test,,libgtest_main)) \
63     $(eval $(call gtest-unit-test,googletest-test-part-test,,libgtest_main)) \
64     $(eval $(call gtest-unit-test, \
65         gtest-typed-test_test,test/gtest-typed-test2_test.cc, \
66             libgtest_main)) \
67     $(eval $(call gtest-unit-test,gtest-unittest-api_test,,)) \
68     $(eval $(call gtest-unit-test,gtest_environment_test,,)) \
69     $(eval $(call gtest-unit-test,gtest_main_unittest,,libgtest_main)) \
70     $(eval $(call gtest-unit-test,gtest_no_test_unittest,,)) \
71     $(eval $(call gtest-unit-test,gtest_pred_impl_unittest,,libgtest_main)) \
72     $(eval $(call gtest-unit-test,gtest_premature_exit_test,,)) \
73     $(eval $(call gtest-unit-test,gtest_prod_test,test/production.cc, \
74             libgtest_main)) \
75     $(eval $(call gtest-unit-test,gtest_repeat_test,,)) \
76     $(eval $(call gtest-unit-test,gtest_skip_test,,libgtest_main)) \
77     $(eval $(call gtest-unit-test,gtest_sole_header_test,,libgtest_main)) \
78     $(eval $(call gtest-unit-test,gtest_stress_test,,)) \
79     $(eval $(call gtest-unit-test,gtest_unittest,,libgtest_main))
80 endef
81
82 # Test is disabled because Android doesn't build gtest with exceptions.
83 # $(eval $(call gtest-unit-test,gtest_throw_on_failure_ex_test,,))
84 # $(eval $(call gtest-unit-test,gtest_assert_by_exception_test,,))
85
86 include $(CLEAR_VARS)
87 LOCAL_MODULE := libgtest
88 LOCAL_LICENSE_KINDS := SPDX-license-identifier-BSD
89 LOCAL_LICENSE_CONDITIONS := notice
90 LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../LICENSE
91 LOCAL_SRC_FILES := src/gtest-all.cc
92 LOCAL_C_INCLUDES := $(LOCAL_PATH)/src $(LOCAL_PATH)/include
93 LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
94 LOCAL_CPP_FEATURES := rtti
95 include $(BUILD_STATIC_LIBRARY)
96
97 # Note: Unlike the platform, libgtest_main carries a dependency on libgtest.
98 # Users don't need to manually depend on both.
99 include $(CLEAR_VARS)
100 LOCAL_MODULE := libgtest_main
101 LOCAL_LICENSE_KINDS := SPDX-license-identifier-BSD
102 LOCAL_LICENSE_CONDITIONS := notice
103 LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../LICENSE
104 LOCAL_SRC_FILES := src/gtest_main.cc
105 LOCAL_C_INCLUDES := $(LOCAL_PATH)/src $(LOCAL_PATH)/include
106 LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
107 LOCAL_CPP_FEATURES := rtti
108 LOCAL_STATIC_LIBRARIES := libgtest
109 include $(BUILD_STATIC_LIBRARY)
110
111 # These are the old names of these libraries. They don't match the platform or
112 # the upstream build, but we've been requiring that people put them in their NDK
113 # makefiles for years.
114
115 include $(CLEAR_VARS)
116 LOCAL_MODULE := googletest_static
117 LOCAL_LICENSE_KINDS := SPDX-license-identifier-BSD
118 LOCAL_LICENSE_CONDITIONS := notice
119 LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../LICENSE
120 LOCAL_SRC_FILES := src/gtest-all.cc
121 LOCAL_C_INCLUDES := $(LOCAL_PATH)/src $(LOCAL_PATH)/include
122 LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
123 LOCAL_CPP_FEATURES := rtti
124 include $(BUILD_STATIC_LIBRARY)
125
126 include $(CLEAR_VARS)
127 LOCAL_MODULE := libgoogletest_main
128 LOCAL_LICENSE_KINDS := SPDX-license-identifier-BSD
129 LOCAL_LICENSE_CONDITIONS := notice
130 LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../LICENSE
131 LOCAL_CPP_EXTENSION := .cc
132 LOCAL_SRC_FILES := src/gtest_main.cc
133 LOCAL_C_INCLUDES := $(LOCAL_PATH)/src $(LOCAL_PATH)/include
134 LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
135 LOCAL_CPP_FEATURES := rtti
136 LOCAL_STATIC_LIBRARIES := libgtest
137 include $(BUILD_STATIC_LIBRARY)
138
139 # The NDK used to include shared versions of these libraries, for some reason.
140
141 include $(CLEAR_VARS)
142 LOCAL_MODULE := googletest_shared
143 LOCAL_LICENSE_KINDS := SPDX-license-identifier-BSD
144 LOCAL_LICENSE_CONDITIONS := notice
145 LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../LICENSE
146 LOCAL_SRC_FILES := src/gtest-all.cc
147 LOCAL_C_INCLUDES := $(LOCAL_PATH)/src $(LOCAL_PATH)/include
148 LOCAL_CFLAGS := -DGTEST_CREATE_SHARED_LIBRARY
149 LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
150 LOCAL_CPP_FEATURES := rtti
151 include $(BUILD_SHARED_LIBRARY)
152
153 include $(CLEAR_VARS)
154 LOCAL_MODULE := googletest_main_shared
155 LOCAL_LICENSE_KINDS := SPDX-license-identifier-BSD
156 LOCAL_LICENSE_CONDITIONS := notice
157 LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../LICENSE
158 LOCAL_SRC_FILES := src/gtest_main.cc
159 LOCAL_C_INCLUDES := $(LOCAL_PATH)/src $(LOCAL_PATH)/include
160 LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
161 LOCAL_CPP_FEATURES := rtti
162 LOCAL_SHARED_LIBRARIES := googletest_shared
163 include $(BUILD_STATIC_LIBRARY)
164
165 # Tests for use in the NDK itself.
166 $(call gtest-test-suite)
167
168 endif