From 35175a4c63b1ea76d5c0f5fb4c9e9bf1437c0290 Mon Sep 17 00:00:00 2001 From: William Dieter Date: Sat, 20 Dec 2014 18:46:44 +0000 Subject: [PATCH] Download gtest-1.7.0 rather than depending on it being installed Making the user download and install gtest-1.7.0 is inconvenient for the user. Also, we do not have direct access to the build machine to update how and where gtest is stored. Downloading to the extlibs directory in project source tree removes the need for developers to download and build gtest and removes the need to configure the build machine. Change-Id: I3b163c09ecdd9f12e8004a69dfa8dbcaf4ae5615 Signed-off-by: William Dieter --- .gitignore | 4 ++++ resource/unittests/README | 17 ++--------------- resource/unittests/makefile | 20 ++++++++++++-------- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index 1db09ad..aec3a0b 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,7 @@ config.log os out/ platform + +# Ignore downloaded dependencies +extlibs/gtest* +extlibs/cereal diff --git a/resource/unittests/README b/resource/unittests/README index de6594e..70d5515 100644 --- a/resource/unittests/README +++ b/resource/unittests/README @@ -4,24 +4,11 @@ It is not a system or end-to-end test. Unit Test Requirements: -1. Install Google Test 1.7.0 on a Linux build machine to from the - following address: - - http://code.google.com/p/googletest/downloads/list - -2. Create/Append a file named "local.properties" at /csdk. - "local.properties" is used by the build process to specify the path to the - Google Test directory. - - local.properties should contain GTEST_DIR, as follows: - - GTEST_DIR := - -3. To run the unit test, first build the unit tests with the following command +1. To run the unit test, first build the unit tests with the following command from : make -f buildScript.mk linux_ub_unittests -4. Run the unit test by issuing the following command from : +2. Run the unit test by issuing the following command from : ./unittests/tests diff --git a/resource/unittests/makefile b/resource/unittests/makefile index 5461731..6a05e80 100644 --- a/resource/unittests/makefile +++ b/resource/unittests/makefile @@ -29,13 +29,8 @@ ROOT_DIR = ./ # You must create the file "local.properties" on your local machine which contains any local paths, etc # local.properties should NOT be committed to repo include $(ROOT_DIR)/../csdk/local.properties -# GTEST_DIR contains the path to Google Test libs and must be defined in local.properties -# Example: -# GTEST_DIR := /home/johndoe/utils/gtest-1.7.0 - -# NOTE: to run app, make sure that LD_LIBRARY_PATH env variable -# contains $(GTEST_DIR)/lib/.libs +GTEST_DIR= ../../extlibs/gtest-1.7.0 OUT_DIR := $(BUILD) ifeq ($(ROOT_DIR),) @@ -53,8 +48,9 @@ INC_DIRS += -I$(GTEST_DIR)/include LIB_OC_LOGGER := ../oc_logger/lib/oc_logger.a +GTEST_LIBS := $(GTEST_DIR)/lib/.libs/libgtest.a $(GTEST_DIR)/lib/.libs/libgtest_main.a CXX_LIBS := ../$(BUILD)/obj/liboc.a ../csdk/$(PLATFORM)/$(BUILD)/liboctbstack.a $(LIB_OC_LOGGER) -CXX_LIBS += $(GTEST_DIR)/lib/.libs/libgtest.a $(GTEST_DIR)/lib/.libs/libgtest_main.a +CXX_LIBS += $(GTEST_LIBS) CC_FLAGS.debug := -g -O0 -g3 -Wall -ffunction-sections -fdata-sections \ -std=c++0x -pedantic $(INC_DIRS) -L$(ROOT_DIR)/$(BUILD) -DTB_LOG @@ -68,9 +64,17 @@ all: prep_dirs tests prep_dirs: -mkdir -p $(OUT_DIR) -tests: tests.cpp +tests: tests.cpp $(GTEST_LIBS) $(CXX) $^ $(CPPFLAGS) -o $(OUT_DIR)/$@ +$(GTEST_LIBS): $(GTEST_DIR) + cd $(GTEST_DIR) && ./configure && make + +$(GTEST_DIR): + cd ../../extlibs && \ + wget -q https://googletest.googlecode.com/files/gtest-1.7.0.zip && \ + unzip gtest-1.7.0.zip + .PHONY: clean clean: -- 2.7.4