aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Catania <niko@google.com>2010-02-22 11:28:02 -0800
committerNicolas Catania <niko@google.com>2010-02-22 12:44:11 -0800
commitcda9ca55683d97e2d215e4a786a865e2b41bc26f (patch)
tree4d3a79d71a9046534b78577d3cdd7e3b23d706fc
parent97bd226fd5b5ea1600c00b04fd281c71cdbaa0aa (diff)
downloadgtest-cda9ca55683d97e2d215e4a786a865e2b41bc26f.tar.gz
Build gtest using stlport.
src/Android.mk Added _host prefix to the module name for host build to prevent name clashes with the device's targets. tests/Android.mk Added _host prefix to the tests built on host. Use new variables to list the required libraries. This is needed because the host libs now have a _host suffix so I maintain the 2 lists of libs separatly. Tests are systematically built. Tested: On linux, build passion-eng and sim-eng Needs to be submitted before Id4771c5f
-rw-r--r--src/Android.mk31
-rw-r--r--test/Android.mk63
2 files changed, 68 insertions, 26 deletions
diff --git a/src/Android.mk b/src/Android.mk
index fd3cd63..239e40e 100644
--- a/src/Android.mk
+++ b/src/Android.mk
@@ -20,27 +20,32 @@
# libgtest_main you won't/should not provide a main() entry point.
#
# We build these 2 libraries for the target device and for the host if
-# it is running linux. The linux build and tests are run under
-# valgrind by 'runtest'.
+# it is running linux and using ASTL.
#
-# Includes:
-# * For a host build we need to specify bionic/libstdc++/include
-# otherwise gcc will pick the system's STL. For targets build this
-# is automatically done by the toolchain but we add it for the
-# simulator builds..
-# * libjingle's include directives start at the 'talk' level which is
-# 2 directories up. We use $(LOCAL_PATH) to get an absolute include
-# path just in case talk has been symlinked.
+
+# TODO: The targets below have some redundancy. Check if we cannot
+# condense them using function(s) for the common code.
LOCAL_PATH := $(call my-dir)
+ifeq ($(BUILD_WITH_ASTL),true)
libgtest_includes:= \
bionic/libstdc++/include \
external/astl/include \
$(LOCAL_PATH)/.. \
$(LOCAL_PATH)/../include
+else
+# BUILD_WITH_ASTL could be undefined, force it to false.
+BUILD_WITH_ASTL := false
+libgtest_includes := \
+ bionic \
+ external/stlport/stlport \
+ $(LOCAL_PATH)/.. \
+ $(LOCAL_PATH)/../include
+endif
-ifeq ($(HOST_OS),linux)
+# Gtest depends on STLPort which does not build on host/simulator.
+ifeq ($(HOST_OS)-$(BUILD_WITH_ASTL),linux-true)
#######################################################################
# gtest lib host
@@ -55,7 +60,7 @@ LOCAL_C_INCLUDES := $(libgtest_includes)
LOCAL_CFLAGS += -O0
-LOCAL_MODULE := libgtest
+LOCAL_MODULE := libgtest_host
LOCAL_MODULE_TAGS := eng
include $(BUILD_HOST_STATIC_LIBRARY)
@@ -75,7 +80,7 @@ LOCAL_CFLAGS += -O0
LOCAL_STATIC_LIBRARIES := libgtest
-LOCAL_MODULE := libgtest_main
+LOCAL_MODULE := libgtest_main_host
LOCAL_MODULE_TAGS := eng
include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/test/Android.mk b/test/Android.mk
index eb07faa..7de718e 100644
--- a/test/Android.mk
+++ b/test/Android.mk
@@ -14,45 +14,81 @@
#
#
-# define the GTEST_TESTS environment variable to build the test programs
-ifdef GTEST_TESTS
+# Test for gtest. Run using 'runtest'.
+# The linux build and tests are run under valgrind by 'runtest'.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# TODO: Refactor these as 1st class build templates as suggested in
-# review of the orginal import.
+# review of the original import.
-libgtest_test_includes:= \
- bionic/libstdc++/include \
- external/astl/include \
+# Gtest depends on STLPort which does not build on host/simulator.
+
+ifeq ($(BUILD_WITH_ASTL),true)
+libgtest_test_includes := \
+ bionic/libstdc++/include \
+ external/astl/include \
+ $(LOCAL_PATH)/../include \
+ $(LOCAL_PATH)/..
+libgtest_test_static_lib := libgtest_main libgtest libastl
+libgtest_test_shared_lib :=
+libgtest_test_host_static_lib := libgtest_main_host libgtest_host libastl_host
+libgtest_test_host_shared_lib :=
+else
+# BUILD_WITH_ASTL could be undefined, force it to false (for the guard
+# before the test-target call).
+BUILD_WITH_ASTL := false
+libgtest_test_includes := \
+ bionic \
+ external/stlport/stlport \
$(LOCAL_PATH)/../include \
$(LOCAL_PATH)/..
+libgtest_test_static_lib := libgtest_main libgtest
+libgtest_test_shared_lib := libstlport
+libgtest_test_host_static_lib :=
+libgtest_test_host_shared_lib :=
+endif
+# $(2) and $(4) must be set or cleared in sync. $(2) is used to
+# generate the right make target (host vs device). $(4) is used in the
+# module's name and to have different module names for the host vs
+# device builds. Finally $(4) is used to pickup the right set of
+# libraries, typically the host libs have a _host suffix in their
+# names.
# $(1): source list
# $(2): "HOST_" or empty
# $(3): extra CFLAGS or empty
+# $(4): "_host" or empty
define _define-test
$(foreach file,$(1), \
$(eval include $(CLEAR_VARS)) \
$(eval LOCAL_CPP_EXTENSION := .cc) \
$(eval LOCAL_SRC_FILES := $(file)) \
$(eval LOCAL_C_INCLUDES := $(libgtest_test_includes)) \
- $(eval LOCAL_MODULE := $(notdir $(file:%.cc=%))) \
+ $(eval LOCAL_MODULE := $(notdir $(file:%.cc=%))$(4)) \
$(eval LOCAL_CFLAGS += $(3)) \
- $(eval LOCAL_STATIC_LIBRARIES := libgtest_main libgtest libastl) \
- $(eval LOCAL_MODULE_TAGS := eng) \
+ $(eval LOCAL_STATIC_LIBRARIES := $(libgtest_test$(4)_static_lib)) \
+ $(eval LOCAL_SHARED_LIBRARIES := $(libgtest_test$(4)_shared_lib)) \
+ $(eval LOCAL_MODULE_TAGS := tests) \
+ $(eval LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)) \
$(eval include $(BUILD_$(2)EXECUTABLE)) \
)
endef
+ifeq ($(HOST_OS)-$(BUILD_WITH_ASTL),linux-true)
define host-test
-$(call _define-test,$(1),HOST_,-O0)
+$(call _define-test,$(1),HOST_,-O0,_host)
endef
+endif
+
+# Cannot build simulator with STLport.
+ifneq ($(TARGET_SIMULATOR)-$(BUILD_WITH_ASTL),true-false)
define target-test
$(call _define-test,$(1))
endef
+endif
sources := \
gtest-death-test_test.cc \
@@ -72,12 +108,13 @@ sources := \
gtest_unittest.cc \
gtest_prod_test.cc
-ifeq ($(HOST_OS),linux)
+ifeq ($(HOST_OS)-$(BUILD_WITH_ASTL),linux-true)
$(call host-test, $(sources))
endif
+# Cannot build simulator with STLport.
+ifneq ($(TARGET_SIMULATOR)-$(BUILD_WITH_ASTL),true-false)
$(call target-test, $(sources))
-
-endif # GTEST_TESTS
+endif