Update build scripts for changes to RD for Windows
authorMike Fenelon <mike.fenelon@microsoft.com>
Mon, 31 Oct 2016 22:27:55 +0000 (15:27 -0700)
committerHabib Virji <habib.virji@samsung.com>
Thu, 3 Nov 2016 10:15:12 +0000 (10:15 +0000)
These changes allow Windows to build correctly with
Resource Directory code. Changes from WITH_RD to RD_MODE were
introduced in early October, but the RUN.BAT file that builds
Windows was not updated, so Windows has been building with a
broken mix of RD and not RD to this point. Changes to RUN.BAT and
SCONS scripts bring Windows builds up-to-date.

Change-Id: I9ba789a11fa0ca1865822578f7da8d4a56439660
Signed-off-by: Mike Fenelon <mike.fenelon@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/13905
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Dave Thaler <dthaler@microsoft.com>
Reviewed-by: Habib Virji <habib.virji@samsung.com>
Readme.scons.txt
resource/csdk/SConscript
resource/csdk/connectivity/test/SConscript
resource/csdk/security/provisioning/unittest/SConscript
resource/csdk/security/unittest/SConscript
resource/csdk/stack/test/SConscript
run.bat

index 1c2d0dd..cc56b27 100644 (file)
@@ -252,32 +252,38 @@ IOS:
     -> Building for a specific transport :
     $ scons TARGET_OS=ios TARGET_ARCH=xxx SYS_VERSION=yyy
 
+Windows:
+ * Possible values for <TARGET_ARCH> are: x86, amd64
+
+For convenience to build projects supported on Windows a batch file (run.bat) is provided
+to run many build combinations with TARGET_OS to 'windows'.
+
+1. Go to root directory
+    $ cd <top directory of the project>
+2. To clean before building:
+      $ run clean
+3. To build debug amd64 binaries:
+      $ run build
+4. To build x86 release/retail binaries and run unit tests:
+      $ run build -arch x86 -release
+See run.bat for more example usage parameters
+
 * Additional options
  * VERBOSE=true or false (Show compilation)
  * RELEASE=true or false (Build for release?)
  * LOGGING=true or false (Enable stack logging)
  * SECURED=1 or 0 (Build with DTLS)
  * TEST=1 or 0 (Run unit tests)
- * SECURED=1 or 0 (Build with DTLS)
  * BUILD_SAMPLE=ON or OFF (Build with sample)
  * ROUTING=GW or EP (Enable routing)
  * WITH_TCP=true or false (Enable CoAP over TCP Transport, arduino is not supported)
  * WITH_RA=true or false (Build with Remote Access module)
- * WITH_RD=1 or 0 (Build including Resource Directory)
+ * RD_MODE=CLIENT or SERVER (Build including Resource Directory)
  * SIMULATOR=true or false (Build with simulator module)
  * Possible values for <WITH_MQ> are: PUB,SUB,BROKER (Build including Message Queue)
    -> PUB : publisher, SUB : subscriber, BROKER : MQ broker(not supported yet)
 
-Note1: Currently most IoTivity project doesn't support Windows, so you can't set
-TARGET_OS to 'windows' except the project support Windows.
-
-That's to say if the project doesn't support Windows, run:
-      $ scons TARGET_OS=windows ....
-or run on Windows
-      $ scons
-may always fail.
-
-Note2:
+Note:
 1) for convenience, a script (auto_build.sh) is provided to run possible build
 at once. Following is the usage:
 
index fc48143..17f67fd 100644 (file)
@@ -147,14 +147,15 @@ if liboctbstack_env.get('ROUTING') in ['GW', 'EP']:
        liboctbstack_env.Prepend(LIBS = ['routingmanager'])
 
 if 'CLIENT' in rd_mode or 'SERVER' in rd_mode:
-    if 'CLIENT' in rd_mode:
-        liboctbstack_env.AppendUnique(CPPDEFINES = ['RD_CLIENT'])
-    if 'SERVER' in rd_mode:
-        liboctbstack_env.AppendUnique(CPPDEFINES = ['RD_SERVER'])
-        if target_os in ['tizen']:
-            liboctbstack_env.ParseConfig('pkg-config --cflags --libs sqlite3')
-        else:
-            liboctbstack_env.AppendUnique(CPPPATH = ['#extlibs/sqlite3'])
+       liboctbstack_env.PrependUnique(CPPPATH = ['resource-directory/include'])
+       if 'CLIENT' in rd_mode:
+               liboctbstack_env.AppendUnique(CPPDEFINES = ['RD_CLIENT'])
+       if 'SERVER' in rd_mode:
+               liboctbstack_env.AppendUnique(CPPDEFINES = ['RD_SERVER'])
+               if target_os in ['tizen']:
+                       liboctbstack_env.ParseConfig('pkg-config --cflags --libs sqlite3')
+               else:
+                       liboctbstack_env.AppendUnique(CPPPATH = ['#extlibs/sqlite3'])
 
 ######################################################################
 # Source files and Targets
index ff90148..004f8d5 100644 (file)
@@ -26,6 +26,7 @@ gtest_env = SConscript('#extlibs/gtest/SConscript')
 catest_env = gtest_env.Clone()
 target_os = catest_env.get('TARGET_OS')
 target_transport = catest_env.get('TARGET_TRANSPORT')
+rd_mode = catest_env.get('RD_MODE')
 
 ######################################################################
 # Build flags
@@ -48,7 +49,7 @@ if target_os not in ['arduino', 'darwin', 'ios', 'msys_nt', 'windows']:
 if catest_env.get('SECURED') == '1':
        catest_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509','mbedcrypto'])
 
-if catest_env.get('WITH_RD') == '1':
+if 'CLIENT' in rd_mode or 'SERVER' in rd_mode:
        catest_env.PrependUnique(LIBS = ['resource_directory'])
 
 if catest_env.get('LOGGING'):
index 5145d09..ffe2fc2 100644 (file)
@@ -26,6 +26,7 @@ gtest_env = SConscript('#extlibs/gtest/SConscript')
 sptest_env = gtest_env.Clone()
 src_dir = sptest_env.get('SRC_DIR')
 target_os = sptest_env.get('TARGET_OS')
+rd_mode = sptest_env.get('RD_MODE')
 
 ######################################################################
 # Build flags
@@ -88,6 +89,9 @@ if target_os in ['msys_nt', 'windows']:
 else:
        sptest_env.AppendUnique(LIBS = ['octbstack'])
 
+if 'CLIENT' in rd_mode or 'SERVER' in rd_mode:
+       sptest_env.PrependUnique(LIBS = ['resource_directory'])
+
 ######################################################################
 # Source files and Targets
 ######################################################################
index dcf9014..fd67ede 100644 (file)
@@ -26,6 +26,7 @@ gtest_env = SConscript('#extlibs/gtest/SConscript')
 srmtest_env = gtest_env.Clone()
 src_dir = srmtest_env.get('SRC_DIR')
 target_os = srmtest_env.get('TARGET_OS')
+rd_mode = srmtest_env.get('RD_MODE')
 
 ######################################################################
 # Build flags
@@ -79,6 +80,9 @@ else:
        srmtest_env.AppendUnique(CPPDEFINES = ['HAVE_LOCALTIME_R'])
        srmtest_env.AppendUnique(LIBS = ['octbstack'])
 
+if 'CLIENT' in rd_mode or 'SERVER' in rd_mode:
+       srmtest_env.PrependUnique(LIBS = ['resource_directory'])
+
 ######################################################################
 # Source files and Targets
 ######################################################################
index cf34456..cf836ec 100644 (file)
@@ -25,6 +25,7 @@ import os.path
 gtest_env = SConscript('#extlibs/gtest/SConscript')
 stacktest_env = gtest_env.Clone()
 target_os = stacktest_env.get('TARGET_OS')
+rd_mode = stacktest_env.get('RD_MODE')
 
 ######################################################################
 # Build flags
@@ -63,6 +64,9 @@ if target_os in ['msys_nt', 'windows']:
 else:
        stacktest_env.PrependUnique(LIBS = ['m'])
 
+if 'CLIENT' in rd_mode or 'SERVER' in rd_mode:
+       stacktest_env.PrependUnique(LIBS = ['resource_directory'])
+
 ######################################################################
 # Source files and Targets
 ######################################################################
diff --git a/run.bat b/run.bat
index 1c7b1c9..a320b45 100644 (file)
--- a/run.bat
+++ b/run.bat
@@ -34,7 +34,6 @@ if "%RELEASE%" == "" (
 )
 
 set SECURED=1
-set WITH_RD=1
 set ROUTING=EP
 set WITH_UPSTREAM_LIBCOAP=1
 
@@ -75,7 +74,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=0 BUILD_SAMPLE=ON LOGGING=%LOGGING% TEST=%TEST% WITH_RD=%WITH_RD% ROUTING=%ROUTING% WITH_UPSTREAM_LIBCOAP=%WITH_UPSTREAM_LIBCOAP%
+set BUILD_OPTIONS= TARGET_OS=%TARGET_OS% TARGET_ARCH=%TARGET_ARCH% RELEASE=%RELEASE% WITH_RA=0 TARGET_TRANSPORT=IP SECURED=%SECURED% WITH_TCP=0 BUILD_SAMPLE=ON LOGGING=%LOGGING% TEST=%TEST% RD_MODE=CLIENT ROUTING=%ROUTING% WITH_UPSTREAM_LIBCOAP=%WITH_UPSTREAM_LIBCOAP%
 
 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.
@@ -137,7 +136,6 @@ if "!RUN_ARG!"=="server" (
   echo   RELEASE=%RELEASE%
   echo   TEST=%TEST%
   echo   LOGGING=%LOGGING%
-  echo   WITH_RD=%WITH_RD%
   echo   ROUTING=%ROUTING%
   echo   WITH_UPSTREAM_LIBCOAP=%WITH_UPSTREAM_LIBCOAP%
   echo   MSVC_VERSION=%MSVC_VERSION%