From 589324fc7aba3f17a84aad8ab50d417efd8b5501 Mon Sep 17 00:00:00 2001 From: George Nash Date: Tue, 15 Nov 2016 12:07:13 -0800 Subject: [PATCH] [IOT-1517] Update scons scripts to pull gtest from github 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 Reviewed-on: https://gerrit.iotivity.org/gerrit/14381 Reviewed-by: Larry Sachs Reviewed-by: Phil Coval Tested-by: jenkins-iotivity Reviewed-by: Dan Mihai --- extlibs/gtest/SConscript | 55 ++++++---------------- resource/csdk/stack/test/README | 6 +-- resource/unittests/README | 4 +- run.bat | 8 ++-- service/easy-setup/enrollee/unittests/SConscript | 5 +- .../mediator/richsdk/unittests/SConscript | 2 +- .../notification/cpp-wrapper/unittest/SConscript | 2 +- service/notification/unittest/SConscript | 2 +- tools/scons/RunTest.py | 2 +- 9 files changed, 31 insertions(+), 55 deletions(-) diff --git a/extlibs/gtest/SConscript b/extlibs/gtest/SConscript index d127ccf..d0ccbae 100644 --- a/extlibs/gtest/SConscript +++ b/extlibs/gtest/SConscript @@ -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') diff --git a/resource/csdk/stack/test/README b/resource/csdk/stack/test/README index 7d08f04..7b727e5 100644 --- a/resource/csdk/stack/test/README +++ b/resource/csdk/stack/test/README @@ -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 /extlibs/gtest/gtest-1.7.0/lib/.libs/ to LD_LIBRARY_PATH +add /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////resource/csdk/stack/test diff --git a/resource/unittests/README b/resource/unittests/README index 3794765..5a34cf6 100644 --- a/resource/unittests/README +++ b/resource/unittests/README @@ -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 /extlibs/gtest/gtest-1.7.0/lib/.libs/ to LD_LIBRARY_PATH +add /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////resource/unittests/unittests diff --git a/run.bat b/run.bat index 578005b..c40c469 100644 --- 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 diff --git a/service/easy-setup/enrollee/unittests/SConscript b/service/easy-setup/enrollee/unittests/SConscript index 399cb12..d7ff5fe 100644 --- a/service/easy-setup/enrollee/unittests/SConscript +++ b/service/easy-setup/enrollee/unittests/SConscript @@ -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') diff --git a/service/easy-setup/mediator/richsdk/unittests/SConscript b/service/easy-setup/mediator/richsdk/unittests/SConscript index 986ace1..40c6a00 100644 --- a/service/easy-setup/mediator/richsdk/unittests/SConscript +++ b/service/easy-setup/mediator/richsdk/unittests/SConscript @@ -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') diff --git a/service/notification/cpp-wrapper/unittest/SConscript b/service/notification/cpp-wrapper/unittest/SConscript index af0b2a5..a6adca8 100644 --- a/service/notification/cpp-wrapper/unittest/SConscript +++ b/service/notification/cpp-wrapper/unittest/SConscript @@ -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') diff --git a/service/notification/unittest/SConscript b/service/notification/unittest/SConscript index a0aae39..1730cb6 100644 --- a/service/notification/unittest/SConscript +++ b/service/notification/unittest/SConscript @@ -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') diff --git a/tools/scons/RunTest.py b/tools/scons/RunTest.py index f814bd5..301370e 100644 --- a/tools/scons/RunTest.py +++ b/tools/scons/RunTest.py @@ -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) -- 2.7.4