Add stack logging flag to scons build parameters.
authorJoseph Morrow <joseph.l.morrow@intel.com>
Mon, 6 Apr 2015 17:00:37 +0000 (13:00 -0400)
committerErich Keane <erich.keane@intel.com>
Tue, 7 Apr 2015 16:26:18 +0000 (16:26 +0000)
This will allow people to build debug versions of the stack without
actually enabling all the stack debug logs. This is useful (for instance)
when you may want to run unit tests in debug mode (ie. with no optimizat-
ion and full debug symbols), run without stack logging noise, and run
valgrind as the CI (ie. build) system does. The default values of when
logging will be enabled remain the same as before, except the default for
stack logging when building/running the unit tests is disabled. You may
change this by simply adding "LOGGING=1" or "LOGGING=true" to the list
of scons options, however.

Change-Id: I70cedc9143c6015fd75bf4725cf72b6a64b8529e
Signed-off-by: Joseph Morrow <joseph.l.morrow@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/657
Reviewed-by: Erich Keane <erich.keane@intel.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
13 files changed:
arduino.scons
auto_build.sh
build_common/SConscript
build_common/linux/SConscript
resource/csdk/SConscript
resource/csdk/connectivity/build/android/SConscript
resource/csdk/connectivity/build/arduino/arduino.scons
resource/csdk/connectivity/build/linux/SConscript
resource/csdk/connectivity/build/tizen/scons/SConscript
resource/csdk/connectivity/lib/libcoap-4.1.1/SConscript
resource/csdk/connectivity/test/SConscript
resource/csdk/stack/test/SConscript
resource/unittests/SConscript

index 143b114..01da529 100644 (file)
@@ -35,7 +35,6 @@ if 'BLE' in env.get('TARGET_TRANSPORT'):
 
 env.ImportLib('Time/Time')
 # we have variety of macros for arduino!!
-if env.get('RELEASE'):
-       env.AppendUnique(CPPDEFINES = ['WITH_ARDUINO', '__ARDUINO__'])
-else:
-       env.AppendUnique(CPPDEFINES = ['WITH_ARDUINO', '__ARDUINO__', 'TB_LOG'])
+env.AppendUnique(CPPDEFINES = ['WITH_ARDUINO', '__ARDUINO__'])
+if env.get('LOGGING'):
+       env.AppendUnique(CPPDEFINES = ['TB_LOG'])
index 820041f..8ec37e0 100755 (executable)
@@ -102,6 +102,6 @@ fi
 export SCONSFLAGS="-Q -j 8"
 build $1 $2 true
 build $1 $2 false
-scons resource TEST=1
+scons resource TEST=1 RELEASE=false
 echo "===================== done ====================="
 
index 7aeb302..3ae69c1 100644 (file)
@@ -50,6 +50,13 @@ target_arch = ARGUMENTS.get('TARGET_ARCH', default_arch) # target arch
 # set to 'no', 'false' or 0 for only compilation
 require_upload = ARGUMENTS.get('UPLOAD', False) 
 
+if ARGUMENTS.get('TEST'):
+       logging_default = False
+else:
+       logging_default = (ARGUMENTS.get('RELEASE', True) == 'false')
+
+
+
 ######################################################################
 # Common build options (release, target os, target arch)
 ######################################################################
@@ -68,6 +75,7 @@ else:
 help_vars.Add(EnumVariable('TARGET_ARCH', 'Target architecture', default_arch, os_arch_map[target_os]))
 help_vars.Add(EnumVariable('SECURED', 'Build with DTLS', '0', allowed_values=('0', '1')))
 help_vars.Add(EnumVariable('TEST', 'Run unit tests', '0', allowed_values=('0', '1')))
+help_vars.Add(BoolVariable('LOGGING', 'Enable stack logging', logging_default))
 help_vars.Add(BoolVariable('UPLOAD', 'Upload binary ? (For Arduino)', require_upload))
 help_vars.Add(EnumVariable('BUILD_SAMPLE', 'Build with sample', 'ON', allowed_values=('ON', 'OFF')))
 ######################################################################
index c980107..6621814 100644 (file)
@@ -12,6 +12,8 @@ if env.get('RELEASE'):
        env.AppendUnique(CPPDEFINES = ['NDEBUG'])
 else:
        env.AppendUnique(CCFLAGS = ['-g'])
+
+if env.get('LOGGING'):
        env.AppendUnique(CPPDEFINES = ['-DTB_LOG'])
 
 env.AppendUnique(CPPDEFINES = ['WITH_POSIX', '__linux__'])
index a2367f9..c32cca0 100644 (file)
@@ -76,7 +76,7 @@ if target_os in ['darwin', 'ios']:
        liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
        liboctbstack_env.AppendUnique(LIBS = ['coap'])
 
-if not env.get('RELEASE'):
+if env.get('LOGGING'):
        liboctbstack_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
 
 ######################################################################
index 7a70b4a..3d5249a 100644 (file)
@@ -154,7 +154,9 @@ if env.get('RELEASE'):
 else:
        env.AppendUnique(CCFLAGS = ['-g'])
 
-env.AppendUnique(CPPDEFINES = ['WITH_POSIX', '__ANDROID__','-DTB_LOG'])
+env.AppendUnique(CPPDEFINES = ['WITH_POSIX', '__ANDROID__'])
+if env.get('LOGGING'):
+       env.AppendUnique(CPPDEFINES = ['-DTB_LOG'])
 env.AppendUnique(CCFLAGS = ['-Wall', '-fPIC','`pkg-config','--cflags','glib-2.0`'])
 env.AppendUnique(LINKFLAGS = ['-ldl', '-lpthread', '-lglib-2.0', '-lgthread-2.0', '-llog', '-landroid'])
 
index 911712b..36aac14 100644 (file)
@@ -14,7 +14,6 @@ if 'BLE' in env.get('TARGET_TRANSPORT'):
 
 env.ImportLib('Time/Time')
 # we have variety of macros for arduino!!
-if env.get('RELEASE'):
-       env.AppendUnique(CPPDEFINES = ['WITH_ARDUINO', '__ARDUINO__'])
-else:
-       env.AppendUnique(CPPDEFINES = ['WITH_ARDUINO', '__ARDUINO__', 'TB_LOG'])
+env.AppendUnique(CPPDEFINES = ['WITH_ARDUINO', '__ARDUINO__'])
+if env.get('LOGGING'):
+       env.AppendUnique(CPPDEFINES = ['TB_LOG'])
index 2233a72..cda841b 100644 (file)
@@ -12,6 +12,8 @@ if env.get('RELEASE'):
        env.AppendUnique(CPPDEFINES = ['NDEBUG'])
 else:
        env.AppendUnique(CCFLAGS = ['-g'])
+
+if env.get('LOGGING'):
        env.AppendUnique(CPPDEFINES = ['-DTB_LOG'])
 
 env.AppendUnique(CPPDEFINES = ['WITH_POSIX', '__linux__'])
index fc6df2b..318d954 100644 (file)
@@ -13,7 +13,10 @@ 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'])
 else:
-       env.AppendUnique(CFLAGS = ['-std=c99', '-fPIC', '-D__TIZEN__','-DWITH_POSIX', '-Wall', '-DSLP_SDK_LOG', '-g','-D_GNU_SOURCE','-DTIZEN_DEBUG_ENABLE', '-DTB_LOG'])
+       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 = ['-DTB_LOG'])
 
 env.ParseConfig("pkg-config --cflags --libs capi-network-wifi dlog glib-2.0")
 if 'ALL' in transport:
index a694c17..eb1491a 100644 (file)
@@ -44,7 +44,7 @@ if target_os == 'arduino':
 if target_os in ['darwin', 'ios']:
        libcoap_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
 
-if not env.get('RELEASE'):
+if env.get('LOGGING'):
        libcoap_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
 
 ######################################################################
index 7e08d8e..ac38019 100644 (file)
@@ -59,8 +59,8 @@ if env.get('SECURED') == '1':
     catest_env.AppendUnique(LIBS = ['tinydtls'])
 catest_env.ParseConfig('pkg-config --libs glib-2.0');
 
-if not env.get('RELEASE'):
-        catest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+if env.get('LOGGING'):
+       catest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
 
 ######################################################################
 # Source files and Targets
index 300eed7..64d2aac 100644 (file)
@@ -54,7 +54,7 @@ if env.get('SECURED') == '1':
     stacktest_env.AppendUnique(LIBS = ['tinydtls'])
 stacktest_env.ParseConfig('pkg-config --libs glib-2.0');
 
-if not env.get('RELEASE'):
+if env.get('LOGGING'):
        stacktest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
 
 ######################################################################
index 4f50aa1..4ecda8a 100644 (file)
@@ -57,7 +57,7 @@ if env.get('SECURED') == '1':
     unittests_env.AppendUnique(LIBS = ['tinydtls'])
 unittests_env.ParseConfig('pkg-config --libs glib-2.0');
 
-if not env.get('RELEASE'):
+if env.get('LOGGING'):
        unittests_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
 
 ######################################################################