From 6d6cc89bdafb20681e498a9266466d8772826d0b Mon Sep 17 00:00:00 2001 From: Pawel Winogrodzki Date: Thu, 12 Jan 2017 18:51:32 -0800 Subject: [PATCH] IOT-1749: Enabling multi-threaded builds in Windows. I've modified the global env configuration and run.bat in order to make parallel builds possible and generate private symbols files at the same time. Change-Id: I770b5a57e4fb8b437b727d7937f37a411e2f6cca Signed-off-by: Pawel Winogrodzki Reviewed-on: https://gerrit.iotivity.org/gerrit/16553 Tested-by: jenkins-iotivity Reviewed-by: Dan Mihai --- build_common/windows/SConscript | 4 +++- plugins/unittests/SConscript | 3 ++- .../csdk/resource-directory/unittests/SConscript | 3 ++- resource/provisioning/unittests/SConscript | 3 ++- resource/unittests/SConscript | 3 ++- run.bat | 23 ++++++++++++++++------ service/easy-setup/enrollee/unittests/SConscript | 3 ++- .../mediator/richsdk/unittests/SConscript | 3 ++- .../notification/cpp-wrapper/unittest/SConscript | 6 ++++-- service/notification/unittest/SConscript | 6 ++++-- service/resource-container/unittests/SConscript | 3 ++- .../resource-encapsulation/src/common/SConscript | 3 ++- .../src/resourceBroker/unittest/SConscript | 3 ++- .../src/resourceCache/unittests/SConscript | 3 ++- .../src/serverBuilder/SConscript | 3 ++- .../resource-encapsulation/unittests/SConscript | 3 ++- service/scene-manager/unittests/SConscript | 3 ++- tools/scons/RunTest.py | 5 +++-- 18 files changed, 57 insertions(+), 26 deletions(-) diff --git a/build_common/windows/SConscript b/build_common/windows/SConscript index 8bf77a7..d47680b 100644 --- a/build_common/windows/SConscript +++ b/build_common/windows/SConscript @@ -30,10 +30,12 @@ if env['CC'] == 'cl': env.AppendUnique(CCFLAGS = ['/MD', '/O2', '/GF']) env.AppendUnique(CPPDEFINES = ['NDEBUG']) else: - env.AppendUnique(CCFLAGS = ['/MDd', '/Od', '/Zi', '/RTC1', '/Gm']) + env.AppendUnique(CCFLAGS = ['/MDd', '/Od', '/RTC1']) env.AppendUnique(LINKFLAGS = ['/debug']) env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')]) env.AppendUnique(PATH = os.environ['PATH']) + env['PDB'] = '${TARGET.base}.pdb' + env.Append(LINKFLAGS=['/PDB:${TARGET.base}.pdb']) # Add Windows-specific libraries env.AppendUnique(LIBS = ['bcrypt', 'ws2_32', 'advapi32', 'iphlpapi', 'crypt32', 'kernel32']) diff --git a/plugins/unittests/SConscript b/plugins/unittests/SConscript index 06b3e66..c1391df 100644 --- a/plugins/unittests/SConscript +++ b/plugins/unittests/SConscript @@ -62,5 +62,6 @@ if unittests_env.get('TEST') == '1': from tools.scons.RunTest import * run_test(unittests_env, 'plugins_unittests.memcheck', - 'plugins/unittests/piunittests') + 'plugins/unittests/piunittests', + piunittests) diff --git a/resource/csdk/resource-directory/unittests/SConscript b/resource/csdk/resource-directory/unittests/SConscript index de50bfd..74c09ed 100644 --- a/resource/csdk/resource-directory/unittests/SConscript +++ b/resource/csdk/resource-directory/unittests/SConscript @@ -92,4 +92,5 @@ if rd_test_env.get('TEST') == '1': if target_os in ['linux']: run_test(rd_test_env, 'resource_csdk_resource-directory_unittests_rdtests.memcheck', - 'resource/csdk/resource-directory/unittests/rdtests') + 'resource/csdk/resource-directory/unittests/rdtests', + rd_client_test) diff --git a/resource/provisioning/unittests/SConscript b/resource/provisioning/unittests/SConscript index b77da02..9a3f1b9 100755 --- a/resource/provisioning/unittests/SConscript +++ b/resource/provisioning/unittests/SConscript @@ -110,7 +110,8 @@ if provisiontests_env.get('TEST') == '1': provisiontests_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir]) run_test(provisiontests_env, 'resource/provisioning/unittests/provisiontests.memcheck', - 'resource/provisioning/unittests/provisiontests') + 'resource/provisioning/unittests/provisiontests', + unittests) src_dir = provisiontests_env.get('SRC_DIR') svr_db_src_dir = src_dir + '/resource/provisioning/examples/' diff --git a/resource/unittests/SConscript b/resource/unittests/SConscript index 11fc02c..710c18f 100644 --- a/resource/unittests/SConscript +++ b/resource/unittests/SConscript @@ -114,7 +114,8 @@ if unittests_env.get('TEST') == '1': if target_os in ['linux', 'windows']: run_test(unittests_env, 'resource_unittests_unittests.memcheck', - 'resource/unittests/unittests') + 'resource/unittests/unittests', + unittests) src_dir = unittests_env.get('SRC_DIR') svr_db_src_dir = os.path.join(src_dir, 'resource/examples/') diff --git a/run.bat b/run.bat index 34305c8..12631e8 100644 --- a/run.bat +++ b/run.bat @@ -33,6 +33,7 @@ if "%RELEASE%" == "" ( set RELEASE=0 ) +set THREAD_COUNT=%NUMBER_OF_PROCESSORS% set SECURED=1 set ROUTING=EP set WITH_TCP=1 @@ -51,6 +52,10 @@ IF NOT "%1"=="" ( SET TARGET_ARCH=%2 SHIFT ) + IF "%1"=="-threads" ( + SET THREAD_COUNT=%2 + SHIFT + ) IF "%1"=="-noTest" ( SET TEST=0 ) @@ -81,7 +86,7 @@ IF "%BUILD_MSYS%" == "" ( set PATH=!PATH!;!BUILD_DIR!;C:\msys64\mingw64\bin ) -set BUILD_OPTIONS= TARGET_OS=%TARGET_OS% TARGET_ARCH=%TARGET_ARCH% RELEASE=%RELEASE% WITH_RA=0 TARGET_TRANSPORT=IP SECURED=%SECURED% WITH_TCP=%WITH_TCP% BUILD_SAMPLE=ON LOGGING=%LOGGING% TEST=%TEST% RD_MODE=CLIENT ROUTING=%ROUTING% WITH_UPSTREAM_LIBCOAP=%WITH_UPSTREAM_LIBCOAP% MULTIPLE_OWNER=%MULTIPLE_OWNER% +set BUILD_OPTIONS= TARGET_OS=%TARGET_OS% TARGET_ARCH=%TARGET_ARCH% RELEASE=%RELEASE% WITH_RA=0 TARGET_TRANSPORT=IP SECURED=%SECURED% WITH_TCP=%WITH_TCP% BUILD_SAMPLE=ON LOGGING=%LOGGING% TEST=%TEST% RD_MODE=CLIENT ROUTING=%ROUTING% WITH_UPSTREAM_LIBCOAP=%WITH_UPSTREAM_LIBCOAP% MULTIPLE_OWNER=%MULTIPLE_OWNER% -j %THREAD_COUNT% REM Use MSVC_VERSION=12.0 for VS2013, or MSVC_VERSION=14.0 for VS2015. REM If MSVC_VERSION has not been defined here, SCons chooses automatically a VS version. @@ -148,6 +153,7 @@ if "!RUN_ARG!"=="server" ( echo WITH_UPSTREAM_LIBCOAP=%WITH_UPSTREAM_LIBCOAP% echo MULTIPLE_OWNER=%MULTIPLE_OWNER% echo MSVC_VERSION=%MSVC_VERSION% + echo THREAD_COUNT=%THREAD_COUNT% echo.scons VERBOSE=1 %BUILD_OPTIONS% scons VERBOSE=1 %BUILD_OPTIONS% ) else if "!RUN_ARG!"=="clean" ( @@ -183,15 +189,17 @@ echo. Default build settings are: debug binaries run unittests and no logging echo. echo. Default build parameters can be overridden using the following arguments echo. -echo -arch [x86 ^| amd64] - Build either amd64 or x86 architecture binaries +echo -arch [x86 ^| amd64] - Build either amd64 or x86 architecture binaries echo. -echo -noTest - Don't run the unittests after building the binaries +echo -noTest - Don't run the unittests after building the binaries echo. -echo -logging - Enable logging while building the binaries +echo -logging - Enable logging while building the binaries echo. -echo -debugger - Debug the requested application +echo -debugger - Debug the requested application echo. -echo -release - Build release binaries +echo -release - Build release binaries +echo. +echo -threads [NUMBER_OF_THREADS] - Build in parallel using [NUMBER_OF_THREADS] threads. Default: %NUMBER_OF_PROCESSORS%. echo. echo. Usage examples: echo Launch SimpleClient with debugger: @@ -215,6 +223,9 @@ echo. echo Build amd64 release binaries with logging enabled: echo %0 build -arch amd64 -release -logging echo. +echo Build using only one thread: +echo %0 build -threads 1 +echo. echo Run all tests: echo %0 test echo. diff --git a/service/easy-setup/enrollee/unittests/SConscript b/service/easy-setup/enrollee/unittests/SConscript index 724fa8d..48044a5 100644 --- a/service/easy-setup/enrollee/unittests/SConscript +++ b/service/easy-setup/enrollee/unittests/SConscript @@ -94,4 +94,5 @@ if env.get('TEST') == '1': if target_os in []: run_test(easysetup_enrollee_test_env, 'service_easy-setup_enrollee_unittests_easysetup_enrollee_test.memcheck', - 'service/easy-setup/enrollee/unittests/easysetup_enrollee_test') + 'service/easy-setup/enrollee/unittests/easysetup_enrollee_test', + easysetup_enrollee_test) diff --git a/service/easy-setup/mediator/richsdk/unittests/SConscript b/service/easy-setup/mediator/richsdk/unittests/SConscript index 14bbf42..50350d5 100644 --- a/service/easy-setup/mediator/richsdk/unittests/SConscript +++ b/service/easy-setup/mediator/richsdk/unittests/SConscript @@ -92,4 +92,5 @@ if env.get('TEST') == '1': run_test(easysetup_mediator_test_env, # 'service_easy-setup_mediator_richsdk_unittests_easysetup_mediator_test.memcheck', '', - 'service/easy-setup/mediator/richsdk/unittests/easysetup_mediator_test') + 'service/easy-setup/mediator/richsdk/unittests/easysetup_mediator_test', + easysetup_mediator_test) diff --git a/service/notification/cpp-wrapper/unittest/SConscript b/service/notification/cpp-wrapper/unittest/SConscript index 5dbc6d1..ab047ed 100644 --- a/service/notification/cpp-wrapper/unittest/SConscript +++ b/service/notification/cpp-wrapper/unittest/SConscript @@ -106,8 +106,10 @@ if env.get('TEST') == '1': '', # 'service_notification_cpp-wrapper_unittest_notification_consumer_wrapper_test.memcheck', - 'service/notification/cpp-wrapper/unittest/notification_consumer_wrapper_test') + 'service/notification/cpp-wrapper/unittest/notification_consumer_wrapper_test', + notification_consumer_wrapper_test) run_test(notification_provider_wrapper_test_env, '', # 'service_notification_cpp-wrapper_unittest_notification_provider_wrapper_test.memcheck', - 'service/notification/cpp-wrapper/unittest/notification_provider_wrapper_test') + 'service/notification/cpp-wrapper/unittest/notification_provider_wrapper_test', + notification_provider_wrapper_test) diff --git a/service/notification/unittest/SConscript b/service/notification/unittest/SConscript index b4d0b42..e011ee6 100644 --- a/service/notification/unittest/SConscript +++ b/service/notification/unittest/SConscript @@ -100,8 +100,10 @@ if env.get('TEST') == '1': run_test(notification_consumer_test_env, # 'service_notification_unittest_notification_consumer_test.memcheck', '', - 'service/notification/unittest/notification_consumer_test') + 'service/notification/unittest/notification_consumer_test', + notification_consumer_test) run_test(notification_provider_test_env, # 'service_notification_unittest_notification_provider_test.memcheck', '', - 'service/notification/unittest/notification_provider_test') + 'service/notification/unittest/notification_provider_test', + notification_provider_test) diff --git a/service/resource-container/unittests/SConscript b/service/resource-container/unittests/SConscript index 65f27bb..dab7ddd 100644 --- a/service/resource-container/unittests/SConscript +++ b/service/resource-container/unittests/SConscript @@ -186,4 +186,5 @@ if container_gtest_env.get('TEST') == '1': run_test(container_gtest_env, # 'service_resource-container_unittests_container_test.memcheck', '', - 'service/resource-container/unittests/container_test') + 'service/resource-container/unittests/container_test', + container_test) diff --git a/service/resource-encapsulation/src/common/SConscript b/service/resource-encapsulation/src/common/SConscript index 16b7550..a2033ee 100644 --- a/service/resource-encapsulation/src/common/SConscript +++ b/service/resource-encapsulation/src/common/SConscript @@ -123,4 +123,5 @@ if target_os in ['linux']: run_test(rcs_common_test_env, # 'service_resource-encapsulation_src_common_rcs_common_test.memcheck', '', - 'service/resource-encapsulation/src/common/rcs_common_test') + 'service/resource-encapsulation/src/common/rcs_common_test', + rcs_common_test) diff --git a/service/resource-encapsulation/src/resourceBroker/unittest/SConscript b/service/resource-encapsulation/src/resourceBroker/unittest/SConscript index 3487bb7..f1d1c64 100644 --- a/service/resource-encapsulation/src/resourceBroker/unittest/SConscript +++ b/service/resource-encapsulation/src/resourceBroker/unittest/SConscript @@ -89,4 +89,5 @@ if broker_test_env.get('TEST') == '1': # TODO: fix this test on linux and remove commented lines # 'service_resource-encapsulation_src_resourceBroker_unittest_broker_test.memcheck', '', - 'service/resource-encapsulation/src/resourceBroker/unittest/broker_test') + 'service/resource-encapsulation/src/resourceBroker/unittest/broker_test', + broker_test) diff --git a/service/resource-encapsulation/src/resourceCache/unittests/SConscript b/service/resource-encapsulation/src/resourceCache/unittests/SConscript index 44033f2..de41905 100644 --- a/service/resource-encapsulation/src/resourceCache/unittests/SConscript +++ b/service/resource-encapsulation/src/resourceCache/unittests/SConscript @@ -79,4 +79,5 @@ if cache_test_env.get('TEST') == '1': from tools.scons.RunTest import run_test run_test(cache_test_env, 'service_resource-encapsulation_src_resourceCache_unittests_cache_test.memtest', - 'service/resource-encapsulation/src/resourceCache/unittests/cache_test') + 'service/resource-encapsulation/src/resourceCache/unittests/cache_test', + cache_test) diff --git a/service/resource-encapsulation/src/serverBuilder/SConscript b/service/resource-encapsulation/src/serverBuilder/SConscript index dde651b..e0364e2 100644 --- a/service/resource-encapsulation/src/serverBuilder/SConscript +++ b/service/resource-encapsulation/src/serverBuilder/SConscript @@ -113,4 +113,5 @@ if target_os in ['linux']: # TODO: fix this test on linux and remove commented lines '', # 'service_resource-encapsulation_src_serverBuilder_rcs_server_test.memcheck', - 'service/resource-encapsulation/src/serverBuilder/rcs_server_test') + 'service/resource-encapsulation/src/serverBuilder/rcs_server_test', + server_builder_test) diff --git a/service/resource-encapsulation/unittests/SConscript b/service/resource-encapsulation/unittests/SConscript index bc8e85d..7a5b8ca 100644 --- a/service/resource-encapsulation/unittests/SConscript +++ b/service/resource-encapsulation/unittests/SConscript @@ -93,4 +93,5 @@ if rcs_test_env.get('TEST') == '1': run_test(rcs_test_env, # 'service_resource-encapsulation_unittests_rcs_client_test.memcheck', '', - 'service/resource-encapsulation/unittests/rcs_client_test') + 'service/resource-encapsulation/unittests/rcs_client_test', + rcs_client_test) diff --git a/service/scene-manager/unittests/SConscript b/service/scene-manager/unittests/SConscript index f4cdb47..c79227a 100644 --- a/service/scene-manager/unittests/SConscript +++ b/service/scene-manager/unittests/SConscript @@ -124,4 +124,5 @@ scene_test_env.AppendTarget('remote_scene_action_test') # from tools.scons.RunTest import * # run_test(scene_test_env, # '', -# 'service/scene-manager/unittest/scene_test') +# 'service/scene-manager/unittest/scene_test', +# remote_scene_action_test) diff --git a/tools/scons/RunTest.py b/tools/scons/RunTest.py index 2d56dbe..fbf1ebd 100644 --- a/tools/scons/RunTest.py +++ b/tools/scons/RunTest.py @@ -16,7 +16,7 @@ import os -def run_test(env, xml_file, test): +def run_test(env, xml_file, test, test_targets = ['test']): """ Run test with the given SCons Environment, dumping Valgrind results to the given XML file. If no Valgrind run is desired @@ -65,4 +65,5 @@ def run_test(env, xml_file, test): if env.get('TARGET_OS') in ['linux']: env.Depends('ut' + test , os.path.join(build_dir, test)) ut = env.Command('ut' + test, None, test_cmd) - env.AlwaysBuild('ut' + test) + env.Depends(ut, test_targets) + env.AlwaysBuild(ut) -- 2.7.4