Android.mk revision f4af911065b1b392085b857b891e5496bc75f478
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_stat_test.cpp \ 84 system_properties_test.cpp \ 85 time_test.cpp \ 86 unistd_test.cpp \ 87 88test_dynamic_ldflags = -Wl,--export-dynamic -Wl,-u,DlSymTestFunction 89test_dynamic_src_files = \ 90 dlfcn_test.cpp \ 91 92test_fortify_static_libraries = \ 93 fortify1-tests-gcc fortify2-tests-gcc fortify1-tests-clang fortify2-tests-clang 94 95include $(CLEAR_VARS) 96LOCAL_MODULE := bionic-unit-tests-unwind-test-impl 97LOCAL_CFLAGS += $(test_c_flags) -fexceptions -fnon-call-exceptions 98LOCAL_SRC_FILES := stack_unwinding_test_impl.c 99include $(BUILD_STATIC_LIBRARY) 100 101include $(CLEAR_VARS) 102LOCAL_MODULE := bionic-unit-tests-unwind-test-impl-host 103LOCAL_CFLAGS += $(test_c_flags) -fexceptions -fnon-call-exceptions 104LOCAL_SRC_FILES := stack_unwinding_test_impl.c 105include $(BUILD_HOST_STATIC_LIBRARY) 106 107# Build tests for the device (with bionic's .so). Run with: 108# adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests 109include $(CLEAR_VARS) 110LOCAL_MODULE := bionic-unit-tests 111LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 112LOCAL_CFLAGS += $(test_c_flags) 113LOCAL_LDFLAGS += $(test_dynamic_ldflags) 114LOCAL_SHARED_LIBRARIES += libdl 115LOCAL_SRC_FILES := $(test_src_files) $(test_dynamic_src_files) 116LOCAL_WHOLE_STATIC_LIBRARIES := $(test_fortify_static_libraries) 117LOCAL_STATIC_LIBRARIES += bionic-unit-tests-unwind-test-impl 118include $(BUILD_NATIVE_TEST) 119 120# Build tests for the device (with bionic's .a). Run with: 121# adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static 122include $(CLEAR_VARS) 123LOCAL_MODULE := bionic-unit-tests-static 124LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 125LOCAL_FORCE_STATIC_EXECUTABLE := true 126LOCAL_WHOLE_STATIC_LIBRARIES += libBionicTests 127LOCAL_STATIC_LIBRARIES += libstlport_static libstdc++ libm libc bionic-unit-tests-unwind-test-impl 128include $(BUILD_NATIVE_TEST) 129 130# ----------------------------------------------------------------------------- 131# We build the static unit tests as a library so they can be used both for 132# bionic-unit-tests-static and also as part of CTS. 133# ----------------------------------------------------------------------------- 134 135include $(CLEAR_VARS) 136LOCAL_MODULE := libBionicTests 137LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 138LOCAL_CFLAGS += $(test_c_flags) 139LOCAL_SRC_FILES := $(test_src_files) 140LOCAL_CFLAGS += -DGTEST_OS_LINUX_ANDROID -DGTEST_HAS_STD_STRING 141LOCAL_C_INCLUDES += bionic bionic/libstdc++/include external/gtest/include external/stlport/stlport 142LOCAL_WHOLE_STATIC_LIBRARIES := $(test_fortify_static_libraries) 143include $(BUILD_STATIC_LIBRARY) 144 145# ----------------------------------------------------------------------------- 146# Test library for the unit tests. 147# ----------------------------------------------------------------------------- 148 149# Build no-elf-hash-table-library.so to test dlopen(3) on a library that 150# only has a GNU-style hash table. MIPS doesn't support GNU hash style. 151ifneq ($(TARGET_ARCH),mips) 152include $(CLEAR_VARS) 153LOCAL_MODULE := no-elf-hash-table-library 154LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 155LOCAL_SRC_FILES := empty.cpp 156LOCAL_LDFLAGS := -Wl,--hash-style=gnu 157include $(BUILD_SHARED_LIBRARY) 158endif 159 160# ----------------------------------------------------------------------------- 161# Unit tests built against glibc. 162# ----------------------------------------------------------------------------- 163 164# Build tests for the host (with glibc). 165# Note that this will build against glibc, so it's not useful for testing 166# bionic's implementation, but it does let you use glibc as a reference 167# implementation for testing the tests themselves. 168ifeq ($(HOST_OS)-$(HOST_ARCH),linux-x86) 169include $(CLEAR_VARS) 170LOCAL_MODULE := bionic-unit-tests-glibc 171LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 172LOCAL_CFLAGS += $(test_c_flags) 173LOCAL_LDFLAGS += -lpthread -ldl -lrt 174LOCAL_LDFLAGS += $(test_dynamic_ldflags) 175LOCAL_SRC_FILES := $(test_src_files) $(test_dynamic_src_files) 176LOCAL_STATIC_LIBRARIES += bionic-unit-tests-unwind-test-impl-host 177include $(BUILD_HOST_NATIVE_TEST) 178endif 179 180# ----------------------------------------------------------------------------- 181# FORTIFY_SOURCE tests 182# ----------------------------------------------------------------------------- 183 184fortify_c_includes = \ 185 bionic \ 186 bionic/libstdc++/include \ 187 external/stlport/stlport \ 188 external/gtest/include 189fortify_test_files = fortify_test.cpp 190 191# -Wno-error=unused-parameter needed as 192# external/stlport/stlport/stl/_threads.c (included from 193# external/gtest/include/gtest/gtest.h) does not compile cleanly under 194# clang. TODO: fix this. 195fortify_c_flags = $(test_c_flags) -Wno-error=unused-parameter 196 197include $(CLEAR_VARS) 198LOCAL_SRC_FILES := $(fortify_test_files) 199LOCAL_MODULE := fortify1-tests-gcc 200LOCAL_CFLAGS += $(fortify_c_flags) -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DTEST_NAME=Fortify1_Gcc 201LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 202LOCAL_C_INCLUDES += $(fortify_c_includes) 203include $(BUILD_STATIC_LIBRARY) 204 205include $(CLEAR_VARS) 206LOCAL_SRC_FILES := $(fortify_test_files) 207LOCAL_MODULE := fortify2-tests-gcc 208LOCAL_CFLAGS += $(fortify_c_flags) -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -DTEST_NAME=Fortify2_Gcc 209LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 210LOCAL_C_INCLUDES += $(fortify_c_includes) 211include $(BUILD_STATIC_LIBRARY) 212 213include $(CLEAR_VARS) 214LOCAL_SRC_FILES := $(fortify_test_files) 215LOCAL_MODULE := fortify1-tests-clang 216LOCAL_CLANG := true 217LOCAL_CFLAGS += $(fortify_c_flags) -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DTEST_NAME=Fortify1_Clang 218LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 219LOCAL_C_INCLUDES += $(fortify_c_includes) 220include $(BUILD_STATIC_LIBRARY) 221 222include $(CLEAR_VARS) 223LOCAL_SRC_FILES := $(fortify_test_files) 224LOCAL_MODULE := fortify2-tests-clang 225LOCAL_CLANG := true 226LOCAL_CFLAGS += $(fortify_c_flags) -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -DTEST_NAME=Fortify2_Clang 227LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 228LOCAL_C_INCLUDES += $(fortify_c_includes) 229include $(BUILD_STATIC_LIBRARY) 230 231endif # !BUILD_TINY_ANDROID 232