Android.mk revision 4a05bef4c06dac05f1c9aa8cfc5b7e7dd6642385
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    string_benchmark.cpp \
35    time_benchmark.cpp \
36
37# Build benchmarks for the device (with bionic's .so). Run with:
38#   adb shell bionic-benchmarks
39include $(CLEAR_VARS)
40LOCAL_MODULE := bionic-benchmarks
41LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
42LOCAL_CFLAGS += $(benchmark_c_flags)
43LOCAL_C_INCLUDES += external/stlport/stlport bionic/ bionic/libstdc++/include
44LOCAL_SHARED_LIBRARIES += libstlport
45LOCAL_SRC_FILES := $(benchmark_src_files)
46include $(BUILD_EXECUTABLE)
47
48# -----------------------------------------------------------------------------
49# Unit tests.
50# -----------------------------------------------------------------------------
51
52test_c_flags = \
53    -fstack-protector-all \
54    -g \
55    -Wall -Wextra \
56    -Werror \
57    -fno-builtin \
58
59test_src_files = \
60    debug_format_test.cpp \
61    dirent_test.cpp \
62    fenv_test.cpp \
63    getauxval_test.cpp \
64    getcwd_test.cpp \
65    libgen_test.cpp \
66    math_test.cpp \
67    netdb_test.cpp \
68    pthread_test.cpp \
69    regex_test.cpp \
70    signal_test.cpp \
71    stack_protector_test.cpp \
72    stdio_test.cpp \
73    stdlib_test.cpp \
74    string_test.cpp \
75    strings_test.cpp \
76    stubs_test.cpp \
77    unistd_test.cpp \
78
79test_dynamic_ldflags = -Wl,--export-dynamic -Wl,-u,DlSymTestFunction
80test_dynamic_src_files = \
81    dlfcn_test.cpp \
82
83# Build tests for the device (with bionic's .so). Run with:
84#   adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests
85include $(CLEAR_VARS)
86LOCAL_MODULE := bionic-unit-tests
87LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
88LOCAL_CFLAGS += $(test_c_flags)
89LOCAL_LDFLAGS += $(test_dynamic_ldflags)
90LOCAL_SHARED_LIBRARIES += libdl
91LOCAL_SRC_FILES := $(test_src_files) $(test_dynamic_src_files)
92include $(BUILD_NATIVE_TEST)
93
94# Build tests for the device (with bionic's .a). Run with:
95#   adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static
96include $(CLEAR_VARS)
97LOCAL_MODULE := bionic-unit-tests-static
98LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
99LOCAL_CFLAGS += $(test_c_flags)
100LOCAL_FORCE_STATIC_EXECUTABLE := true
101LOCAL_SRC_FILES := $(test_src_files)
102LOCAL_STATIC_LIBRARIES += libstlport_static libstdc++ libm libc
103include $(BUILD_NATIVE_TEST)
104
105# -----------------------------------------------------------------------------
106# Test library for the unit tests.
107# -----------------------------------------------------------------------------
108
109# Build no-elf-hash-table-library.so to test dlopen(3) on a library that
110# only has a GNU-style hash table. MIPS doesn't support GNU hash style.
111ifneq ($(TARGET_ARCH),mips)
112include $(CLEAR_VARS)
113LOCAL_MODULE := no-elf-hash-table-library
114LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
115LOCAL_SRC_FILES := empty.cpp
116LOCAL_LDFLAGS := -Wl,--hash-style=gnu
117include $(BUILD_SHARED_LIBRARY)
118endif
119
120# -----------------------------------------------------------------------------
121# Unit tests built against glibc.
122# -----------------------------------------------------------------------------
123
124# Build tests for the host (with glibc).
125# Note that this will build against glibc, so it's not useful for testing
126# bionic's implementation, but it does let you use glibc as a reference
127# implementation for testing the tests themselves.
128ifeq ($(HOST_OS)-$(HOST_ARCH),linux-x86)
129include $(CLEAR_VARS)
130LOCAL_MODULE := bionic-unit-tests-glibc
131LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
132LOCAL_CFLAGS += $(test_c_flags)
133LOCAL_LDFLAGS += -lpthread -ldl
134LOCAL_LDFLAGS += $(test_dynamic_ldflags)
135LOCAL_SRC_FILES := $(test_src_files) $(test_dynamic_src_files)
136include $(BUILD_HOST_NATIVE_TEST)
137endif
138
139endif # !BUILD_TINY_ANDROID
140