aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiko Catania <niko@google.com>2010-02-23 14:32:38 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-02-23 14:32:38 -0800
commit938395ab8004a27baf181a53c97b3a37878672ed (patch)
treed506afb77be6c4e83647193c7cc7509634ef8ecd
parent0cc3ee31c3cddd2bb5322398d17c388975e96d64 (diff)
parentc831059e003183517883381177ff312bfe00dbe9 (diff)
downloadastl-938395ab8004a27baf181a53c97b3a37878672ed.tar.gz
Merge "Cleanup the ASTL makefiles."
-rw-r--r--src/Android.mk22
-rw-r--r--tests/Android.mk81
2 files changed, 46 insertions, 57 deletions
diff --git a/src/Android.mk b/src/Android.mk
index 85b1a68..b5d4d3c 100644
--- a/src/Android.mk
+++ b/src/Android.mk
@@ -28,39 +28,27 @@ astl_common_src_files := \
streambuf.cpp \
string.cpp
-# Build the target lib
+# Target build
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(astl_common_src_files)
-
LOCAL_C_INCLUDES := external/astl/include
-
LOCAL_CFLAGS += -I bionic/libstdc++/include -I external/astl/include
-
LOCAL_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libutils
-
LOCAL_MODULE:= libastl
include $(BUILD_STATIC_LIBRARY)
-# Define the ASTL_TESTS environment variable to build the host lib
-# needed for testing under valgrind.
-# This is done automatically if you use: runtest astl
-
-ifdef ASTL_TESTS
-
+# On linux we build a host version of the lib to run under valgrind.
+ifeq ($(HOST_OS),linux)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(astl_common_src_files)
-
LOCAL_C_INCLUDES := external/astl/include
-
LOCAL_CFLAGS += -I bionic/libstdc++/include -I external/astl/include
-
LOCAL_SYSTEM_SHARED_LIBRARIES := libc libstdc++ libutils
-
-LOCAL_MODULE:= libastl
+LOCAL_MODULE:= libastl_host
include $(BUILD_HOST_STATIC_LIBRARY)
+endif
-endif #ASTL_TESTS
diff --git a/tests/Android.mk b/tests/Android.mk
index dab455a..db4c4b4 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -13,48 +13,51 @@
# limitations under the License.
#
-# define the ASTL_TESTS environment variable to build the test programs
-ifdef ASTL_TESTS
+# To integrate with the nightly build, we use
+# LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+# to put the tests under /data and not /system/bin (default).
LOCAL_PATH := $(call my-dir)
-# used to define a simple test program and build it as a standalone
-# device executable.
-#
-# you can use EXTRA_CFLAGS to indicate additional CFLAGS to use
-# in the build. the variable will be cleaned on exit
-#
-define device-test
- $(foreach file,$(1), \
- $(eval include $(CLEAR_VARS)) \
- $(eval LOCAL_SRC_FILES := $(file)) \
- $(eval LOCAL_MODULE := $(notdir $(file:%.cpp=%))) \
- $(eval $(info LOCAL_MODULE=$(LOCAL_MODULE))) \
- $(eval LOCAL_CFLAGS += $(EXTRA_CFLAGS)) \
- $(eval LOCAL_MODULE_TAGS := tests) \
- $(eval LOCAL_STATIC_LIBRARIES := libastl) \
- $(eval include $(BUILD_EXECUTABLE)) \
- ) \
- $(eval EXTRA_CFLAGS :=)
+libastl_test_includes:= \
+ bionic/libstdc++/include \
+ external/astl/include
+libastl_test_static_lib := libastl
+libastl_test_host_static_lib := libastl_host
+
+# $(3) and $(5) must be set or cleared in sync. $(3) is used to
+# generate the right make target (host vs device). $(5) is used in the
+# module's name to have different name for the host vs device
+# builds. Also $(5) is used to pickup the right set of libraries,
+# typically the host libs have a _host suffix in their names.
+# $(1): source list
+# $(2): tags
+# $(3): "HOST_" or empty
+# $(4): extra CFLAGS or empty
+# $(5): "_host" or empty
+define _define-test
+$(foreach file,$(1), \
+ $(eval include $(CLEAR_VARS)) \
+ $(eval LOCAL_SRC_FILES := $(file)) \
+ $(eval LOCAL_C_INCLUDES := $(libastl_test_includes)) \
+ $(eval LOCAL_MODULE := $(notdir $(file:%.cpp=%))$(5)) \
+ $(eval LOCAL_CFLAGS += $(4)) \
+ $(eval LOCAL_STATIC_LIBRARIES := $(libastl_test$(5)_static_lib)) \
+ $(eval LOCAL_MODULE_TAGS := $(2) ) \
+ $(eval LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)) \
+ $(eval include $(BUILD_$(3)EXECUTABLE)) \
+)
endef
-# same as 'device-test' but builds a host executable instead
-# you can use EXTRA_LDLIBS to indicate additional linker flags
-#
+ifeq ($(HOST_OS),linux)
+# Compile using the host only on linux for valgrind support.
define host-test
- $(foreach file,$(1), \
- $(eval include $(CLEAR_VARS)) \
- $(eval LOCAL_SRC_FILES := $(file)) \
- $(eval LOCAL_MODULE := $(notdir $(file:%.cpp=%))) \
- $(eval $(info LOCAL_MODULE=$(LOCAL_MODULE) file=$(file))) \
- $(eval LOCAL_CFLAGS += $(EXTRA_CFLAGS)) \
- $(eval LOCAL_LDLIBS += $(EXTRA_LDLIBS)) \
- $(eval LOCAL_MODULE_TAGS := eng tests) \
- $(eval LOCAL_STATIC_LIBRARIES := libastl) \
- $(eval include $(BUILD_HOST_EXECUTABLE)) \
- ) \
- $(eval EXTRA_CFLAGS :=) \
- $(eval EXTRA_LDLIBS :=)
+$(call _define-test,$(1),eng,HOST_,-O0 -g,_host)
+endef
+endif
+
+define target-test
+$(call _define-test,$(1),eng tests)
endef
sources := \
@@ -77,11 +80,9 @@ sources := \
test_uninitialized.cpp \
test_vector.cpp
-# Disable all optimization for the host target to help test tools (valgrind...)
-EXTRA_CFLAGS := -I bionic/libstdc++/include -I external/astl/include -g -O0
+ifeq ($(HOST_OS),linux)
$(call host-test, $(sources))
+endif
-EXTRA_CFLAGS := -I bionic/libstdc++/include -I external/astl/include
$(call device-test, $(sources))
-endif #ASTL_TESTS