Android.mk revision 5abe6dfaae971d3c0d1c8e3349b0d2b2ae83cc97
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# define the ASTL_TESTS environment variable to build the test programs
20ifdef ASTL_TESTS
21
22LOCAL_PATH := $(call my-dir)
23
24# used to define a simple test program and build it as a standalone
25# device executable.
26#
27# you can use EXTRA_CFLAGS to indicate additional CFLAGS to use
28# in the build. the variable will be cleaned on exit
29#
30define device-test
31  $(foreach file,$(1), \
32    $(eval include $(CLEAR_VARS)) \
33    $(eval LOCAL_SRC_FILES := $(file)) \
34    $(eval LOCAL_MODULE := $(notdir $(file:%.cpp=%))) \
35    $(eval $(info LOCAL_MODULE=$(LOCAL_MODULE))) \
36    $(eval LOCAL_CFLAGS += $(EXTRA_CFLAGS)) \
37    $(eval LOCAL_MODULE_TAGS := tests) \
38    $(eval LOCAL_STATIC_LIBRARIES := libastl) \
39    $(eval include $(BUILD_EXECUTABLE)) \
40  ) \
41  $(eval EXTRA_CFLAGS :=)
42endef
43
44# same as 'device-test' but builds a host executable instead
45# you can use EXTRA_LDLIBS to indicate additional linker flags
46#
47define host-test
48  $(foreach file,$(1), \
49    $(eval include $(CLEAR_VARS)) \
50    $(eval LOCAL_SRC_FILES := $(file)) \
51    $(eval LOCAL_MODULE := $(notdir $(file:%.cpp=%))) \
52    $(eval $(info LOCAL_MODULE=$(LOCAL_MODULE) file=$(file))) \
53    $(eval LOCAL_CFLAGS += $(EXTRA_CFLAGS))  \
54    $(eval LOCAL_LDLIBS += $(EXTRA_LDLIBS)) \
55    $(eval LOCAL_MODULE_TAGS := eng tests) \
56    $(eval LOCAL_STATIC_LIBRARIES := libastl) \
57    $(eval include $(BUILD_HOST_EXECUTABLE)) \
58  ) \
59  $(eval EXTRA_CFLAGS :=) \
60  $(eval EXTRA_LDLIBS :=)
61endef
62
63sources := \
64    test_algorithm.cpp \
65    test_functional.cpp \
66    test_ios_pos_types.cpp \
67    test_limits.cpp \
68    test_set.cpp \
69    test_string.cpp \
70    test_type_traits.cpp \
71    test_uninitialized.cpp \
72    test_vector.cpp
73
74# Disable all optimization for the host target to help test tools (valgrind...)
75EXTRA_CFLAGS := -I bionic/libstdc++/include -I external/astl/include -g -O0
76$(call host-test, $(sources))
77
78EXTRA_CFLAGS := -I bionic/libstdc++/include -I external/astl/include
79$(call device-test, $(sources))
80
81endif  #ASTL_TESTS
82