Android.mk revision b4f7616fd618875768b8fffc122b58bdb84a9969
1# 2# Copyright (C) 2012 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 17ifneq ($(BUILD_TINY_ANDROID), true) 18 19LOCAL_PATH := $(call my-dir) 20 21# ----------------------------------------------------------------------------- 22# Benchmarks. 23# ----------------------------------------------------------------------------- 24 25benchmark_c_flags = \ 26 -O2 \ 27 -Wall -Wextra \ 28 -Werror \ 29 -fno-builtin \ 30 31benchmark_src_files = \ 32 benchmark_main.cpp \ 33 math_benchmark.cpp \ 34 property_benchmark.cpp \ 35 string_benchmark.cpp \ 36 time_benchmark.cpp \ 37 38# Build benchmarks for the device (with bionic's .so). Run with: 39# adb shell bionic-benchmarks 40include $(CLEAR_VARS) 41LOCAL_MODULE := bionic-benchmarks 42LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 43LOCAL_CFLAGS += $(benchmark_c_flags) 44LOCAL_C_INCLUDES += external/stlport/stlport bionic/ bionic/libstdc++/include 45LOCAL_SHARED_LIBRARIES += libstlport 46LOCAL_SRC_FILES := $(benchmark_src_files) 47include $(BUILD_EXECUTABLE) 48 49# ----------------------------------------------------------------------------- 50# Unit tests. 51# ----------------------------------------------------------------------------- 52 53test_c_flags = \ 54 -fstack-protector-all \ 55 -g \ 56 -Wall -Wextra \ 57 -Werror \ 58 -fno-builtin \ 59 60test_src_files = \ 61 dirent_test.cpp \ 62 eventfd_test.cpp \ 63 fenv_test.cpp \ 64 getauxval_test.cpp \ 65 getcwd_test.cpp \ 66 inttypes_test.cpp \ 67 libc_logging_test.cpp \ 68 libgen_test.cpp \ 69 malloc_test.cpp \ 70 math_test.cpp \ 71 netdb_test.cpp \ 72 pthread_test.cpp \ 73 regex_test.cpp \ 74 signal_test.cpp \ 75 stack_protector_test.cpp \ 76 stack_unwinding_test.cpp \ 77 statvfs_test.cpp \ 78 stdio_test.cpp \ 79 stdlib_test.cpp \ 80 string_test.cpp \ 81 strings_test.cpp \ 82 stubs_test.cpp \ 83 sys_sendfile_test.cpp \ 84 sys_stat_test.cpp \ 85 system_properties_test.cpp \ 86 time_test.cpp \ 87 unistd_test.cpp \ 88 89test_dynamic_ldflags = -Wl,--export-dynamic -Wl,-u,DlSymTestFunction 90test_dynamic_src_files = \ 91 dlfcn_test.cpp \ 92 93test_fortify_static_libraries = \ 94 fortify1-tests-gcc fortify2-tests-gcc fortify1-tests-clang fortify2-tests-clang 95 96include $(CLEAR_VARS) 97LOCAL_MODULE := bionic-unit-tests-unwind-test-impl 98LOCAL_CFLAGS += $(test_c_flags) -fexceptions -fnon-call-exceptions 99LOCAL_SRC_FILES := stack_unwinding_test_impl.c 100include $(BUILD_STATIC_LIBRARY) 101 102include $(CLEAR_VARS) 103LOCAL_MODULE := bionic-unit-tests-unwind-test-impl-host 104LOCAL_CFLAGS += $(test_c_flags) -fexceptions -fnon-call-exceptions 105LOCAL_SRC_FILES := stack_unwinding_test_impl.c 106include $(BUILD_HOST_STATIC_LIBRARY) 107 108# Build tests for the device (with bionic's .so). Run with: 109# adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests 110include $(CLEAR_VARS) 111LOCAL_MODULE := bionic-unit-tests 112LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 113LOCAL_CFLAGS += $(test_c_flags) 114LOCAL_LDFLAGS += $(test_dynamic_ldflags) 115LOCAL_SHARED_LIBRARIES += libdl 116LOCAL_SRC_FILES := $(test_src_files) $(test_dynamic_src_files) 117LOCAL_WHOLE_STATIC_LIBRARIES := $(test_fortify_static_libraries) 118LOCAL_STATIC_LIBRARIES += bionic-unit-tests-unwind-test-impl 119include $(BUILD_NATIVE_TEST) 120 121# Build tests for the device (with bionic's .a). Run with: 122# adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static 123include $(CLEAR_VARS) 124LOCAL_MODULE := bionic-unit-tests-static 125LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 126LOCAL_FORCE_STATIC_EXECUTABLE := true 127LOCAL_WHOLE_STATIC_LIBRARIES += libBionicTests 128LOCAL_STATIC_LIBRARIES += libstlport_static libstdc++ libm libc 129include $(BUILD_NATIVE_TEST) 130 131# ----------------------------------------------------------------------------- 132# We build the static unit tests as a library so they can be used both for 133# bionic-unit-tests-static and also as part of CTS. 134# ----------------------------------------------------------------------------- 135 136include $(CLEAR_VARS) 137LOCAL_MODULE := libBionicTests 138LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 139LOCAL_CFLAGS += $(test_c_flags) 140LOCAL_SRC_FILES := $(test_src_files) 141LOCAL_CFLAGS += \ 142 -DGTEST_OS_LINUX_ANDROID \ 143 -DGTEST_HAS_STD_STRING \ 144 145LOCAL_C_INCLUDES += \ 146 bionic bionic/libstdc++/include \ 147 external/gtest/include \ 148 external/stlport/stlport \ 149 150LOCAL_WHOLE_STATIC_LIBRARIES := \ 151 $(test_fortify_static_libraries) \ 152 bionic-unit-tests-unwind-test-impl \ 153 154include $(BUILD_STATIC_LIBRARY) 155 156# ----------------------------------------------------------------------------- 157# Test library for the unit tests. 158# ----------------------------------------------------------------------------- 159 160# Build no-elf-hash-table-library.so to test dlopen(3) on a library that 161# only has a GNU-style hash table. MIPS doesn't support GNU hash style. 162ifneq ($(TARGET_ARCH),mips) 163include $(CLEAR_VARS) 164LOCAL_MODULE := no-elf-hash-table-library 165LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 166LOCAL_SRC_FILES := empty.cpp 167LOCAL_LDFLAGS := -Wl,--hash-style=gnu 168include $(BUILD_SHARED_LIBRARY) 169endif 170 171# ----------------------------------------------------------------------------- 172# Unit tests built against glibc. 173# ----------------------------------------------------------------------------- 174 175# Build tests for the host (with glibc). 176# Note that this will build against glibc, so it's not useful for testing 177# bionic's implementation, but it does let you use glibc as a reference 178# implementation for testing the tests themselves. 179ifeq ($(HOST_OS)-$(HOST_ARCH),linux-x86) 180include $(CLEAR_VARS) 181LOCAL_MODULE := bionic-unit-tests-glibc 182LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 183LOCAL_CFLAGS += $(test_c_flags) 184LOCAL_LDFLAGS += -lpthread -ldl -lrt 185LOCAL_LDFLAGS += $(test_dynamic_ldflags) 186LOCAL_SRC_FILES := $(test_src_files) $(test_dynamic_src_files) 187LOCAL_STATIC_LIBRARIES += bionic-unit-tests-unwind-test-impl-host 188include $(BUILD_HOST_NATIVE_TEST) 189endif 190 191# ----------------------------------------------------------------------------- 192# Run the unit tests built against x86 bionic on an x86 host. 193# ----------------------------------------------------------------------------- 194 195ifeq ($(HOST_OS)-$(HOST_ARCH),linux-x86) 196ifeq ($(TARGET_ARCH),x86) 197# gtest needs EXTERNAL_STORAGE for death test output. 198# bionic itself should always work relative to ANDROID_DATA or ANDROID_ROOT. 199# We create /data/local/tmp to be as much like the regular target environment 200# as possible. 201bionic-unit-tests-run-on-host: bionic-unit-tests $(TARGET_OUT_EXECUTABLES)/linker 202 mkdir -p $(TARGET_OUT_DATA)/local/tmp 203 cp $(TARGET_OUT_EXECUTABLES)/linker /system/bin 204 cp $(TARGET_OUT_EXECUTABLES)/sh /system/bin 205 ANDROID_DATA=$(TARGET_OUT_DATA) \ 206 ANDROID_ROOT=$(TARGET_OUT) \ 207 EXTERNAL_STORAGE=$(TARGET_OUT_DATA)/local/tmp \ 208 LD_LIBRARY_PATH=$(TARGET_OUT_SHARED_LIBRARIES) \ 209 $(TARGET_OUT_DATA_NATIVE_TESTS)/bionic-unit-tests/bionic-unit-tests 210endif 211endif 212 213# ----------------------------------------------------------------------------- 214# FORTIFY_SOURCE tests 215# ----------------------------------------------------------------------------- 216 217fortify_c_includes = \ 218 bionic \ 219 bionic/libstdc++/include \ 220 external/stlport/stlport \ 221 external/gtest/include 222fortify_test_files = fortify_test.cpp 223 224# -Wno-error=unused-parameter needed as 225# external/stlport/stlport/stl/_threads.c (included from 226# external/gtest/include/gtest/gtest.h) does not compile cleanly under 227# clang. TODO: fix this. 228fortify_c_flags = $(test_c_flags) -Wno-error=unused-parameter 229 230include $(CLEAR_VARS) 231LOCAL_SRC_FILES := $(fortify_test_files) 232LOCAL_MODULE := fortify1-tests-gcc 233LOCAL_CFLAGS += $(fortify_c_flags) -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DTEST_NAME=Fortify1_Gcc 234LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 235LOCAL_C_INCLUDES += $(fortify_c_includes) 236include $(BUILD_STATIC_LIBRARY) 237 238include $(CLEAR_VARS) 239LOCAL_SRC_FILES := $(fortify_test_files) 240LOCAL_MODULE := fortify2-tests-gcc 241LOCAL_CFLAGS += $(fortify_c_flags) -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -DTEST_NAME=Fortify2_Gcc 242LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 243LOCAL_C_INCLUDES += $(fortify_c_includes) 244include $(BUILD_STATIC_LIBRARY) 245 246include $(CLEAR_VARS) 247LOCAL_SRC_FILES := $(fortify_test_files) 248LOCAL_MODULE := fortify1-tests-clang 249LOCAL_CLANG := true 250LOCAL_CFLAGS += $(fortify_c_flags) -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DTEST_NAME=Fortify1_Clang 251LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 252LOCAL_C_INCLUDES += $(fortify_c_includes) 253include $(BUILD_STATIC_LIBRARY) 254 255include $(CLEAR_VARS) 256LOCAL_SRC_FILES := $(fortify_test_files) 257LOCAL_MODULE := fortify2-tests-clang 258LOCAL_CLANG := true 259LOCAL_CFLAGS += $(fortify_c_flags) -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -DTEST_NAME=Fortify2_Clang 260LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 261LOCAL_C_INCLUDES += $(fortify_c_includes) 262include $(BUILD_STATIC_LIBRARY) 263 264endif # !BUILD_TINY_ANDROID 265