Android.mk revision 7e5a367b7f5523654e25df92b4a353dc6679ba4b
1# Copyright (C) 2015 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# 15# 16 17# Test for gmock. Run using 'runtest'. 18# The linux build and tests are run under valgrind by 'runtest'. 19 20LOCAL_PATH := $(call my-dir) 21include $(CLEAR_VARS) 22 23# TODO: Refactor these as 1st class build templates as suggested in 24# review of the original import. 25 26libgmock_test_common_includes := \ 27 $(LOCAL_PATH)/../include \ 28 $(LOCAL_PATH)/.. \ 29 $(TOP)/external/gtest/include \ 30 31libgmock_test_includes := $(libgmock_test_common_includes) 32libgmock_test_static_lib := libgmock_main libgmock libgtest libgtest_main 33libgmock_test_ldflags := 34 35libgmock_test_host_includes := $(libgmock_test_common_includes) 36libgmock_test_host_static_lib := libgmock_main_host libgmock_host libgtest_host libgtest_main_host 37libgmock_test_host_ldflags := -lpthread 38 39# $(2) and $(4) must be set or cleared in sync. $(2) is used to 40# generate the right make target (host vs device). $(4) is used in the 41# module's name and to have different module names for the host vs 42# device builds. Finally $(4) is used to pick up the right set of 43# libraries, typically the host libs have a _host suffix in their 44# names. 45# $(1): source list 46# $(2): "HOST_" or empty 47# $(3): extra CFLAGS or empty 48# $(4): "_host" or empty 49# $(5): "TARGET_OUT_DATA_NATIVE_TESTS" or empty (where to install) 50define _define-test 51$(foreach file,$(1), \ 52 $(eval include $(CLEAR_VARS)) \ 53 $(eval LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk) \ 54 $(eval LOCAL_CPP_EXTENSION := .cc) \ 55 $(eval LOCAL_SRC_FILES := $(file)) \ 56 $(eval LOCAL_C_INCLUDES := $(libgmock_test$(4)_includes)) \ 57 $(eval LOCAL_MODULE := $(notdir $(file:%.cc=%))$(4)) \ 58 $(eval LOCAL_CFLAGS += $(3) -Wno-empty-body) \ 59 $(eval LOCAL_LDFLAGS += $(libgmock_test$(4)_ldflags)) \ 60 $(eval LOCAL_STATIC_LIBRARIES := $(libgmock_test$(4)_static_lib)) \ 61 $(eval LOCAL_SHARED_LIBRARIES := $(libgmock_test$(4)_shared_lib)) \ 62 $(if $(2),,$(eval LOCAL_MODULE_TAGS := tests)) \ 63 $(eval LOCAL_MODULE_PATH := $($(5))) \ 64 $(eval include $(BUILD_$(2)EXECUTABLE)) \ 65) 66endef 67 68define host-test 69$(call _define-test,$(1),HOST_,-O0,_host,) 70endef 71 72define target-test 73$(call _define-test,$(1),,,,TARGET_OUT_DATA_NATIVE_TESTS) 74endef 75 76sources := \ 77 gmock_test.cc \ 78 gmock-spec-builders_test.cc \ 79 gmock_link_test.cc \ 80 81# The remaining tests aren't executed by the configure/make/make check sequence. 82 83$(call host-test, $(sources)) 84$(call target-test, $(sources)) 85