aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Catania <niko@google.com>2010-02-09 11:44:38 -0800
committerNicolas Catania <niko@google.com>2010-02-09 13:27:55 -0800
commit97bd226fd5b5ea1600c00b04fd281c71cdbaa0aa (patch)
treef69e1a5815c2a321917b728be6dd1130d9144c02
parentb27e0dd2ef1bc4c33c87ee6a745b08ca7c8d4948 (diff)
downloadgtest-97bd226fd5b5ea1600c00b04fd281c71cdbaa0aa.tar.gz
Fix for the gtest makefiles to build the libs and tests.
For the linux targets, fixed the include directives to include libstdc++ and astl. For the targets, both libgtest and libgtest_main are built. Tested on linux: passion-eng and sim-eng.
-rw-r--r--src/Android.mk90
-rw-r--r--test/Android.mk33
2 files changed, 89 insertions, 34 deletions
diff --git a/src/Android.mk b/src/Android.mk
index ec547c8..fd3cd63 100644
--- a/src/Android.mk
+++ b/src/Android.mk
@@ -14,37 +14,49 @@
#
#
-ifeq ($(HOST_OS),linux)
+# Gtest builds 2 libraries: libgtest and libgtest_main. libgtest
+# contains most of the code (assertions...) and libgtest_main just
+# provide a common main to run the test (ie if you link against
+# 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'.
+#
+# 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.
LOCAL_PATH := $(call my-dir)
+libgtest_includes:= \
+ bionic/libstdc++/include \
+ external/astl/include \
+ $(LOCAL_PATH)/.. \
+ $(LOCAL_PATH)/../include
+
+ifeq ($(HOST_OS),linux)
+
#######################################################################
# gtest lib host
include $(CLEAR_VARS)
LOCAL_CPP_EXTENSION := .cc
-# TODO: may need to drag these in a shared variable when we start to
-# support target builds.
-LOCAL_SRC_FILES := \
- gtest.cc \
- gtest-death-test.cc \
- gtest-filepath.cc \
- src/gtest-internal-inl.h \
- gtest-port.cc \
- gtest-test-part.cc \
- gtest-typed-test.cc
-
-
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/.. \
- $(LOCAL_PATH)/../include
+LOCAL_SRC_FILES := gtest-all.cc
+
+LOCAL_C_INCLUDES := $(libgtest_includes)
LOCAL_CFLAGS += -O0
LOCAL_MODULE := libgtest
-LOCAL_MODULE_TAGS := tests
+LOCAL_MODULE_TAGS := eng
include $(BUILD_HOST_STATIC_LIBRARY)
@@ -54,14 +66,10 @@ include $(BUILD_HOST_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_CPP_EXTENSION := .cc
-# TODO: may need to drag these in a shared variable when we start to
-# support target builds.
-LOCAL_SRC_FILES := \
- gtest_main.cc
-LOCAL_C_INCLUDES := \
- $(LOCAL_PATH)/.. \
- $(LOCAL_PATH)/../include
+LOCAL_SRC_FILES := gtest_main.cc
+
+LOCAL_C_INCLUDES := $(libgtest_includes)
LOCAL_CFLAGS += -O0
@@ -73,3 +81,37 @@ LOCAL_MODULE_TAGS := eng
include $(BUILD_HOST_STATIC_LIBRARY)
endif # HOST_OS == linux
+
+#######################################################################
+# gtest lib target
+
+include $(CLEAR_VARS)
+
+LOCAL_CPP_EXTENSION := .cc
+
+LOCAL_SRC_FILES := gtest-all.cc
+
+LOCAL_C_INCLUDES := $(libgtest_includes)
+
+LOCAL_MODULE := libgtest
+LOCAL_MODULE_TAGS := eng
+
+include $(BUILD_STATIC_LIBRARY)
+
+#######################################################################
+# gtest_main lib target
+
+include $(CLEAR_VARS)
+
+LOCAL_CPP_EXTENSION := .cc
+
+LOCAL_SRC_FILES := gtest_main.cc
+
+LOCAL_C_INCLUDES := $(libgtest_includes)
+
+LOCAL_STATIC_LIBRARIES := libgtest
+
+LOCAL_MODULE := libgtest_main
+LOCAL_MODULE_TAGS := eng
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/test/Android.mk b/test/Android.mk
index 1f399d6..eb07faa 100644
--- a/test/Android.mk
+++ b/test/Android.mk
@@ -14,12 +14,21 @@
#
#
-ifeq ($(HOST_OS),linux)
+# define the GTEST_TESTS environment variable to build the test programs
+ifdef GTEST_TESTS
+
LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
# TODO: Refactor these as 1st class build templates as suggested in
# review of the orginal import.
+libgtest_test_includes:= \
+ bionic/libstdc++/include \
+ external/astl/include \
+ $(LOCAL_PATH)/../include \
+ $(LOCAL_PATH)/..
+
# $(1): source list
# $(2): "HOST_" or empty
# $(3): extra CFLAGS or empty
@@ -28,11 +37,11 @@ $(foreach file,$(1), \
$(eval include $(CLEAR_VARS)) \
$(eval LOCAL_CPP_EXTENSION := .cc) \
$(eval LOCAL_SRC_FILES := $(file)) \
- $(eval LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include $(LOCAL_PATH)/..) \
+ $(eval LOCAL_C_INCLUDES := $(libgtest_test_includes)) \
$(eval LOCAL_MODULE := $(notdir $(file:%.cc=%))) \
$(eval LOCAL_CFLAGS += $(3)) \
- $(eval LOCAL_STATIC_LIBRARIES := libgtest_main libgtest) \
- $(eval LOCAL_MODULE_TAGS := tests) \
+ $(eval LOCAL_STATIC_LIBRARIES := libgtest_main libgtest libastl) \
+ $(eval LOCAL_MODULE_TAGS := eng) \
$(eval include $(BUILD_$(2)EXECUTABLE)) \
)
endef
@@ -41,30 +50,34 @@ define host-test
$(call _define-test,$(1),HOST_,-O0)
endef
-# TODO: Figure out the right CFLAGS combination needed for bionic/astl.
define target-test
$(call _define-test,$(1))
endef
-
-# We use the single file option to build all the tests.
sources := \
+ gtest-death-test_test.cc \
gtest-filepath_test.cc \
gtest-linked_ptr_test.cc \
gtest-message_test.cc \
gtest-options_test.cc \
gtest-port_test.cc \
+ gtest_environment_test.cc \
+ gtest_no_test_unittest.cc \
gtest_pred_impl_unittest.cc \
+ gtest_repeat_test.cc \
gtest-test-part_test.cc \
gtest-typed-test_test.cc \
gtest-typed-test2_test.cc \
+ gtest_stress_test.cc \
gtest_unittest.cc \
gtest_prod_test.cc
+ifeq ($(HOST_OS),linux)
$(call host-test, $(sources))
+endif
+
+$(call target-test, $(sources))
+endif # GTEST_TESTS
-# TODO: Target is not working yet.
-# $(call target-test, $(sources))
-endif # HOST_OS == linux