1 # Copyright (C) 2009 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 # Build control file for Bionic's test programs 16 # define the BIONIC_TESTS environment variable to build the test programs 17 # 18 19 ifdef BIONIC_TESTS 20 21 LOCAL_PATH:= $(call my-dir) 22 23 # used to define a simple test program and build it as a standalone 24 # device executable. 25 # 26 # you can use EXTRA_CFLAGS to indicate additional CFLAGS to use 27 # in the build. the variable will be cleaned on exit 28 # 29 define device-test 30 $(foreach file,$(1), \ 31 $(eval include $(CLEAR_VARS)) \ 32 $(eval LOCAL_SRC_FILES := $(file)) \ 33 $(eval LOCAL_MODULE := $(notdir $(file:%.cpp=%))) \ 34 $(eval LOCAL_CFLAGS += $(EXTRA_CFLAGS)) \ 35 $(eval LOCAL_MODULE_TAGS := tests) \ 36 $(eval include $(BUILD_EXECUTABLE)) \ 37 ) \ 38 $(eval EXTRA_CFLAGS :=) 39 endef 40 41 # same as 'device-test' but builds a host executable instead 42 # you can use EXTRA_LDLIBS to indicate additional linker flags 43 # 44 define host-test 45 $(foreach file,$(1), \ 46 $(eval include $(CLEAR_VARS)) \ 47 $(eval LOCAL_SRC_FILES := $(file)) \ 48 $(eval LOCAL_MODULE := $(notdir $(file:%.cpp=%))) \ 49 $(eval LOCAL_CFLAGS += $(EXTRA_CFLAGS)) \ 50 $(eval LOCAL_LDLIBS += $(EXTRA_LDLIBS)) \ 51 $(eval LOCAL_MODULE_TAGS := tests) \ 52 $(eval include $(BUILD_HOST_EXECUTABLE)) \ 53 ) \ 54 $(eval EXTRA_CFLAGS :=) \ 55 $(eval EXTRA_LDLIBS :=) 56 endef 57 58 sources := \ 59 test_cassert.cpp \ 60 test_cctype.cpp \ 61 test_climits.cpp \ 62 test_cmath.cpp \ 63 test_csetjmp.cpp \ 64 test_csignal.cpp \ 65 test_cstddef.cpp \ 66 test_cstdio.cpp \ 67 test_cstdlib.cpp \ 68 test_cstring.cpp \ 69 test_ctime.cpp 70 71 $(call host-test, $(sources)) 72 73 EXTRA_CFLAGS := -DBIONIC=1 -I bionic/libstdc++/include 74 75 # <cstdint> is not part of the C++ standard yet, and some 76 # host environments don't provide it unless you use specific 77 # compiler flags, so only build this test for device/Bionic 78 # builds at the moment. 79 # 80 sources += test_cstdint.cpp 81 82 $(call device-test, $(sources)) 83 84 endif # BIONIC_TESTS 85