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