[IOT-1517] Update scons scripts to pull gtest from github
authorGeorge Nash <george.nash@intel.com>
Tue, 15 Nov 2016 20:07:13 +0000 (12:07 -0800)
committerDan Mihai <Daniel.Mihai@microsoft.com>
Tue, 6 Dec 2016 21:23:26 +0000 (21:23 +0000)
Stop downloading gtest-1.7.0 from the fedora project mirror.
Download it from github googletest project page.

The major changes as a result are:
    - The name of the zip file has changed from
      gtest-1.7.0.zip to release-1.7.0.zip
    - The name of the extracted folder has changed from
      gtest-1.7.0 to googletest-release-1.7.0
    - Google test no longer contains a configure file to
      run auto make files. The autoreconfig tool is used
      to produce a new configure file from the
      configure.ac file.

Change-Id: I3316af1f3a875137a872577a22f0e4db74f0b0f3
Signed-off-by: George Nash <george.nash@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14381
Reviewed-by: Larry Sachs <larry.j.sachs@intel.com>
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
extlibs/gtest/SConscript
resource/csdk/stack/test/README
resource/unittests/README
run.bat
service/easy-setup/enrollee/unittests/SConscript
service/easy-setup/mediator/richsdk/unittests/SConscript
service/notification/cpp-wrapper/unittest/SConscript
service/notification/unittest/SConscript
tools/scons/RunTest.py

index d127ccf..d0ccbae 100644 (file)
@@ -6,6 +6,7 @@
 ##
 
 import os
+import shutil
 
 Import('env')
 
@@ -14,11 +15,11 @@ target_os = gtest_env.get('TARGET_OS')
 src_dir = gtest_env.get('SRC_DIR')
 
 targets_need_gtest = ['darwin','linux', 'msys_nt', 'windows']
-gtest_dir      = os.path.join(src_dir, 'extlibs', 'gtest', 'gtest-1.7.0')
+gtest_dir      = os.path.join(src_dir, 'extlibs', 'gtest', 'googletest-release-1.7.0')
 gtest_lib_dir = os.path.join(gtest_dir,'lib')
 gtest_dotlib_dir =  os.path.join(gtest_lib_dir, '.libs')
-gtest_zip_file = os.path.join(src_dir, 'extlibs', 'gtest', 'gtest-1.7.0.zip')
-gtest_url = 'http://pkgs.fedoraproject.org/repo/pkgs/gtest/gtest-1.7.0.zip/2d6ec8ccdf5c46b05ba54a9fd1d130d7/gtest-1.7.0.zip'
+gtest_zip_file = os.path.join(src_dir, 'extlibs', 'gtest', 'release-1.7.0.zip')
+gtest_url = 'https://github.com/google/googletest/archive/release-1.7.0.zip'
 
 if target_os in targets_need_gtest:
        print '*** Checking for installation of google unit test 1.7.0 ***'
@@ -31,51 +32,24 @@ if target_os in targets_need_gtest:
                print 'Unzipping to : ' + gtest_dir
                gtest_env.UnpackAll(gtest_dir, gtest_zip)
 
-if target_os == 'darwin':
-       if os.path.exists(gtest_dir):
-               # Build gtest and store it at a temporary directory
-
-               if not os.path.exists(gtest_lib_dir):
-#                      print 'Create a directory'
-#                      os.mkdir(gtest_lib_dir)
-
-
-                       print 'Invoke cmake command to generate appropriate make files'
-                       gtest_env.Configure(gtest_dir, './configure')
-
-                       # Run make on gtest
-                       print 'Making google unit test'
-                       gtest_env.Configure(gtest_dir, 'make')
-
-#                      print 'Create a directory'
-#                      os.mkdir(gtest_dotlib_dir)
-
-                       print 'Change to a directory'
-                       os.chdir(gtest_dotlib_dir)
-
-##                     print 'Change to a directory'
-#                      os.chdir(gtest_lib_dir)
-
-                       print 'Create hard links pointing to gtest libraries'
-                       os.link('libgtest.a', gtest_lib_dir + 'libgtest.a')
-                       os.link('libgtest_main.a', gtest_lib_dir +  'libgtest_main.a')
-                       print 'Create hard links pointing to gtest libraries - DONE'
-
-
-elif target_os in ['linux']:
+if target_os in ['linux']:
        if os.path.exists(gtest_dir):
                if not os.path.exists(gtest_lib_dir):
                        # Run configure on gtest
                        print 'Configuring google unit test'
+                       reconfigure_ran = gtest_env.Configure(gtest_dir, 'autoreconf -i')
                        if env.get('CROSS_COMPILE'):
-                               env.Configure(gtest_dir, './configure --disable-shared --host=' + env['CROSS_COMPILE'])
+                               configure_ran = env.Configure(gtest_dir, './configure --disable-shared --host=' + env['CROSS_COMPILE'])
+                               gtest_env.Depends(configure_ran, reconfigure_ran)
                        else:
-                               env.Configure(gtest_dir, './configure --disable-shared')
+                               configure_ran = env.Configure(gtest_dir, './configure --disable-shared')
+                               gtest_env.Depends(configure_ran, reconfigure_ran)
                        # Run make on gtest
                        print 'Making google unit test'
-                       gtest_env.Configure(gtest_dir, 'make')
+                       make_ran = gtest_env.Configure(gtest_dir, 'make')
+                       gtest_env.Depends(make_ran, configure_ran)
 
-elif target_os == 'msys_nt':
+elif target_os in ['darwin', 'msys_nt']:
        if os.path.exists(gtest_dir):
                if not os.path.exists(gtest_lib_dir):
                        # Create lib dir
@@ -96,7 +70,7 @@ elif target_os == 'msys_nt':
                        gtest_env.Configure(gtest_dir, 'cp libgtest_main.a lib')
                        gtest_env.Configure(gtest_dir, 'mv libgtest_main.a lib/.libs')
 
-elif target_os == 'windows':
+elif target_os in ['windows']:
        # Avoid building the same StaticLibrary in more than one environment, by using the
        # IOTIVITY_GTEST_HAS_BEEN_BUILT environment variable
        if not env.has_key('IOTIVITY_GTEST_HAS_BEEN_BUILT'):
@@ -127,4 +101,5 @@ if target_os in targets_need_gtest:
        if target_os in ['windows']:
                gtest_env.AppendUnique(LINKFLAGS = ['/subsystem:CONSOLE'])
 
+
 Return('gtest_env')
index 7d08f04..7b727e5 100644 (file)
@@ -10,7 +10,7 @@ directory. The build steps used in continuous integration can be found
 in auto_build.sh which is also in the the repository root directory.
 
 To dynamically link with the Google Unit test library,
-add <src_dir>/extlibs/gtest/gtest-1.7.0/lib/.libs/ to LD_LIBRARY_PATH
+add <src_dir>/extlibs/gtest/googletest-release-1.7.0/lib/.libs/ to LD_LIBRARY_PATH
 
 //---------------------------------------------------------------------
 
@@ -33,7 +33,7 @@ Unit Test Requirements:
    For example:
 
 
-   GTEST_DIR := /home/johndoe/utils/gtest-1.7.0
+   GTEST_DIR := /home/johndoe/utils/googletest-release-1.7.0
 
 3. The unit test assumes that a network interface is available
    (e.g. "eth0", "wlan0", etc.)
@@ -53,7 +53,7 @@ Unit Test Requirements:
 
 6. Export LD_LIBRARY_PATH before running the unit tests.
    Example:
-   export LD_LIBRARY_PATH=/home/tester/Documents/iotivity/extlibs/gtest/gtest-1.7.0/lib/.libs/
+   export LD_LIBRARY_PATH=/home/tester/Documents/iotivity/extlibs/gtest/googletest-release-1.7.0/lib/.libs/
 
 7. Run the unit test by issuing the following command from root 'iotivity' folder
    ./out/<TARGET_OS>/<TARGET_ARCH>/<release/debug>/resource/csdk/stack/test
index 3794765..5a34cf6 100644 (file)
@@ -10,7 +10,7 @@ directory. The build steps used in continuous integration can be found
 in auto_build.sh which is also in the the repository root directory.
 
 To dynamically link with the Google Unit test library,
-add <src_dir>/extlibs/gtest/gtest-1.7.0/lib/.libs/ to LD_LIBRARY_PATH
+add <src_dir>/extlibs/gtest/googletest-release-1.7.0/lib/.libs/ to LD_LIBRARY_PATH
 
 //---------------------------------------------------------------------
 
@@ -27,7 +27,7 @@ It is not a system or end-to-end test.
 
 2. Export LD_LIBRARY_PATH before running the unit tests.
    Example:
-   export LD_LIBRARY_PATH=/home/tester/Documents/iotivity/extlibs/gtest/gtest-1.7.0/lib/.libs/
+   export LD_LIBRARY_PATH=/home/tester/Documents/iotivity/extlibs/gtest/googletest-release-1.7.0/lib/.libs/
 
 3. Run the unit test by issuing the following command from root 'iotivity' folder:
    ./out/<TARGET_OS>/<TARGET_ARCH>/<release/debug>/resource/unittests/unittests
diff --git a/run.bat b/run.bat
index 578005b..c40c469 100644 (file)
--- a/run.bat
+++ b/run.bat
@@ -150,16 +150,16 @@ if "!RUN_ARG!"=="server" (
   scons VERBOSE=1 %BUILD_OPTIONS% -c clean
   rd /s /q out
   del .sconsign.dblite
-  del extlibs\gtest\gtest*.lib
-  del extlibs\gtest\gtest-1.7.0\src\gtest*.obj
+  del extlibs\gtest\googletest*.lib
+  del extlibs\gtest\googletest-release-1.7.0\src\gtest*.obj
   erase /s *.obj
   erase resource\c_common\iotivity_config.h
   erase extlibs\libcoap\coap.lib
   erase extlibs\libcoap\libcoap\include\coap\coap_config.h
   erase extlibs\mbedtls\mbed*.lib
 ) else if "!RUN_ARG!"=="cleangtest" (
-  rd /s /q extlibs\gtest\gtest-1.7.0
-  del extlibs\gtest\gtest-1.7.0.zip
+  rd /s /q extlibs\gtest\googletest-release-1.7.0
+  del extlibs\gtest\release-1.7.0.zip
 ) else (
     echo.%0 - Script requires a valid argument!
     goto :EOF
index 399cb12..d7ff5fe 100644 (file)
@@ -33,7 +33,8 @@ else:
 if env.get('LOGGING'):
        env.AppendUnique(CPPDEFINES = ['TB_LOG'])
 
-lib_env = env.Clone()
+lib_env = SConscript('#extlibs/gtest/SConscript')
+rd_mode = env.get('RD_MODE')
 
 SConscript(env.get('SRC_DIR') + '/service/third_party_libs.scons', 'lib_env')
 
@@ -41,7 +42,7 @@ SConscript(env.get('SRC_DIR') + '/service/third_party_libs.scons', 'lib_env')
 #unit test setting
 ######################################################################
 src_dir = lib_env.get('SRC_DIR')
-gtest_dir = src_dir + '/extlibs/gtest/gtest-1.7.0'
+gtest_dir = src_dir + '/extlibs/gtest/googletest-release-1.7.0'
 
 easysetup_test_env = lib_env.Clone()
 target_os = env.get('TARGET_OS')
index 986ace1..40c6a00 100644 (file)
@@ -40,7 +40,7 @@ SConscript(env.get('SRC_DIR') + '/service/third_party_libs.scons', 'lib_env')
 #unit test setting
 ######################################################################
 src_dir = lib_env.get('SRC_DIR')
-gtest_dir = src_dir + '/extlibs/gtest/gtest-1.7.0'
+gtest_dir = src_dir + '/extlibs/gtest/googletest-release-1.7.0'
 
 easysetup_test_env = lib_env.Clone()
 target_os = env.get('TARGET_OS')
index af0b2a5..a6adca8 100644 (file)
@@ -40,7 +40,7 @@ SConscript(env.get('SRC_DIR') + '/service/third_party_libs.scons', 'lib_env')
 #unit test setting
 ######################################################################
 src_dir = lib_env.get('SRC_DIR')
-gtest_dir = src_dir + '/extlibs/gtest/gtest-1.7.0'
+gtest_dir = src_dir + '/extlibs/gtest/googletest-release-1.7.0'
 
 notification_wrapper_test_env = lib_env.Clone()
 target_os = env.get('TARGET_OS')
index a0aae39..1730cb6 100644 (file)
@@ -40,7 +40,7 @@ SConscript(env.get('SRC_DIR') + '/service/third_party_libs.scons', 'lib_env')
 #unit test setting
 ######################################################################
 src_dir = lib_env.get('SRC_DIR')
-gtest_dir = src_dir + '/extlibs/gtest/gtest-1.7.0'
+gtest_dir = src_dir + '/extlibs/gtest/googletest-release-1.7.0'
 
 notification_test_env = lib_env.Clone()
 target_os = env.get('TARGET_OS')
index f814bd5..301370e 100644 (file)
@@ -39,7 +39,7 @@ def run_test(env, xml_file, test):
     # Make sure the Google Test libraries are in the dynamic
     # linker/loader path.
     env.AppendENVPath('LD_LIBRARY_PATH', [build_dir])
-    env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
+    env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/googletest-release-1.7.0/lib/.libs'])
 
     test_cmd = os.path.join(build_dir, test)