From c831059e003183517883381177ff312bfe00dbe9 Mon Sep 17 00:00:00 2001 From: Nicolas Catania Date: Wed, 10 Feb 2010 21:47:49 -0800 Subject: Cleanup the ASTL makefiles. src/Android.mk: Removed empty lines. Removed the ifdef ASTL_TESTS guard and replaced it with a HOST_OS == linux one. The tests will now be built by default for the targets and on linux hosts. Renamed the host module name to libastl_host. Now need to submit a CL to fix the gtest project before this one can go in. tests/Android.mk: Test targets ends with _host to avoid multiple modules (host vs target) with the same name. Removed verbosity of the makefile (dropped the $(info xxx) statements). Collapsed the 2 define tests into one (similar to the one in the gtest package). Extracted the common include directives to a new libastl_test_includes var. Got rid of unused EXTRA_CFLAGS (uses LOCAL_C_INCLUDES) and EXTRA_LDFLAGS. Removed the ASTL_TESTS guard, the tests will always be built. A host version is built on Linux to run under valgrind. Forces the tests to go under /data and not /system/bin Tested: Build on linux for passion-eng and sim-eng --- src/Android.mk | 22 ++++----------- tests/Android.mk | 81 ++++++++++++++++++++++++++++---------------------------- 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 -- cgit v1.2.3