Download gtest-1.7.0 rather than depending on it being installed
authorWilliam Dieter <william.r.dieter@intel.com>
Sat, 20 Dec 2014 18:46:44 +0000 (18:46 +0000)
committerWilliam Dieter <william.r.dieter@intel.com>
Sat, 20 Dec 2014 19:12:48 +0000 (19:12 +0000)
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 <william.r.dieter@intel.com>
.gitignore
resource/unittests/README
resource/unittests/makefile

index 1db09ad..aec3a0b 100644 (file)
@@ -51,3 +51,7 @@ config.log
 os
 out/
 platform
+
+# Ignore downloaded dependencies
+extlibs/gtest*
+extlibs/cereal
index de6594e..70d5515 100644 (file)
@@ -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 <gtest-1.7.0> from the
-   following address:
-
-       http://code.google.com/p/googletest/downloads/list
-
-2. Create/Append a file named "local.properties" at <oic-resource>/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 := <gtest-1.7.0>
-
-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 <oic-resource>:
 
    make -f buildScript.mk linux_ub_unittests
 
-4. Run the unit test by issuing the following command from <oic-resource>:
+2. Run the unit test by issuing the following command from <oic-resource>:
 
    ./unittests/tests
index 5461731..6a05e80 100644 (file)
@@ -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: