IOT-1749: Enabling multi-threaded builds in Windows. 53/16553/10
authorPawel Winogrodzki <pawelwi@microsoft.com>
Fri, 13 Jan 2017 02:51:32 +0000 (18:51 -0800)
committerDan Mihai <Daniel.Mihai@microsoft.com>
Tue, 24 Jan 2017 15:26:07 +0000 (15:26 +0000)
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 <pawelwi@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/16553
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
18 files changed:
build_common/windows/SConscript
plugins/unittests/SConscript
resource/csdk/resource-directory/unittests/SConscript
resource/provisioning/unittests/SConscript
resource/unittests/SConscript
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
service/resource-container/unittests/SConscript
service/resource-encapsulation/src/common/SConscript
service/resource-encapsulation/src/resourceBroker/unittest/SConscript
service/resource-encapsulation/src/resourceCache/unittests/SConscript
service/resource-encapsulation/src/serverBuilder/SConscript
service/resource-encapsulation/unittests/SConscript
service/scene-manager/unittests/SConscript
tools/scons/RunTest.py

index 8bf77a7..d47680b 100644 (file)
@@ -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'])
index 06b3e66..c1391df 100644 (file)
@@ -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)
 
index de50bfd..74c09ed 100644 (file)
@@ -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)
index b77da02..9a3f1b9 100755 (executable)
@@ -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/'
index 11fc02c..710c18f 100644 (file)
@@ -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 (file)
--- 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.
index 724fa8d..48044a5 100644 (file)
@@ -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)
index 14bbf42..50350d5 100644 (file)
@@ -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)
index 5dbc6d1..ab047ed 100644 (file)
@@ -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)
index b4d0b42..e011ee6 100644 (file)
@@ -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)
index 65f27bb..dab7ddd 100644 (file)
@@ -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)
index 16b7550..a2033ee 100644 (file)
@@ -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)
index 3487bb7..f1d1c64 100644 (file)
@@ -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)
index 44033f2..de41905 100644 (file)
@@ -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)
index dde651b..e0364e2 100644 (file)
@@ -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)
index bc8e85d..7a5b8ca 100644 (file)
@@ -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)
index f4cdb47..c79227a 100644 (file)
@@ -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)
index 2d56dbe..fbf1ebd 100644 (file)
@@ -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)