build: Reformat resource/csdk to be more Pythonic
authorMats Wichmann <mats@linux.com>
Mon, 12 Jun 2017 14:13:42 +0000 (08:13 -0600)
committerPhil Coval <philippe.coval@osg.samsung.com>
Wed, 28 Jun 2017 21:20:22 +0000 (21:20 +0000)
[Mats Wichmann]

Reformat resource/csdk SConscripts to be more Pythonic 2/4

These are the resource/csdk/stack subset

There are not intended to be any functional changes, with a minor
exception: in resource/csdk/stack/samples/linux/secure/SConscript,
the samples are now assigned to an appropriately constructed list,
which is assigned an Alias, rather than two similar but different
conditional Alias lines with the list inline.

There is no consistently "pretty" way to fold long lines,
the choices were made by a tool (yapf) but occasionally
overridden to be a little more consistent

The test harness is now consistently imported as:
  from tools.scons.RunTest import run_test
rather than import * - should normally avoid importing whole
namespace unqualified unless it is really needed

[Philippe Coval]

Merge from master to 1.3-rel

Conflicts:
resource/csdk/stack/samples/arduino/SimpleClientServer/ocserver/SConscript
resource/csdk/stack/samples/tizen/build/SConscript
resource/csdk/stack/samples/tizen/build/scons/SConscript
resource/csdk/stack/test/SConscript

Change-Id: I0e15b375a052ef792b2a1c4470552e5e0e4fb3fc
Signed-off-by: Mats Wichmann <mats@linux.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/20697
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
Origin: master
Bug: https://jira.iotivity.org/browse/IOT-1745
Signed-off-by: Phil Coval <philippe.coval@osg.samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/20909
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-by: George Nash <george.nash@intel.com>
resource/csdk/stack/SConscript
resource/csdk/stack/samples/SConscript
resource/csdk/stack/samples/arduino/SimpleClientServer/ocserver/SConscript
resource/csdk/stack/samples/linux/OCSample/SConscript
resource/csdk/stack/samples/linux/SimpleClientServer/SConscript
resource/csdk/stack/samples/linux/secure/SConscript
resource/csdk/stack/samples/tizen/SimpleClientServer/SConscript
resource/csdk/stack/samples/tizen/SimpleClientServer/scons/SConscript
resource/csdk/stack/samples/tizen/build/SConscript
resource/csdk/stack/samples/tizen/build/scons/SConscript
resource/csdk/stack/test/SConscript

index a1535ba..ff706ed 100644 (file)
@@ -27,9 +27,11 @@ import os
 liboctbstack_env = env.Clone()
 
 # Build C Samples
-SConscript('samples/SConscript', exports = { 'stacksamples_env' : liboctbstack_env })
+SConscript('samples/SConscript',
+           exports={'stacksamples_env': liboctbstack_env})
 
-SConscript('#resource/third_party_libs.scons', exports = { 'lib_env' : liboctbstack_env })
+SConscript('#/resource/third_party_libs.scons',
+           exports={'lib_env': liboctbstack_env})
 
 target_os = env.get('TARGET_OS')
 rd_mode = env.get('RD_MODE')
@@ -41,159 +43,187 @@ with_mq = env.get('WITH_MQ')
 # As in the source code, it includes arduino Time library (C++)
 # It requires compile the .c with g++
 if target_os == 'arduino':
-    liboctbstack_env.Replace(CC = env.get('CXX'))
-    liboctbstack_env.Replace(CFLAGS = env.get('CXXFLAGS'))
+    liboctbstack_env.Replace(CC=env.get('CXX'))
+    liboctbstack_env.Replace(CFLAGS=env.get('CXXFLAGS'))
 
 ######################################################################
 # Build flags
 ######################################################################
 with_upstream_libcoap = liboctbstack_env.get('WITH_UPSTREAM_LIBCOAP')
 if with_upstream_libcoap == '1':
-    liboctbstack_env.PrependUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
+    liboctbstack_env.PrependUnique(CPPPATH=['#extlibs/libcoap/libcoap/include'])
 else:
-    liboctbstack_env.PrependUnique(CPPPATH = ['#resource/csdk/connectivity/lib/libcoap-4.1.1/include'])
-
-liboctbstack_env.PrependUnique(CPPPATH = [
-        '#resource/c_common/octimer/include',
-        '#resource/c_common/ocatomic/include',
-        '#resource/csdk/logger/include',
-        '#resource/csdk/include',
-        'include',
-        'include/internal',
-        '#resource/oc_logger/include',
-        '#resource/csdk/connectivity/common/inc',
-        '#resource/csdk/connectivity/inc',
-        '#resource/csdk/connectivity/inc/pkix',
-        '#resource/csdk/connectivity/api',
-        '#resource/csdk/connectivity/external/inc',
-        '#resource/csdk/security/include',
-        '#resource/csdk/security/include/internal',
-        '#resource/csdk/security/provisioning/include',
-        '#resource/csdk/routing/include',
-        ])
+    liboctbstack_env.PrependUnique(CPPPATH=['#resource/csdk/connectivity/lib/libcoap-4.1.1/include'])
+
+liboctbstack_env.PrependUnique(CPPPATH=[
+    '#resource/c_common/octimer/include',
+    '#resource/c_common/ocatomic/include',
+    '#resource/csdk/logger/include',
+    '#resource/csdk/include',
+    'include',
+    'include/internal',
+    '#resource/oc_logger/include',
+    '#resource/csdk/connectivity/common/inc',
+    '#resource/csdk/connectivity/inc',
+    '#resource/csdk/connectivity/inc/pkix',
+    '#resource/csdk/connectivity/api',
+    '#resource/csdk/connectivity/external/inc',
+    '#resource/csdk/security/include',
+    '#resource/csdk/security/include/internal',
+    '#resource/csdk/security/provisioning/include',
+    '#resource/csdk/routing/include',
+])
 
 if 'SUB' in with_mq:
-    liboctbstack_env.AppendUnique(CPPDEFINES = ['MQ_SUBSCRIBER', 'WITH_MQ'])
+    liboctbstack_env.AppendUnique(CPPDEFINES=['MQ_SUBSCRIBER', 'WITH_MQ'])
 if 'PUB' in with_mq:
-    liboctbstack_env.AppendUnique(CPPDEFINES = ['MQ_PUBLISHER', 'WITH_MQ'])
+    liboctbstack_env.AppendUnique(CPPDEFINES=['MQ_PUBLISHER', 'WITH_MQ'])
 if 'BROKER' in with_mq:
-    liboctbstack_env.AppendUnique(CPPDEFINES = ['MQ_BROKER', 'WITH_MQ'])
+    liboctbstack_env.AppendUnique(CPPDEFINES=['MQ_BROKER', 'WITH_MQ'])
 
 if target_os not in ['arduino', 'windows']:
-    liboctbstack_env.AppendUnique(CPPDEFINES  = ['WITH_POSIX', '_GNU_SOURCE'])
-    liboctbstack_env.AppendUnique(CFLAGS = ['-std=c99'])
+    liboctbstack_env.AppendUnique(CPPDEFINES=['WITH_POSIX', '_GNU_SOURCE'])
+    liboctbstack_env.AppendUnique(CFLAGS=['-std=c99'])
 
 if liboctbstack_env.get('ROUTING') == 'GW':
-    liboctbstack_env.AppendUnique(CPPDEFINES = ['ROUTING_GATEWAY'])
+    liboctbstack_env.AppendUnique(CPPDEFINES=['ROUTING_GATEWAY'])
 elif liboctbstack_env.get('ROUTING') == 'EP':
-    liboctbstack_env.AppendUnique(CPPDEFINES = ['ROUTING_EP'])
+    liboctbstack_env.AppendUnique(CPPDEFINES=['ROUTING_EP'])
 
 if target_os not in ['windows']:
-    liboctbstack_env.AppendUnique(CFLAGS = ['-Wall'])
+    liboctbstack_env.AppendUnique(CFLAGS=['-Wall'])
 
-liboctbstack_env.PrependUnique(LIBS = ['ocsrm', 'coap'])
+liboctbstack_env.PrependUnique(LIBS=['ocsrm', 'coap'])
 
 if target_os in ['linux'] and liboctbstack_env.get('SIMULATOR', False):
-    liboctbstack_env.Append( RPATH = liboctbstack_env.Literal('\\$$ORIGIN'))
+    liboctbstack_env.Append(RPATH=liboctbstack_env.Literal('\\$$ORIGIN'))
 
 if env.get('SECURED') == '1':
-    liboctbstack_env.AppendUnique(LIBS = ['mbedtls','mbedx509'])
+    liboctbstack_env.AppendUnique(LIBS=['mbedtls', 'mbedx509'])
 
 # c_common calls into mbedcrypto.
-liboctbstack_env.AppendUnique(LIBS = ['mbedcrypto'])
+liboctbstack_env.AppendUnique(LIBS=['mbedcrypto'])
 
 if target_os in ['android', 'linux', 'tizen', 'msys_nt', 'windows']:
     if target_os not in ['windows', 'msys_nt']:
-        liboctbstack_env.PrependUnique(LIBS = ['connectivity_abstraction'])
+        liboctbstack_env.PrependUnique(LIBS=['connectivity_abstraction'])
     else:
         # On Windows, apps don't link directly with connectivity_abstraction.
         # connectivity_abstraction is linked inside octbstack.dll and apps
         # import its APIs by linking with octbstack.lib.
-        liboctbstack_env.PrependUnique(LIBS = ['connectivity_abstraction_internal'])
+        liboctbstack_env.PrependUnique(LIBS=['connectivity_abstraction_internal'])
 
     if with_ra_ibb:
-        liboctbstack_env.AppendUnique(LIBS = liboctbstack_env['RALIBS'], LIBPATH = liboctbstack_env['RALIBPATH'], RPATH = liboctbstack_env['RARPATH'])
-    else :
+        liboctbstack_env.AppendUnique(
+            LIBS=liboctbstack_env['RALIBS'],
+            LIBPATH=liboctbstack_env['RALIBPATH'],
+            RPATH=liboctbstack_env['RARPATH'])
+    else:
         if with_ra:
-            liboctbstack_env.AppendUnique(LIBS = ['ra_xmpp'])
+            liboctbstack_env.AppendUnique(LIBS=['ra_xmpp'])
 
 if target_os not in ['windows', 'msys_nt']:
-    liboctbstack_env.AppendUnique(LIBS = ['m'])
+    liboctbstack_env.AppendUnique(LIBS=['m'])
 else:
     # octbstack.def specifies the list of functions exported by octbstack.dll.
-    liboctbstack_env.Replace(WINDOWS_INSERT_DEF = ['1'])
+    liboctbstack_env.Replace(WINDOWS_INSERT_DEF=['1'])
 
     # On Windows, apps don't link directly with oc_logger. oc_logger is linked inside
     # octbstack.dll and apps import its APIs by linking with octbstack.lib.
-    liboctbstack_env.PrependUnique(LIBS = ['oc_logger_internal'])
+    liboctbstack_env.PrependUnique(LIBS=['oc_logger_internal'])
 
     if 'CLIENT' in rd_mode or 'SERVER' in rd_mode:
         # On Windows:
         # - octbstack.dll is exporting resource_directory C APIs
         # - resource_directory.lib contains just the implementation of the C++ RD APIs
-        liboctbstack_env.PrependUnique(LIBS = ['resource_directory_internal'])
+        liboctbstack_env.PrependUnique(LIBS=['resource_directory_internal'])
 
     if 'CLIENT' in rd_mode:
-        liboctbstack_env.Textfile(target = 'octbstack_temp1.def', source = [File('octbstack_product.def'), File('octbstack_rd_client.def')])
+        liboctbstack_env.Textfile(
+            target='octbstack_temp1.def',
+            source=[
+                File('octbstack_product.def'),
+                File('octbstack_rd_client.def')
+            ])
     else:
-        liboctbstack_env.Textfile(target = 'octbstack_temp1.def', source = [File('octbstack_product.def')])
+        liboctbstack_env.Textfile(
+            target='octbstack_temp1.def',
+            source=[File('octbstack_product.def')])
 
     if 'SERVER' in rd_mode:
-        liboctbstack_env.Textfile(target = 'octbstack_temp2.def', source = [File('octbstack_temp1.def'), File('octbstack_rd_server.def')])
+        liboctbstack_env.Textfile(
+            target='octbstack_temp2.def',
+            source=[
+                File('octbstack_temp1.def'),
+                File('octbstack_rd_server.def')
+            ])
     else:
-        liboctbstack_env.Textfile(target = 'octbstack_temp2.def', source = [File('octbstack_temp1.def')])
+        liboctbstack_env.Textfile(
+            target='octbstack_temp2.def', source=[File('octbstack_temp1.def')])
 
     if env.get('SECURED') != '1':
-        liboctbstack_env.Textfile(target = 'octbstack.def', source = [File('octbstack_temp2.def')])
+        liboctbstack_env.Textfile(
+            target='octbstack.def', source=[File('octbstack_temp2.def')])
     else:
         # On Windows, apps don't link directly with ocpmapi.lib. ocpmapi is linked
         # inside octbstack.dll and apps import its APIs by linking with octbstack.lib.
-        liboctbstack_env.PrependUnique(LIBS = ['ocpmapi_internal'])
+        liboctbstack_env.PrependUnique(LIBS=['ocpmapi_internal'])
 
-        liboctbstack_env.Textfile(target = 'octbstack_temp3.def', source = [File('octbstack_temp2.def'), File('octbstack_product_secured.def')])
+        liboctbstack_env.Textfile(
+            target='octbstack_temp3.def',
+            source=[
+                File('octbstack_temp2.def'),
+                File('octbstack_product_secured.def')
+            ])
 
         if env.get('MULTIPLE_OWNER') == '1':
-            liboctbstack_env.Textfile(target = 'octbstack.def', source = [File('octbstack_temp3.def'), File('octbstack_product_secured_mot.def')])
+            liboctbstack_env.Textfile(
+                target='octbstack.def',
+                source=[
+                    File('octbstack_temp3.def'),
+                    File('octbstack_product_secured_mot.def')
+                ])
         else:
-            liboctbstack_env.Textfile(target = 'octbstack.def', source = [File('octbstack_temp3.def')])
+            liboctbstack_env.Textfile(
+                target='octbstack.def', source=[File('octbstack_temp3.def')])
 
 if target_os in ['tizen', 'linux']:
     liboctbstack_env.ParseConfig("pkg-config --cflags --libs uuid")
     liboctbstack_env.ParseConfig('pkg-config --cflags --libs sqlite3')
 
 if target_os == 'arduino':
-    liboctbstack_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
-elif target_os not in ['darwin','ios', 'msys_nt', 'windows']:
-    liboctbstack_env.AppendUnique(CFLAGS = ['-fPIC'])
+    liboctbstack_env.AppendUnique(CPPDEFINES=['NDEBUG', 'WITH_ARDUINO'])
+elif target_os not in ['darwin', 'ios', 'msys_nt', 'windows']:
+    liboctbstack_env.AppendUnique(CFLAGS=['-fPIC'])
 if target_os in ['darwin', 'ios']:
-    env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
-    liboctbstack_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
+    env.AppendUnique(CPPDEFINES=['_DARWIN_C_SOURCE'])
+    liboctbstack_env.AppendUnique(CPPDEFINES=['_DARWIN_C_SOURCE'])
 if target_os not in ['arduino', 'windows']:
-    liboctbstack_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
+    liboctbstack_env.AppendUnique(LINKFLAGS=['-Wl,--no-undefined'])
 if target_os == 'android':
-    liboctbstack_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,liboctbstack.so'])
+    liboctbstack_env.AppendUnique(LINKFLAGS=['-Wl,-soname,liboctbstack.so'])
 
 if env.get('LOGGING'):
-    liboctbstack_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+    liboctbstack_env.AppendUnique(CPPDEFINES=['TB_LOG'])
 
 if liboctbstack_env.get('ROUTING') in ['GW', 'EP']:
-    liboctbstack_env.Prepend(LIBS = ['routingmanager'])
+    liboctbstack_env.Prepend(LIBS=['routingmanager'])
 
 if 'CLIENT' in rd_mode or 'SERVER' in rd_mode:
-    liboctbstack_env.PrependUnique(CPPPATH = ['#resource/csdk/resource-directory/include'])
+    liboctbstack_env.PrependUnique(CPPPATH=['#resource/csdk/resource-directory/include'])
 
     if target_os in ['windows']:
-        liboctbstack_env.AppendUnique(LIBS = ['sqlite3'])
+        liboctbstack_env.AppendUnique(LIBS=['sqlite3'])
 
     if 'CLIENT' in rd_mode:
-        liboctbstack_env.AppendUnique(CPPDEFINES = ['RD_CLIENT'])
+        liboctbstack_env.AppendUnique(CPPDEFINES=['RD_CLIENT'])
 
     if 'SERVER' in rd_mode:
-        liboctbstack_env.AppendUnique(CPPDEFINES = ['RD_SERVER'])
+        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.AppendUnique(CPPPATH=['#extlibs/sqlite3'])
 
 ######################################################################
 # Source files and Targets
@@ -211,7 +241,7 @@ liboctbstack_src = [
     OCTBSTACK_SRC + 'occollection.c',
     OCTBSTACK_SRC + 'oicgroup.c',
     OCTBSTACK_SRC + 'ocendpoint.c'
-    ]
+]
 
 if with_tcp == True:
     liboctbstack_src.append(OCTBSTACK_SRC + 'oickeepalive.c')
@@ -226,17 +256,20 @@ if 'SERVER' in rd_mode:
 if ((target_os in ['windows']) and (liboctbstack_env.get('UWP_APP') == '1')):
     liboctbstack_src.append(OCTBSTACK_SRC + 'ocsqlite3helper.c')
 
-internal_liboctbstack = liboctbstack_env.StaticLibrary('octbstack_internal', liboctbstack_src)
+internal_liboctbstack = liboctbstack_env.StaticLibrary(
+    'octbstack_internal', liboctbstack_src)
 octbstack_libs = Flatten(internal_liboctbstack)
 
-if target_os not in ['arduino', 'darwin', 'ios'] :
-    shared_liboctbstack = liboctbstack_env.SharedLibrary('octbstack', liboctbstack_src)
+if target_os not in ['arduino', 'darwin', 'ios']:
+    shared_liboctbstack = liboctbstack_env.SharedLibrary(
+        'octbstack', liboctbstack_src)
     octbstack_libs += Flatten(shared_liboctbstack)
     liboctbstack_env.UserInstallTargetHeader('include/ocstack.h', 'resource/stack', 'ocstack.h')
     liboctbstack_env.UserInstallTargetHeader('include/ocpresence.h', 'resource/stack', 'ocpresence.h')
 
 if target_os not in ['windows', 'msys_nt']:
-    static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
+    static_liboctbstack = liboctbstack_env.StaticLibrary(
+        'octbstack', liboctbstack_src)
     octbstack_libs += Flatten(static_liboctbstack)
 
 liboctbstack_env.InstallTarget(octbstack_libs, 'octbstack')
index b73f3a6..f5e9a60 100644 (file)
@@ -34,7 +34,8 @@ elif target_os == 'darwin':
     # Build linux samples for now
     SConscript('linux/SimpleClientServer/SConscript', 'stacksamples_env')
 elif target_os == 'arduino':
-    SConscript('arduino/SimpleClientServer/ocserver/SConscript', 'stacksamples_env')
+    SConscript('arduino/SimpleClientServer/ocserver/SConscript',
+               'stacksamples_env')
 elif target_os == 'msys_nt':
     # Build secure samples. Using linux samples for now.
     SConscript('linux/secure/SConscript', 'stacksamples_env')
index fc7ac11..08a6085 100644 (file)
@@ -28,22 +28,28 @@ transport = arduino_simplecs_env.get('TARGET_TRANSPORT')
 ######################################################################
 # Build flags
 ######################################################################
-arduino_simplecs_env.PrependUnique(CPPPATH = [
-               '../../../../../logger/include',
-               '../../../../../include',
-               '../../../../../stack/include',
-               '../../../../../../oc_logger/include'
-               ])
+arduino_simplecs_env.PrependUnique(CPPPATH=[
+    '../../../../../logger/include',
+    '../../../../../include',
+    '../../../../../stack/include',
+    '../../../../../../oc_logger/include'
+])
 
-arduino_simplecs_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+arduino_simplecs_env.AppendUnique(CPPDEFINES=['TB_LOG'])
 
-arduino_simplecs_env.PrependUnique(
-    LIBS = ['octbstack', 'ocsrm', 'routingmanager', 'connectivity_abstraction','coap'])
+arduino_simplecs_env.PrependUnique(LIBS=[
+    'octbstack',
+    'ocsrm',
+    'routingmanager',
+    'connectivity_abstraction',
+    'coap'
+])
 
 arduino_simplecs = arduino_simplecs_env.Program('SimpleClientServer', 'ocserver.cpp')
 arduino_simplecs_env.CreateBin('SimpleClientServer')
 
-i_arduino_simplecs = arduino_simplecs_env.Install(arduino_simplecs_env.get('BUILD_DIR'), arduino_simplecs)
+i_arduino_simplecs = arduino_simplecs_env.Install(
+    arduino_simplecs_env.get('BUILD_DIR'), arduino_simplecs)
 
 #The map file is intermediate file, make sure it's removed when clean build
 arduino_simplecs_env.Clean(arduino_simplecs, 'SimpleClientServer.map')
@@ -51,8 +57,9 @@ arduino_simplecs_env.Clean(arduino_simplecs, 'SimpleClientServer.map')
 Alias('arduino_simplecs', i_arduino_simplecs)
 arduino_simplecs_env.AppendTarget('arduino_simplecs')
 
-if(arduino_simplecs_env['UPLOAD'] == True):
-       if sys.platform.startswith("linux"):
-               arduino_simplecs_env.Upload(arduino_simplecs_env.get('BUILD_DIR') + '/resource/csdk/stack/samples/arduino/SimpleClientServer/ocserver/SimpleClientServer.hex')
-       else:
-               print 'Please use appropriate install method for your development machine. Linux is the only supported platform right now.'
+if (arduino_simplecs_env['UPLOAD'] == True):
+    if sys.platform.startswith("linux"):
+        arduino_simplecs_env.Upload(
+            arduino_simplecs_env.get('BUILD_DIR') + '/resource/csdk/stack/samples/arduino/SimpleClientServer/ocserver/SimpleClientServer.hex')
+    else:
+        print 'Please use appropriate install method for your development machine. Linux is the only supported platform right now.'
index fc358d3..a1ba54b 100644 (file)
@@ -26,27 +26,21 @@ target_os = stacksamples_env.get('TARGET_OS')
 ######################################################################
 # Build flags
 ######################################################################
-ocsample_env.PrependUnique(CPPPATH = [
+ocsample_env.PrependUnique(CPPPATH=[
     '#/resource/csdk/include',
     '#/resource/csdk/stack/include',
 ])
 
 if target_os not in ['msys_nt', 'windows']:
-    ocsample_env.PrependUnique(LIBS = [
-        'connectivity_abstraction',
-    ])
+    ocsample_env.PrependUnique(LIBS=['connectivity_abstraction',])
 
-ocsample_env.PrependUnique(LIBS = [
-    'octbstack',
-])
+ocsample_env.PrependUnique(LIBS=['octbstack',])
 
 if ocsample_env.get('SECURED') == '1':
-       if ocsample_env.get('WITH_TCP') == True:
-               ocsample_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509','mbedcrypto'])
+    if ocsample_env.get('WITH_TCP') == True:
+        ocsample_env.AppendUnique(LIBS=['mbedtls', 'mbedx509', 'mbedcrypto'])
 
-ocsample_env.AppendUnique(LIBPATH = [
-    ocsample_env.get('BUILD_DIR'),
-])
+ocsample_env.AppendUnique(LIBPATH=[ocsample_env.get('BUILD_DIR'),])
 
 ######################################################################
 # Source files and Targets
index 9737de5..d8feaa6 100644 (file)
@@ -31,12 +31,9 @@ with_ra = samples_env.get('WITH_RA')
 ######################################################################
 with_upstream_libcoap = samples_env.get('WITH_UPSTREAM_LIBCOAP')
 if with_upstream_libcoap == '1':
-    # For bring up purposes only, we manually copy the forked version to where
-    # the unforked version is downloaded.
-    samples_env.AppendUnique(CPPPATH=['#extlibs/libcoap/libcoap/include'])
+    samples_env.AppendUnique(CPPPATH=['#/extlibs/libcoap/libcoap/include'])
 else:
-    # For bring up purposes only, the forked version will live here.
-    samples_env.AppendUnique(CPPPATH=['#resource/csdk/connectivity/lib/libcoap-4.1.1/include'])
+    samples_env.AppendUnique(CPPPATH=['#/resource/csdk/connectivity/lib/libcoap-4.1.1/include'])
 
 samples_env.PrependUnique(CPPPATH=[
     '../../../../logger/include',
@@ -80,13 +77,11 @@ sample_src_dir = src_dir + '/resource/csdk/stack/samples/linux/SimpleClientServe
 sample_build_dir = samples_env.get(
     'BUILD_DIR') + '/resource/csdk/stack/samples/linux/SimpleClientServer/'
 
+introspectionDat = samples_env.Install(
+    sample_build_dir, sample_src_dir + 'introspection.dat')
 
-introspectionDat = samples_env.Install(sample_build_dir,
-                                       sample_src_dir + 'introspection.dat')
-
-deviceProperties = samples_env.Install(sample_build_dir,
-                                       sample_src_dir + 'device_properties.dat')
-
+deviceProperties = samples_env.Install(
+    sample_build_dir, sample_src_dir + 'device_properties.dat')
 
 ######################################################################
 # Source files and Targets
@@ -109,14 +104,19 @@ ocserverbasicops = samples_env.Program(
 occlientbasicops = samples_env.Program(
     'occlientbasicops', ['occlientbasicops.cpp', 'common.cpp'])
 if with_ra:
-    ocremoteaccessclient = samples_env.Program('ocremoteaccessclient',
-                                               ['ocremoteaccessclient.cpp', 'common.cpp'])
-
-list_of_samples = [ocserver, occlient,
-                   ocservercoll, occlientcoll,
-                   ocserverbasicops, occlientbasicops,
-                   ocserverslow, occlientslow
-                   ]
+    ocremoteaccessclient = samples_env.Program(
+        'ocremoteaccessclient', ['ocremoteaccessclient.cpp', 'common.cpp'])
+
+list_of_samples = [
+    ocserver,
+    occlient,
+    ocservercoll,
+    occlientcoll,
+    ocserverbasicops,
+    occlientbasicops,
+    ocserverslow,
+    occlientslow
+]
 if with_ra:
     list_of_samples.append(ocremoteaccessclient)
 Alias("samples", list_of_samples)
index b49042e..c1af966 100644 (file)
@@ -24,85 +24,111 @@ samples_env = stacksamples_env.Clone()
 ######################################################################
 # Build flags
 ######################################################################
-samples_env.PrependUnique(CPPPATH = [
-               '../../../../logger/include',
-               '../../../../include',
-               '../../../../stack/include',
-               '../../../../security/include',
-               '../../../../../oc_logger/include'
-               ])
+samples_env.PrependUnique(CPPPATH=[
+    '../../../../logger/include',
+    '../../../../include',
+    '../../../../stack/include',
+    '../../../../security/include',
+    '../../../../../oc_logger/include'
+])
 
 target_os = samples_env.get('TARGET_OS')
 if target_os not in ['windows']:
-       samples_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
+    samples_env.AppendUnique(CXXFLAGS=['-std=c++0x', '-Wall', '-pthread'])
 
-       # Note: 'pthread' is in libc for android.
-       if target_os != 'android':
-               samples_env.AppendUnique(LIBS = ['pthread'])
-       samples_env.Append(LINKFLAGS = ['-Wl,--no-as-needed'])
+    # Note: 'pthread' is in libc for android.
+    if target_os != 'android':
+        samples_env.AppendUnique(LIBS=['pthread'])
+    samples_env.Append(LINKFLAGS=['-Wl,--no-as-needed'])
 
 if target_os in ['windows', 'msys_nt']:
-       samples_env.PrependUnique(LIBS = ['coap', 'ocsrm'])
+    samples_env.PrependUnique(LIBS=['coap', 'ocsrm'])
 else:
-       samples_env.PrependUnique(LIBS = ['connectivity_abstraction', 'coap', 'm'])
+    samples_env.PrependUnique(LIBS=['connectivity_abstraction', 'coap', 'm'])
 
-samples_env.PrependUnique(LIBS = ['octbstack'])
+samples_env.PrependUnique(LIBS=['octbstack'])
 
 if samples_env.get('SECURED') == '1':
-       samples_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509','mbedcrypto'])
-
+    samples_env.AppendUnique(LIBS=['mbedtls', 'mbedx509', 'mbedcrypto'])
 
 if target_os == 'android':
-       samples_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
-       samples_env.AppendUnique(LIBS = ['gnustl_shared'])
-       samples_env.AppendUnique(CPPDEFINES = ['_GLIBCXX_USE_C99=1', '_GLIBCXX_HAVE_WCSTOF=1'])
+    samples_env.AppendUnique(CXXFLAGS=['-frtti', '-fexceptions'])
+    samples_env.AppendUnique(LIBS=['gnustl_shared'])
+    samples_env.AppendUnique(
+        CPPDEFINES=['_GLIBCXX_USE_C99=1', '_GLIBCXX_HAVE_WCSTOF=1'])
 
-       if not samples_env.get('RELEASE'):
-               samples_env.AppendUnique(LIBS = ['log'])
+    if not samples_env.get('RELEASE'):
+        samples_env.AppendUnique(LIBS=['log'])
 
 if target_os in ['darwin', 'ios']:
-       samples_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
+    samples_env.AppendUnique(CPPDEFINES=['_DARWIN_C_SOURCE'])
 
-samples_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+samples_env.AppendUnique(CPPDEFINES=['TB_LOG'])
 
 ######################################################################
 # Source files and Targets
 ######################################################################
 
-ocserverbasicops = samples_env.Program('ocserverbasicops', ['common.cpp', 'ocserverbasicops.cpp'])
-occlientbasicops = samples_env.Program('occlientbasicops', ['common.cpp', 'occlientbasicops.cpp'])
-ocamsservice = samples_env.Program('ocamsservice', ['common.cpp', 'ocamsservice.cpp'])
+ocserverbasicops = samples_env.Program(
+    'ocserverbasicops', ['common.cpp', 'ocserverbasicops.cpp'])
+occlientbasicops = samples_env.Program(
+    'occlientbasicops', ['common.cpp', 'occlientbasicops.cpp'])
+ocamsservice = samples_env.Program(
+    'ocamsservice', ['common.cpp', 'ocamsservice.cpp'])
+ocsamples = [ocserverbasicops, occlientbasicops, ocamsservice]
 if samples_env.get('SECURED') == '1':
-       occlientdirectpairing = samples_env.Program('occlientdirectpairing', 'occlientdirectpairing.cpp')
-       Alias("samples", [ocserverbasicops, occlientbasicops, ocamsservice, occlientdirectpairing])
-else:
-       Alias("samples", [ocserverbasicops, occlientbasicops, ocamsservice])
-
+    occlientdirectpairing = samples_env.Program(
+        'occlientdirectpairing', 'occlientdirectpairing.cpp')
+    ocsamples.append(occlientdirectpairing)
+Alias("samples", ocsamples)
 samples_env.AppendTarget('samples')
 
 src_dir = samples_env.get('SRC_DIR')
 sec_samples_src_dir = src_dir + '/resource/csdk/stack/samples/linux/secure/'
-sec_samples_build_dir = samples_env.get('BUILD_DIR') +'/resource/csdk/stack/samples/linux/secure'
-
-samples_env.Alias("install", samples_env.Install( sec_samples_build_dir,
-    sec_samples_src_dir + 'oic_svr_db_server.json'))
-samples_env.Alias("install", samples_env.Install( sec_samples_build_dir,
-    sec_samples_src_dir + 'oic_svr_db_client_devowner.json'))
-samples_env.Alias("install", samples_env.Install( sec_samples_build_dir,
-    sec_samples_src_dir + 'oic_svr_db_client_nondevowner.json'))
-samples_env.Alias("install", samples_env.Install( sec_samples_build_dir,
-    sec_samples_src_dir + 'oic_amss_db.json'))
+sec_samples_build_dir = samples_env.get(
+    'BUILD_DIR') + '/resource/csdk/stack/samples/linux/secure'
+
+samples_env.Alias(
+    "install",
+    samples_env.Install(sec_samples_build_dir,
+                        sec_samples_src_dir + 'oic_svr_db_server.json'))
+samples_env.Alias(
+    "install",
+    samples_env.Install(sec_samples_build_dir,
+                        sec_samples_src_dir + 'oic_svr_db_client_devowner.json'))
+samples_env.Alias(
+    "install",
+    samples_env.Install(sec_samples_build_dir,
+                        sec_samples_src_dir + 'oic_svr_db_client_nondevowner.json'))
+samples_env.Alias(
+    "install",
+    samples_env.Install(sec_samples_build_dir,
+                        sec_samples_src_dir + 'oic_amss_db.json'))
 if samples_env.get('SECURED') == '1':
-       samples_env.Alias("install", samples_env.Install( sec_samples_build_dir,
-               sec_samples_src_dir + 'oic_svr_db_client_directpairing.json'))
-       samples_env.Alias("install", samples_env.Install( sec_samples_build_dir,
-       sec_samples_src_dir + 'oic_svr_db_client_directpairing.dat'))
-
-samples_env.Alias("install", samples_env.Install( sec_samples_build_dir,
-    sec_samples_src_dir + 'oic_svr_db_server.dat'))
-samples_env.Alias("install", samples_env.Install( sec_samples_build_dir,
-    sec_samples_src_dir + 'oic_svr_db_client_devowner.dat'))
-samples_env.Alias("install", samples_env.Install( sec_samples_build_dir,
-    sec_samples_src_dir + 'oic_svr_db_client_nondevowner.dat'))
-samples_env.Alias("install", samples_env.Install( sec_samples_build_dir,
-    sec_samples_src_dir + 'oic_amss_db.dat'))
+    samples_env.Alias(
+        "install",
+        samples_env.Install(
+            sec_samples_build_dir,
+            sec_samples_src_dir + 'oic_svr_db_client_directpairing.json'))
+    samples_env.Alias(
+        "install",
+        samples_env.Install(
+            sec_samples_build_dir,
+            sec_samples_src_dir + 'oic_svr_db_client_directpairing.dat'))
+
+samples_env.Alias(
+    "install",
+    samples_env.Install(sec_samples_build_dir,
+                        sec_samples_src_dir + 'oic_svr_db_server.dat'))
+samples_env.Alias(
+    "install",
+    samples_env.Install(sec_samples_build_dir,
+                        sec_samples_src_dir + 'oic_svr_db_client_devowner.dat'))
+samples_env.Alias(
+    "install",
+    samples_env.Install(sec_samples_build_dir,
+                        sec_samples_src_dir + 'oic_svr_db_client_nondevowner.dat'))
+samples_env.Alias(
+    "install",
+    samples_env.Install(sec_samples_build_dir,
+                        sec_samples_src_dir + 'oic_amss_db.dat'))
index 49e2e68..33a452e 100644 (file)
@@ -8,41 +8,45 @@ import platform
 print "Inside the Config SConscript"
 # Map of host os and allowed target os (host: allowed target os)
 host_target_map = {
-               'linux': ['linux', 'android', 'arduino', 'yocto', 'tizen'],
-               'windows': ['windows', 'android', 'arduino', 'tizen'],
-               'darwin': ['darwin', 'ios', 'android', 'arduino'],
-               }
+    'linux': ['linux', 'android', 'arduino', 'yocto', 'tizen'],
+    'windows': ['windows', 'android', 'arduino', 'tizen'],
+    'darwin': ['darwin', 'ios', 'android', 'arduino'],
+}
 
 # Map of os and allowed archs (os: allowed archs)
 os_arch_map = {
-               'linux': ['x86', 'x86_64', 'arm', 'arm64'],
-               'android': ['x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'armeabi-v7a-hard', 'arm64-v8a'],
-               'windows': ['x86', 'amd64', 'arm'],
-               'darwin': ['i386', 'x86_64'],
-               'ios': ['i386', 'x86_64', 'armv7', 'armv7s', 'arm64'],
-               'arduino': ['avr', 'arm'],
-                'yocto': ['x86', 'x86_64'],
-               'tizen': ['armv7'],
-               }
+    'linux': ['x86', 'x86_64', 'arm', 'arm64'],
+    'android': [
+        'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'armeabi-v7a-hard',
+        'arm64-v8a'
+    ],
+    'windows': ['x86', 'amd64', 'arm'],
+    'darwin': ['i386', 'x86_64'],
+    'ios': ['i386', 'x86_64', 'armv7', 'armv7s', 'arm64'],
+    'arduino': ['avr', 'arm'],
+    'yocto': ['x86', 'x86_64'],
+    'tizen': ['armv7'],
+}
 
 host = platform.system().lower()
 
 if host not in host_target_map:
-       print "\nError: Current system (%s) isn't supported\n" % host
-       Exit(1)
+    print "\nError: Current system (%s) isn't supported\n" % host
+    Exit(1)
 
 ######################################################################
 # Get build options (the optins from command line)
 ######################################################################
-target_os = ARGUMENTS.get('TARGET_OS', host).lower() # target os
+target_os = ARGUMENTS.get('TARGET_OS', host).lower()  # target os
 
 if target_os not in host_target_map[host]:
-       print "\nError: Unknown target os: %s (Allow values: %s)\n" % (target_os, host_target_map[host])
-       Exit(1)
+    print "\nError: Unknown target os: %s (Allow values: %s)\n" % (
+        target_os, host_target_map[host])
+    Exit(1)
 
 default_arch = platform.machine()
 if default_arch not in os_arch_map[target_os]:
-       default_arch = os_arch_map[target_os][0].lower()
+    default_arch = os_arch_map[target_os][0].lower()
 
 target_arch = ARGUMENTS.get('TARGET_ARCH', default_arch) # target arch
 
@@ -50,14 +54,44 @@ target_arch = ARGUMENTS.get('TARGET_ARCH', default_arch) # target arch
 # Common build options (release, target os, target arch)
 ######################################################################
 help_vars = Variables()
-help_vars.Add(BoolVariable('RELEASE', 'Build for release?', True)) # set to 'no', 'false' or 0 for debug
-help_vars.Add(EnumVariable('TARGET_OS', 'Target platform', host, host_target_map[host]))
-help_vars.Add(ListVariable('TARGET_TRANSPORT', 'Target transport', 'ALL', ['ALL', 'IP', 'BT', 'BLE']))
-help_vars.Add(EnumVariable('TARGET_ARCH', 'Target architecture', default_arch, os_arch_map[target_os]))
-help_vars.Add(EnumVariable('SECURED', 'Build with DTLS', '1', allowed_values=('0', '1')))
-help_vars.Add(EnumVariable('ROUTING', 'Enable routing', 'EP', allowed_values=('GW', 'EP')))
-help_vars.Add(BoolVariable('WITH_PROXY', 'CoAP-HTTP Proxy', False)) # set to 'no', 'false' or 0 for debug
-help_vars.Add(ListVariable('WITH_MQ', 'Build with MQ publisher/subscriber/broker', 'OFF', ['OFF', 'SUB', 'PUB', 'BROKER']))
+help_vars.Add(
+    BoolVariable('RELEASE',
+                 'Build for release?',
+                 True))  # set to 'no', 'false' or 0 for debug
+help_vars.Add(
+    EnumVariable('TARGET_OS',
+                 'Target platform',
+                 host,
+                 allowed_values=host_target_map[host]))
+help_vars.Add(
+    ListVariable('TARGET_TRANSPORT',
+                 'Target transport',
+                 'ALL',
+                 ['ALL', 'IP', 'BT', 'BLE']))
+help_vars.Add(
+    EnumVariable('TARGET_ARCH',
+                 'Target architecture',
+                 default_arch,
+                 allowed_values=os_arch_map[target_os]))
+help_vars.Add(
+    EnumVariable('SECURED',
+                 'Build with DTLS',
+                 '1',
+                 allowed_values=('0', '1')))
+help_vars.Add(
+    EnumVariable('ROUTING',
+                 'Enable routing',
+                 'EP',
+                 allowed_values=('GW', 'EP')))
+help_vars.Add(
+    BoolVariable('WITH_PROXY',
+                 'CoAP-HTTP Proxy',
+                           False))  # set to 'no', 'false' or 0 for debug
+help_vars.Add(
+    ListVariable('WITH_MQ',
+                 'Build with MQ publisher/subscriber/broker',
+                 'OFF',
+                 ['OFF', 'SUB', 'PUB', 'BROKER']))
 
 ######################################################################
 # Platform(build target) specific options: SDK/NDK & toolchain
@@ -65,18 +99,25 @@ help_vars.Add(ListVariable('WITH_MQ', 'Build with MQ publisher/subscriber/broker
 targets_support_cc = ['linux', 'arduino', 'tizen']
 
 if target_os in targets_support_cc:
-       # Set cross compile toolchain
-       help_vars.Add('TC_PREFIX', "Toolchain prefix (Generally only be required for cross-compiling)", os.environ.get('TC_PREFIX'))
-       help_vars.Add(PathVariable('TC_PATH',
-                       'Toolchain path (Generally only be required for cross-compiling)',
-                       os.environ.get('TC_PATH')))
-
-if target_os in ['android', 'arduino']: # Android/Arduino always uses GNU compiler regardless of the host
-       env = Environment(variables = help_vars,
-                       tools = ['gnulink', 'gcc', 'g++', 'ar', 'as']
-                       )
+    # Set cross compile toolchain
+    help_vars.Add(
+        'TC_PREFIX',
+        "Toolchain prefix (Generally only required for cross-compiling)",
+        os.environ.get('TC_PREFIX'))
+    help_vars.Add(
+        PathVariable(
+        'TC_PATH',
+        'Toolchain path (Generally only required for cross-compiling)',
+        os.environ.get('TC_PATH')))
+
+if target_os in [
+        'android', 'arduino'
+]:  # Android/Arduino always uses GNU compiler regardless of the host
+    env = Environment(
+        variables=help_vars, tools=['gnulink', 'gcc', 'g++', 'ar', 'as'])
 else:
-       env = Environment(variables = help_vars, TARGET_ARCH = target_arch, TARGET_OS = target_os)
+    env = Environment(
+        variables=help_vars, TARGET_ARCH=target_arch, TARGET_OS=target_os)
 
 Help(help_vars.GenerateHelpText(env))
 
@@ -89,24 +130,24 @@ tc_set_msg = '''
 '''
 
 if target_os in targets_support_cc:
-       prefix = env.get('TC_PREFIX')
-       tc_path = env.get('TC_PATH')
-       if prefix:
-               env.Replace(CC = prefix + 'gcc')
-               env.Replace(CXX = prefix + 'g++')
-               env.Replace(AR = prefix + 'ar')
-               env.Replace(AS = prefix + 'as')
-               env.Replace(LINK = prefix + 'ld')
-               env.Replace(RANLIB = prefix + 'ranlib')
-
-       if tc_path:
-               env.PrependENVPath('PATH', tc_path)
-               sys_root = os.path.abspath(tc_path + '/../')
-               env.AppendUnique(CCFLAGS = ['--sysroot=' + sys_root])
-               env.AppendUnique(LINKFLAGS = ['--sysroot=' + sys_root])
-
-       if prefix or tc_path:
-               print tc_set_msg
+    prefix = env.get('TC_PREFIX')
+    tc_path = env.get('TC_PATH')
+    if prefix:
+        env.Replace(CC=prefix + 'gcc')
+        env.Replace(CXX=prefix + 'g++')
+        env.Replace(AR=prefix + 'ar')
+        env.Replace(AS=prefix + 'as')
+        env.Replace(LINK=prefix + 'ld')
+        env.Replace(RANLIB=prefix + 'ranlib')
+
+    if tc_path:
+        env.PrependENVPath('PATH', tc_path)
+        sys_root = os.path.abspath(tc_path + '/../')
+        env.AppendUnique(CCFLAGS=['--sysroot=' + sys_root])
+        env.AppendUnique(LINKFLAGS=['--sysroot=' + sys_root])
+
+    if prefix or tc_path:
+        print tc_set_msg
 
 # Ensure scons be able to change its working directory
 env.SConscriptChdir(1)
@@ -119,66 +160,72 @@ env.SConscriptChdir(1)
 #   env.get('SRC_DIR')
 #   env.get('BUILD_DIR')
 
+
 def __set_dir(env, dir):
-       if not os.path.exists(dir + '/SConstruct'):
-               print '''
+    if not os.path.exists(dir + '/SConstruct'):
+        print '''
 *************************************** Error *********************************
 * The directory(%s) seems isn't a source code directory, no SConstruct file is
 * found. *
 *******************************************************************************
 ''' % dir
-               Exit(1)
+        Exit(1)
+
+    if env.get('RELEASE'):
+        build_dir = dir + '/out/' + target_os + '/' + target_arch + '/release/'
+    else:
+        build_dir = dir + '/out/' + target_os + '/' + target_arch + '/debug/'
+    env.VariantDir(build_dir, dir, duplicate=0)
+
+    env.Replace(BUILD_DIR=build_dir)
+    env.Replace(SRC_DIR=dir)
 
-       if env.get('RELEASE'):
-               build_dir = dir + '/out/' + target_os + '/' + target_arch + '/release/'
-       else:
-               build_dir = dir + '/out/' + target_os + '/' + target_arch + '/debug/'
-       env.VariantDir(build_dir, dir, duplicate=0)
 
-       env.Replace(BUILD_DIR = build_dir)
-       env.Replace(SRC_DIR = dir)
+def __src_to_obj(env, src, home=''):
+    obj = env.get('BUILD_DIR') + src.replace(home, '')
+    if env.get('OBJSUFFIX'):
+        obj += env.get('OBJSUFFIX')
+    return env.Object(obj, src)
 
-def __src_to_obj(env, src, home = ''):
-       obj = env.get('BUILD_DIR') + src.replace(home, '')
-       if env.get('OBJSUFFIX'):
-               obj += env.get('OBJSUFFIX')
-       return env.Object(obj, src)
 
 def __install(ienv, targets, name):
-       i_n = ienv.Install(env.get('BUILD_DIR'), targets)
-       Alias(name, i_n)
-       env.AppendUnique(TS = [name])
+    i_n = ienv.Install(env.get('BUILD_DIR'), targets)
+    Alias(name, i_n)
+    env.AppendUnique(TS=[name])
+
 
 def __append_target(ienv, target):
-       env.AppendUnique(TS = [target])
+    env.AppendUnique(TS=[target])
+
 
 def __print_targets(env):
-       Help('''
+    Help('''
 ===============================================================================
 Targets:\n    ''')
-       for t in env.get('TS'):
-               Help(t + ' ')
-       Help('''
+    for t in env.get('TS'):
+        Help(t + ' ')
+    Help('''
 \nDefault all targets will be built. You can specify the target to build:
 
     $ scons [options] [target]
 ===============================================================================
 ''')
 
+
 env.AddMethod(__set_dir, 'SetDir')
 env.AddMethod(__print_targets, 'PrintTargets')
 env.AddMethod(__src_to_obj, 'SrcToObj')
 env.AddMethod(__append_target, 'AppendTarget')
 env.AddMethod(__install, 'InstallTarget')
 env.SetDir(env.GetLaunchDir())
-env['ROOT_DIR']=env.GetLaunchDir()
+env['ROOT_DIR'] = env.GetLaunchDir()
 
-env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+env.AppendUnique(CPPDEFINES=['TB_LOG'])
 if env.get('ROUTING') == 'GW':
-       env.AppendUnique(CPPDEFINES = ['ROUTING_GATEWAY'])
+    env.AppendUnique(CPPDEFINES=['ROUTING_GATEWAY'])
 elif env.get('ROUTING') == 'EP':
-       env.AppendUnique(CPPDEFINES = ['ROUTING_EP'])
-env.AppendUnique(CPPDEFINES = ['__TIZEN__'])
+    env.AppendUnique(CPPDEFINES=['ROUTING_EP'])
+env.AppendUnique(CPPDEFINES=['__TIZEN__'])
 
 Export('env')
 
@@ -195,20 +242,22 @@ if target_os == "yocto":
     try:
         CC = os.environ['CC']
         target_prefix = CC.split()[0]
-        target_prefix = target_prefix[:len(target_prefix)-3]
-        tools = {"CC" : target_prefix+"gcc",
-                "CXX" : target_prefix+"g++",
-                "AS" : target_prefix+"as",
-                "LD" : target_prefix+"ld",
-                "GDB" : target_prefix+"gdb",
-                "STRIP" : target_prefix+"strip",
-                "RANLIB" : target_prefix+"ranlib",
-                "OBJCOPY" : target_prefix+"objcopy",
-                "OBJDUMP" : target_prefix+"objdump",
-                "AR" : target_prefix+"ar",
-                "NM" : target_prefix+"nm",
-                "M4" : "m4",
-                "STRINGS": target_prefix+"strings"}
+        target_prefix = target_prefix[:len(target_prefix) - 3]
+        tools = {
+            "CC": target_prefix + "gcc",
+            "CXX": target_prefix + "g++",
+            "AS": target_prefix + "as",
+            "LD": target_prefix + "ld",
+            "GDB": target_prefix + "gdb",
+            "STRIP": target_prefix + "strip",
+            "RANLIB": target_prefix + "ranlib",
+            "OBJCOPY": target_prefix + "objcopy",
+            "OBJDUMP": target_prefix + "objdump",
+            "AR": target_prefix + "ar",
+            "NM": target_prefix + "nm",
+            "M4": "m4",
+            "STRINGS": target_prefix + "strings"
+        }
         PATH = os.environ['PATH'].split(os.pathsep)
         for tool in tools:
             if tool in os.environ:
@@ -239,12 +288,12 @@ else:
 
 # Delete the temp files of configuration
 if env.GetOption('clean'):
-       dir = env.get('SRC_DIR')
+    dir = env.get('SRC_DIR')
 
-       if os.path.exists(dir + '/config.log'):
-               Execute(Delete(dir + '/config.log'))
-               Execute(Delete(dir + '/.sconsign.dblite'))
-               Execute(Delete(dir + '/.sconf_temp'))
+    if os.path.exists(dir + '/config.log'):
+        Execute(Delete(dir + '/config.log'))
+        Execute(Delete(dir + '/.sconsign.dblite'))
+        Execute(Delete(dir + '/.sconf_temp'))
 
 Return('env')
 
index 8da0f97..5edcced 100644 (file)
@@ -32,61 +32,83 @@ sample_dir = build_dir
 
 print "MQ flag is %s" % with_mq
 
-env.AppendUnique(CPPFLAGS = ['-std=c++0x', '-fPIC', '-D__TIZEN__','-DWITH_POSIX', '-Wall', '-DSLP_SDK_LOG', '-g','-D_GNU_SOURCE','-DTIZEN_DEBUG_ENABLE', '-DTB_LOG','`pkg-config', '--cflags', '--libs','dlog', 'com.oic.ri', 'capi-network-connection',
-                               'gobject-2.0','glib-2.0`'])
+env.AppendUnique(CPPFLAGS=[
+    '-std=c++0x', '-fPIC', '-D__TIZEN__', '-DWITH_POSIX', '-Wall',
+    '-DSLP_SDK_LOG', '-g', '-D_GNU_SOURCE', '-DTIZEN_DEBUG_ENABLE', '-DTB_LOG',
+    '`pkg-config', '--cflags', '--libs', 'dlog', 'com.oic.ri',
+    'capi-network-connection', 'gobject-2.0', 'glib-2.0`'
+])
 
 if routing == 'GW':
-       env.AppendUnique(CPPDEFINES = ['ROUTING_GATEWAY'])
+    env.AppendUnique(CPPDEFINES=['ROUTING_GATEWAY'])
 elif routing == 'EP':
-       env.AppendUnique(CPPDEFINES = ['ROUTING_EP'])
+    env.AppendUnique(CPPDEFINES=['ROUTING_EP'])
 
 env.Append(LIBS=[
-  'm', 'pthread', 'rt', 'dl', 'stdc++', 'gobject-2.0', 'gio-2.0', 'glib-2.0', 'capi-network-connection', 'dlog', 'capi-network-bluetooth', 'connectivity_abstraction', 'coap', 'octbstack', 'ocsrm', 'c_common'
+    'm',
+    'pthread',
+    'rt',
+    'dl',
+    'stdc++',
+    'gobject-2.0',
+    'gio-2.0',
+    'glib-2.0',
+    'capi-network-connection',
+    'dlog',
+    'capi-network-bluetooth',
+    'connectivity_abstraction',
+    'coap',
+    'octbstack',
+    'ocsrm',
+    'c_common',
 ])
 
 if secured == '1':
-       env.PrependUnique(CPPPATH = [root_dir + '/external/inc/'])
-       env.AppendUnique(CPPDEFINES = ['__WITH_DTLS__'])
-       env.Append(LIBS=['mbedtls', 'mbedx509','mbedcrypto'])
+    env.PrependUnique(CPPPATH=[root_dir + '/external/inc/'])
+    env.AppendUnique(CPPDEFINES=['__WITH_DTLS__'])
+    env.Append(LIBS=['mbedtls', 'mbedx509', 'mbedcrypto'])
 
 if 'ALL' in transport:
-               env.AppendUnique(CPPDEFINES = ['IP_ADAPTER','EDR_ADAPTER','LE_ADAPTER','BT_ADAPTER_TEST','BLE_ADAPTER_TEST'])
-               print "CA Transport is ALL"
+    env.AppendUnique(CPPDEFINES=[
+        'IP_ADAPTER', 'EDR_ADAPTER', 'LE_ADAPTER', 'BT_ADAPTER_TEST',
+        'BLE_ADAPTER_TEST'
+    ])
+    print "CA Transport is ALL"
 else:
-       if 'BT' in transport:
-               env.AppendUnique(CPPDEFINES = ['EDR_ADAPTER','BT_ADAPTER_TEST'])
-               print "CA Transport is BT"
-       else:
-               env.AppendUnique(CPPDEFINES = ['NO_EDR_ADAPTER'])
-
-       if 'BLE' in transport:
-               env.AppendUnique(CPPDEFINES = ['LE_ADAPTER','BLE_ADAPTER_TEST'])
-               print "CA Transport is BLE"
-       else:
-               env.AppendUnique(CPPDEFINES = ['NO_LE_ADAPTER'])
-
-       if 'IP' in transport:
-               env.AppendUnique(CPPDEFINES = ['IP_ADAPTER'])
-               print "CA Transport is IP"
-       else:
-               env.AppendUnique(CPPDEFINES = ['NO_IP_ADAPTER'])
-
-       if env.get('WITH_TCP'):
-               env.AppendUnique(CPPDEFINES = ['TCP_ADAPTER', 'WITH_TCP'])
-       else:
-               env.AppendUnique(CPPDEFINES = ['NO_TCP_ADAPTER'])
+    if 'BT' in transport:
+        env.AppendUnique(CPPDEFINES=['EDR_ADAPTER', 'BT_ADAPTER_TEST'])
+        print "CA Transport is BT"
+    else:
+        env.AppendUnique(CPPDEFINES=['NO_EDR_ADAPTER'])
+
+    if 'BLE' in transport:
+        env.AppendUnique(CPPDEFINES=['LE_ADAPTER', 'BLE_ADAPTER_TEST'])
+        print "CA Transport is BLE"
+    else:
+        env.AppendUnique(CPPDEFINES=['NO_LE_ADAPTER'])
+
+    if 'IP' in transport:
+        env.AppendUnique(CPPDEFINES=['IP_ADAPTER'])
+        print "CA Transport is IP"
+    else:
+        env.AppendUnique(CPPDEFINES=['NO_IP_ADAPTER'])
+
+    if env.get('WITH_TCP'):
+        env.AppendUnique(CPPDEFINES=['TCP_ADAPTER', 'WITH_TCP'])
+    else:
+        env.AppendUnique(CPPDEFINES=['NO_TCP_ADAPTER'])
 
 if 'SUB' in with_mq:
-       env.AppendUnique(CPPDEFINES = ['MQ_SUBSCRIBER', 'WITH_MQ'])
-       print "MQ SUB support"
+    env.AppendUnique(CPPDEFINES=['MQ_SUBSCRIBER', 'WITH_MQ'])
+    print "MQ SUB support"
 
 if 'PUB' in with_mq:
-       env.AppendUnique(CPPDEFINES = ['MQ_PUBLISHER', 'WITH_MQ'])
-       print "MQ PUB support"
+    env.AppendUnique(CPPDEFINES=['MQ_PUBLISHER', 'WITH_MQ'])
+    print "MQ PUB support"
 
 if 'BROKER' in with_mq:
-       env.AppendUnique(CPPDEFINES = ['MQ_BROKER', 'WITH_MQ'])
-       print "MQ Broker support"
+    env.AppendUnique(CPPDEFINES=['MQ_BROKER', 'WITH_MQ'])
+    print "MQ Broker support"
 
 #ri_sample_src = [sample_dir + '/occlient.cpp']
 
@@ -94,6 +116,7 @@ if 'BROKER' in with_mq:
 
 #env.Program('ri_sample', [ri_sample_src,])
 
-env.Program('occlient', [sample_dir + 'occlient.cpp', sample_dir + 'common.cpp'])
-env.Program('ocserver', [sample_dir + 'ocserver.cpp', sample_dir + 'common.cpp'])
-env.Program('ocrouting', [sample_dir + 'ocrouting.cpp', sample_dir + 'common.cpp'])
+sample_comm = sample_dir + 'common.cpp'
+env.Program('occlient', [sample_dir + 'occlient.cpp', sample_comm])
+env.Program('ocserver', [sample_dir + 'ocserver.cpp', sample_comm])
+env.Program('ocrouting', [sample_dir + 'ocrouting.cpp', sample_comm])
index 68fdd31..8f7cecd 100644 (file)
@@ -20,30 +20,32 @@ with_mq = env.get('WITH_MQ')
 
 with_upstream_libcoap = env.get('WITH_UPSTREAM_LIBCOAP')
 if with_upstream_libcoap == '1':
-       env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
+    env.AppendUnique(CPPPATH=['#extlibs/libcoap/libcoap/include'])
 else:
-       env.AppendUnique(CPPPATH = ['../../../../connectivity/lib/libcoap-4.1.1'])
+    env.AppendUnique(CPPPATH=['../../../../connectivity/lib/libcoap-4.1.1'])
 
-env.PrependUnique(CPPPATH = [
-               '../../../../logger/include',
-               '../../../../include',
-               '../../../../stack/include',
-               '../../../../../oc_logger/include'
-               ])
+env.PrependUnique(CPPPATH=[
+    '../../../../logger/include',
+    '../../../../include',
+    '../../../../stack/include',
+    '../../../../../oc_logger/include'
+])
 
-env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+env.AppendUnique(CPPDEFINES=['TB_LOG'])
 if routing == 'GW':
-       env.AppendUnique(CPPDEFINES = ['ROUTING_GATEWAY'])
+    env.AppendUnique(CPPDEFINES=['ROUTING_GATEWAY'])
 elif routing == 'EP':
-       env.AppendUnique(CPPDEFINES = ['ROUTING_EP'])
-env.AppendUnique(CPPDEFINES = ['__TIZEN__'])
+    env.AppendUnique(CPPDEFINES=['ROUTING_EP'])
+env.AppendUnique(CPPDEFINES=['__TIZEN__'])
 
 print "Given Transport is %s" % transport
 print "Given OS is %s" % target_os
 print "Given MQ is %s" % with_mq
 
 if target_os == 'tizen':
-       command = "sh resource/csdk/stack/samples/tizen/build/gbsbuild.sh %s %s %s %s %s %s %s %s %s %s" % (transport, secured, buildsample, release_mode, logging, routing, with_tcp, with_proxy, with_mq, target_arch)
-       print "Created Command is %s" % command
-       gbs_script = env.Command('gbs_build', None, command)
-       AlwaysBuild ('gbs_script')
+    command = "./resource/csdk/stack/samples/tizen/build/gbsbuild.sh %s %s %s %s %s %s %s %s %s %s" % (
+        transport, secured, buildsample, release_mode, logging, routing,
+        with_tcp, with_proxy, with_mq, target_arch)
+    print "Created Command is %s" % command
+    gbs_script = env.Command('gbs_build', None, command)
+    AlwaysBuild('gbs_script')
index a606db0..4206416 100644 (file)
@@ -13,54 +13,63 @@ with_mq = env.get('WITH_MQ')
 print "Given Transport is %s" % transport
 
 if env.get('RELEASE'):
-       env.AppendUnique(CFLAGS = ['-std=c99', '-fPIC', '-D__TIZEN__','-DWITH_POSIX', '-Wall','-D_GNU_SOURCE','-DTIZEN_DEBUG_ENABLE'])
+    env.AppendUnique(CFLAGS=[
+        '-std=c99', '-fPIC', '-D__TIZEN__', '-DWITH_POSIX', '-Wall',
+        '-D_GNU_SOURCE', '-DTIZEN_DEBUG_ENABLE'
+    ])
 else:
-       env.AppendUnique(CFLAGS = ['-std=c99', '-fPIC', '-D__TIZEN__','-DWITH_POSIX', '-Wall', '-DSLP_SDK_LOG', '-g','-D_GNU_SOURCE','-DTIZEN_DEBUG_ENABLE'])
+    env.AppendUnique(CFLAGS=[
+        '-std=c99', '-fPIC', '-D__TIZEN__', '-DWITH_POSIX', '-Wall',
+        '-DSLP_SDK_LOG', '-g', '-D_GNU_SOURCE', '-DTIZEN_DEBUG_ENABLE'
+    ])
 
 if env.get('LOGGING'):
-    env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+    env.AppendUnique(CPPDEFINES=['TB_LOG'])
 
-env.ParseConfig("pkg-config --cflags --libs capi-network-connection dlog glib-2.0")
+env.ParseConfig(
+    "pkg-config --cflags --libs capi-network-connection dlog glib-2.0")
 if env.get('OIC_SUPPORT_TIZEN_TRACE') == 'True':
-       env.ParseConfig("pkg-config --cflags --libs ttrace")
-       env.AppendUnique(CPPDEFINES = ['OIC_SUPPORT_TIZEN_TRACE'])
+    env.ParseConfig("pkg-config --cflags --libs ttrace")
+    env.AppendUnique(CPPDEFINES=['OIC_SUPPORT_TIZEN_TRACE'])
 if 'ALL' in transport:
-               env.AppendUnique(CPPDEFINES = ['WIFI_ADAPTER', 'NO_ETHERNET_ADAPTER','EDR_ADAPTER','LE_ADAPTER'])
-               print "CA Transport is ALL"
+    env.AppendUnique(CPPDEFINES=[
+        'WIFI_ADAPTER', 'NO_ETHERNET_ADAPTER', 'EDR_ADAPTER', 'LE_ADAPTER'
+    ])
+    print "CA Transport is ALL"
 else:
-       if 'BT' in transport:
-               env.AppendUnique(CPPDEFINES = ['EDR_ADAPTER'])
-               print "CA Transport is BT"
-       else:
-               env.AppendUnique(CPPDEFINES = ['NO_EDR_ADAPTER'])
+    if 'BT' in transport:
+        env.AppendUnique(CPPDEFINES=['EDR_ADAPTER'])
+        print "CA Transport is BT"
+    else:
+        env.AppendUnique(CPPDEFINES=['NO_EDR_ADAPTER'])
 
-       if 'BLE' in transport:
-               env.AppendUnique(CPPDEFINES = ['LE_ADAPTER'])
-               print "CA Transport is BLE"
-       else:
-               env.AppendUnique(CPPDEFINES = ['NO_LE_ADAPTER'])
+    if 'BLE' in transport:
+        env.AppendUnique(CPPDEFINES=['LE_ADAPTER'])
+        print "CA Transport is BLE"
+    else:
+        env.AppendUnique(CPPDEFINES=['NO_LE_ADAPTER'])
 
-       if 'IP' in transport:
-               env.AppendUnique(CPPDEFINES = ['WIFI_ADAPTER'])
-               print "CA Transport is WIFI"
-       else:
-               env.AppendUnique(CPPDEFINES = ['NO_WIFI_ADAPTER'])
+    if 'IP' in transport:
+        env.AppendUnique(CPPDEFINES=['WIFI_ADAPTER'])
+        print "CA Transport is WIFI"
+    else:
+        env.AppendUnique(CPPDEFINES=['NO_WIFI_ADAPTER'])
 
-       if env.get('WITH_TCP'):
-               env.AppendUnique(CPPDEFINES = ['TCP_ADAPTER', 'WITH_TCP'])
-       else:
-               env.AppendUnique(CPPDEFINES = ['NO_TCP_ADAPTER'])
+    if env.get('WITH_TCP'):
+        env.AppendUnique(CPPDEFINES=['TCP_ADAPTER', 'WITH_TCP'])
+    else:
+        env.AppendUnique(CPPDEFINES=['NO_TCP_ADAPTER'])
 
 if 'SUB' in with_mq:
-       env.AppendUnique(CPPDEFINES = ['MQ_SUBSCRIBER', 'WITH_MQ'])
-       print "MQ SUB support"
+    env.AppendUnique(CPPDEFINES=['MQ_SUBSCRIBER', 'WITH_MQ'])
+    print "MQ SUB support"
 
 if 'PUB' in with_mq:
-       env.AppendUnique(CPPDEFINES = ['MQ_PUBLISHER', 'WITH_MQ'])
-       print "MQ PUB support"
+    env.AppendUnique(CPPDEFINES=['MQ_PUBLISHER', 'WITH_MQ'])
+    print "MQ PUB support"
 
 if 'BROKER' in with_mq:
-       env.AppendUnique(CPPDEFINES = ['MQ_BROKER', 'WITH_MQ'])
-       print "MQ Broker support"
+    env.AppendUnique(CPPDEFINES=['MQ_BROKER', 'WITH_MQ'])
+    print "MQ Broker support"
 
-env.SConscript(['../resource/SConscript'])
+SConscript(env.get('BUILD_DIR') + 'resource/SConscript')
index 0904e16..abdd263 100644 (file)
@@ -20,7 +20,7 @@
 
 import os
 import os.path
-from tools.scons.RunTest import *
+from tools.scons.RunTest import run_test
 
 Import('test_env')
 
@@ -32,45 +32,50 @@ rd_mode = stacktest_env.get('RD_MODE')
 ######################################################################
 # Build flags
 ######################################################################
-stacktest_env.PrependUnique(CPPPATH = [
-        '../../security/include',
-        '../../ocsocket/include',
-        '../../logger/include',
-        '../../../c_common/ocrandom/include',
-        '../../include',
-        '../../stack/include',
-        '../../stack/include/internal',
-        '../../connectivity/api',
-        '../../connectivity/inc/pkix',
-        '../../connectivity/external/inc',
-        '../../../oc_logger/include',
-        ])
+stacktest_env.PrependUnique(CPPPATH=[
+    '../../security/include',
+    '../../ocsocket/include',
+    '../../logger/include',
+    '../../../c_common/ocrandom/include',
+    '../../include',
+    '../../stack/include',
+    '../../stack/include/internal',
+    '../../connectivity/api',
+    '../../connectivity/inc/pkix',
+    '../../connectivity/external/inc',
+    '../../../oc_logger/include',
+])
 
-stacktest_env.PrependUnique(LIBS = ['octbstack_internal',
-                                    'ocsrm',
-                                    'routingmanager',
-                                    'connectivity_abstraction_internal',
-                                    'coap',
-                                    ])
+stacktest_env.PrependUnique(LIBS=[
+    'octbstack_internal',
+    'ocsrm',
+    'routingmanager',
+    'connectivity_abstraction_internal',
+    'coap',
+])
 
 if stacktest_env.get('SECURED') == '1':
-    stacktest_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509'])
+    stacktest_env.AppendUnique(LIBS=['mbedtls', 'mbedx509'])
 
 # c_common calls into mbedcrypto.
-stacktest_env.AppendUnique(LIBS = ['mbedcrypto'])
+stacktest_env.AppendUnique(LIBS=['mbedcrypto'])
 
-if 'CLIENT' in rd_mode and target_os not in ['arduino', 'darwin', 'ios', 'windows', 'winrt']:
-    stacktest_env.PrependUnique(LIBS = ['oc', 'oc_logger'])
+if 'CLIENT' in rd_mode and target_os not in [
+        'arduino', 'darwin', 'ios', 'windows', 'winrt'
+]:
+    stacktest_env.PrependUnique(LIBS=['oc', 'oc_logger'])
 if 'SERVER' in rd_mode:
     if target_os in ['linux', 'tizen']:
         stacktest_env.ParseConfig('pkg-config --cflags --libs sqlite3')
     elif target_os in ['msys_nt', 'windows']:
-        stacktest_env.PrependUnique(LIBS = ['sqlite3'])
+        stacktest_env.PrependUnique(LIBS=['sqlite3'])
 
 if target_os not in ['msys_nt', 'windows']:
-    stacktest_env.PrependUnique(LIBS = ['m'])
+    stacktest_env.PrependUnique(LIBS=['m'])
+
     if target_os in ['tizen', 'linux']:
-        stacktest_env.ParseConfig("pkg-config --cflags --libs gobject-2.0 gio-2.0 glib-2.0")
+        stacktest_env.ParseConfig(
+            "pkg-config --cflags --libs gobject-2.0 gio-2.0 glib-2.0")
 
 ######################################################################
 # Source files and Targets
@@ -83,9 +88,9 @@ Alias("test", [stacktests, cbortests])
 stacktest_env.AppendTarget('test')
 if stacktest_env.get('TEST') == '1':
     if target_os in ['linux', 'windows']:
-                run_test(stacktest_env,
-                         'resource_csdk_stack_test.memcheck',
-                         'resource/csdk/stack/test/stacktests')
-                run_test(stacktest_env,
-                         'resource_csdk_stack_test.memcheck',
-                         'resource/csdk/stack/test/cbortests')
+        run_test(stacktest_env,
+                 'resource_csdk_stack_test.memcheck',
+                 'resource/csdk/stack/test/stacktests')
+        run_test(stacktest_env,
+                 'resource_csdk_stack_test.memcheck',
+                 'resource/csdk/stack/test/cbortests')