easy-setup: Removing redundant env configuration 25/21325/10
authorPawel Winogrodzki <pawelwi@microsoft.com>
Thu, 6 Jul 2017 23:31:48 +0000 (16:31 -0700)
committerMats Wichmann <mats@linux.com>
Tue, 29 Aug 2017 14:52:13 +0000 (14:52 +0000)
Moving global environment configuration common for all
platforms into build_common/SConscript and removing repeated
lines from service/easy-setup/*.

Bug: https://jira.iotivity.org/browse/IOT-1583
Change-Id: I76cf82bacb36d95574f5d716c01cd1d7fb7e4f5f
Signed-off-by: Pawel Winogrodzki <pawelwi@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/21325
Reviewed-by: George Nash <george.nash@intel.com>
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Mats Wichmann <mats@linux.com>
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
service/easy-setup/enrollee/SConscript
service/easy-setup/enrollee/unittests/SConscript
service/easy-setup/mediator/richsdk/SConscript
service/easy-setup/mediator/richsdk/unittests/SConscript
service/easy-setup/sampleapp/enrollee/arduino/SConscript
service/easy-setup/sampleapp/enrollee/linux/SConscript
service/easy-setup/sampleapp/enrollee/tizen-sdb/EnrolleeSample/scons/SConscript
service/easy-setup/sampleapp/mediator/linux/richsdk_sample/SConscript

index ef24090..9dccd48 100644 (file)
@@ -28,18 +28,16 @@ target_os = enrollee_env.get('TARGET_OS')
 
 if enrollee_env.get('RELEASE'):
     enrollee_env.AppendUnique(CCFLAGS=['-Os'])
-    enrollee_env.AppendUnique(CPPDEFINES=['NDEBUG'])
 else:
     enrollee_env.AppendUnique(CCFLAGS=['-g'])
 
-if enrollee_env.get('LOGGING'):
-    enrollee_env.AppendUnique(CPPDEFINES=['TB_LOG'])
-
 ######################################################################
 # Build flags
 ######################################################################
 enrollee_env.PrependUnique(CPPPATH=[
+    '#/resource/c_common',
     '#/resource/c_common/oic_malloc/include',
+    '#/resource/c_common/oic_string/include',
     '#/resource/include',
     '#/resource/csdk/logger/include',
     '#/resource/oc_logger/include',
@@ -76,10 +74,9 @@ if not env.get('RELEASE'):
 # Linux Enrollee
 ######################################################################
 if target_os in ['linux']:
-    enrollee_env.AppendUnique(LIBS=['pthread', 'dl'])
-    enrollee_env.AppendUnique(LIBPATH=[enrollee_env.get('BUILD_DIR')])
+    enrollee_env.AddPthreadIfNeeded()
+    enrollee_env.AppendUnique(LIBS=['dl'])
     enrollee_env.AppendUnique(RPATH=[enrollee_env.get('BUILD_DIR')])
-    enrollee_env.AppendUnique(CXXFLAGS=['-pthread'])
     enrollee_env.PrependUnique(LIBS=[
         'oc',
         'octbstack',
@@ -94,7 +91,6 @@ if target_os in ['linux']:
 # Tizen Enrollee
 ######################################################################
 if target_os == 'tizen':
-    enrollee_env.AppendUnique(LIBPATH=[enrollee_env.get('BUILD_DIR')])
     enrollee_env.AppendUnique(RPATH=[enrollee_env.get('BUILD_DIR')])
     enrollee_env.AppendUnique(CXXFLAGS=['-pthread'])
     enrollee_env.PrependUnique(LIBS=[
@@ -109,7 +105,6 @@ if target_os == 'tizen':
 # Arduino Enrollee
 ######################################################################
 if target_os == 'arduino':
-    enrollee_env.AppendUnique(LIBPATH=[enrollee_env.get('BUILD_DIR')])
     enrollee_env.AppendUnique(RPATH=[enrollee_env.get('BUILD_DIR')])
     enrollee_env.PrependUnique(LIBS=[
         'oc',
index f1a8b60..958f1c5 100644 (file)
@@ -64,8 +64,7 @@ if target_os not in ['windows', 'winrt']:
     easysetup_test_env.AppendUnique(
         CXXFLAGS=['-O2', '-g', '-Wall', '-fmessage-length=0', '-std=c++0x'])
 
-easysetup_test_env.AppendUnique(CXXFLAGS=['-pthread'])
-easysetup_test_env.AppendUnique(LIBS=['pthread'])
+easysetup_test_env.AddPthreadIfNeeded()
 
 easysetup_test_env.PrependUnique(CPPPATH=[
     '#/extlibs/hippomocks/hippomocks',
index 6829e9e..66ca5ea 100644 (file)
@@ -26,14 +26,16 @@ Import('env')
 
 easysetup_path = os.curdir
 
-if env.get('RELEASE'):
-    env.AppendUnique(CCFLAGS=['-Os'])
-    env.AppendUnique(CPPDEFINES=['NDEBUG'])
-else:
-    env.AppendUnique(CCFLAGS=['-g'])
+# Add third party libraries
+lib_env = env.Clone()
+SConscript('#service/third_party_libs.scons', 'lib_env')
 
-if env.get('LOGGING'):
-    env.AppendUnique(CPPDEFINES=['TB_LOG'])
+easy_setup_env = lib_env.Clone()
+
+if easy_setup_env.get('RELEASE'):
+    easy_setup_env.AppendUnique(CCFLAGS=['-Os'])
+else:
+    easy_setup_env.AppendUnique(CCFLAGS=['-g'])
 
 # Easysetup provides reference implemenation of Arduino Enrollee.
 # Mediator applications developed on different platforms will be default defining the
@@ -45,13 +47,7 @@ target_enrollee = env.get('ES_TARGET_ENROLLEE')
 if target_enrollee == 'arduino':
     print "REMOTE_ARDUINO_ENROLEE flag is defined."
     print "The Mediator application will be working only with Arduino Enrollee."
-    env.AppendUnique(CPPDEFINES=['REMOTE_ARDUINO_ENROLEE'])
-
-# Add third party libraries
-lib_env = env.Clone()
-SConscript('#service/third_party_libs.scons', 'lib_env')
-
-easy_setup_env = lib_env.Clone()
+    easy_setup_env.AppendUnique(CPPDEFINES=['REMOTE_ARDUINO_ENROLEE'])
 target_os = env.get('TARGET_OS')
 
 ######################################################################
@@ -61,6 +57,9 @@ easy_setup_env.AppendUnique(CPPPATH=[
     'inc',
     'src',
     '../../inc',
+    '#/resource/c_common',
+    '#/resource/c_common/oic_malloc/include',
+    '#/resource/c_common/oic_string/include',
     '#/resource/include',
     '#/resource/csdk/include',
     '#/resource/csdk/stack/include',
@@ -71,10 +70,11 @@ if target_os not in ['windows']:
     easy_setup_env.AppendUnique(CXXFLAGS=['-Wall', '-std=c++0x'])
 
 if target_os in ['linux', 'tizen']:
-    easy_setup_env.AppendUnique(LIBS=['pthread', 'dl', 'coap'])
+    easy_setup_env.AppendUnique(LIBS=['dl', 'coap'])
+
+easy_setup_env.AddPthreadIfNeeded()
 
 if target_os in ['android']:
-    easy_setup_env.AppendUnique(LIBPATH=[env.get('BUILD_DIR')])
     if env.get('SECURED') == '1':
         easy_setup_env.AppendUnique(LIBPATH=[
             env.get('SRC_DIR') +
@@ -95,7 +95,6 @@ if target_os in ['android']:
         easy_setup_env.AppendUnique(LIBS=['log'])
 
 if target_os in ['linux', 'tizen']:
-    easy_setup_env.AppendUnique(LIBPATH=[env.get('BUILD_DIR')])
     easy_setup_env.AppendUnique(RPATH=[env.get('BUILD_DIR')])
     easy_setup_env.AppendUnique(CXXFLAGS=['-pthread'])
     easy_setup_env.PrependUnique(LIBS=[
@@ -155,7 +154,7 @@ es_src = None
 
 if target_os in ['android', 'ios', 'linux', 'tizen']:
     if env.get('SECURED') == '1':
-        env.AppendUnique(
+        easy_setup_env.AppendUnique(
             es_src=[os.path.join(easysetup_path, 'src/EnrolleeSecurity.cpp')])
 
     es_common_src = [
@@ -166,14 +165,14 @@ if target_os in ['android', 'ios', 'linux', 'tizen']:
         'src/ESException.cpp',
     ]
 
-    env.AppendUnique(es_src=es_common_src)
+    easy_setup_env.AppendUnique(es_src=es_common_src)
 
     es_sdk_static = easy_setup_env.StaticLibrary('ESMediatorRich',
-                                                 env.get('es_src'))
+                                                 easy_setup_env.get('es_src'))
     easy_setup_env.InstallTarget(es_sdk_static, 'libESMediatorRich')
     if target_os not in ['ios']:
         es_sdk_shared = easy_setup_env.SharedLibrary('ESMediatorRich',
-                                                     env.get('es_src'))
+                                                     easy_setup_env.get('es_src'))
         easy_setup_env.UserInstallTargetLib(es_sdk_shared, 'libESMediatorRich')
         easy_setup_env.AppendUnique(
             LINKFLAGS=['-Wl,-soname,libESMediatorRich.so'])
index fdf5097..6818aed 100644 (file)
@@ -63,8 +63,7 @@ if target_os not in ['windows', 'winrt']:
     easysetup_test_env.AppendUnique(
         CXXFLAGS=['-O2', '-g', '-Wall', '-fmessage-length=0', '-std=c++0x'])
 
-easysetup_test_env.AppendUnique(CXXFLAGS=['-pthread'])
-easysetup_test_env.AppendUnique(LIBS=['pthread'])
+easysetup_test_env.AddPthreadIfNeeded()
 
 easysetup_test_env.PrependUnique(CPPPATH=[
     '#/extlibs/hippomocks/hippomocks',
index 9bbbc5d..4c8a2db 100644 (file)
@@ -44,9 +44,7 @@ enrollee_env.PrependUnique(CPPPATH=[
     env.get('SRC_DIR') + '/service/easy-setup/enrollee/src'
 ])
 
-enrollee_env.AppendUnique(CPPDEFINES=['TB_LOG', 'ESWIFI'])
-
-enrollee_env.AppendUnique(LIBPATH=[env.get('BUILD_DIR')])
+enrollee_env.AppendUnique(CPPDEFINES=['ESWIFI'])
 
 enrollee_env.PrependUnique(LIBS=[
     'octbstack',
index b9cf40c..5ecdbd3 100644 (file)
 # Build script for Linux Enrollee Sample App
 ######################################################################
 
-Import('env')
+import os
 
-print Dir('#').abspath
-print Dir('.').abspath
+Import('env')
 
 enrollee_env = env.Clone()
 transport = enrollee_env.get('TARGET_TRANSPORT')
@@ -32,30 +31,28 @@ transport = enrollee_env.get('TARGET_TRANSPORT')
 ######################################################################
 # Build flags
 ######################################################################
-enrollee_env.AppendUnique(LIBPATH=[env.get('BUILD_DIR')])
 enrollee_env.AppendUnique(CXXFLAGS=['-Wall', '-std=c++0x'])
 
 if env.get('RELEASE'):
     enrollee_env.AppendUnique(CCFLAGS=['-Os'])
-    enrollee_env.AppendUnique(CPPDEFINES=['NDEBUG'])
 else:
     enrollee_env.AppendUnique(CCFLAGS=['-g'])
 
-if env.get('LOGGING'):
-    env.AppendUnique(CPPDEFINES=['TB_LOG'])
-
 enrollee_env.PrependUnique(CPPPATH=[
-    env.get('SRC_DIR') + '/resource/include',
-    env.get('SRC_DIR') + '/resource/oc_logger/include',
-    env.get('SRC_DIR') + '/resource/csdk/logger/include',
-    env.get('SRC_DIR') + '/resource/csdk/include',
-    env.get('SRC_DIR') + '/resource/csdk/security/include',
-    env.get('SRC_DIR') + '/resource/csdk/stack/include',
-    env.get('SRC_DIR') + '/extlibs/cjson',
-    env.get('SRC_DIR') + '/service/easy-setup/inc',
-    env.get('SRC_DIR') + '/service/easy-setup/enrollee/linux/wifi',
-    env.get('SRC_DIR') + '/service/easy-setup/enrollee/inc',
-    env.get('SRC_DIR') + '/service/easy-setup/enrollee/src'
+    '#/resource/include',
+    '#/resource/c_common',
+    '#/resource/c_common/oic_malloc/include',
+    '#/resource/c_common/oic_string/include',
+    '#/resource/oc_logger/include',
+    '#/resource/csdk/logger/include',
+    '#/resource/csdk/include',
+    '#/resource/csdk/security/include',
+    '#/resource/csdk/stack/include',
+    '#/extlibs/cjson',
+    '#/service/easy-setup/inc',
+    '#/service/easy-setup/enrollee/linux/wifi',
+    '#/service/easy-setup/enrollee/inc',
+    '#/service/easy-setup/enrollee/src',
 ])
 
 enrollee_env.PrependUnique(LIBS=[
index fb8b528..c611677 100644 (file)
@@ -34,8 +34,8 @@ env.ParseConfig(
 )
 env.AppendUnique(CPPFLAGS=[
     '-fPIC', '-D__TIZEN__', '-DWITH_POSIX', '-Wall', '-DSLP_SDK_LOG', '-g',
-    '-D_GNU_SOURCE', '-DTIZEN_DEBUG_ENABLE', '-DTB_LOG', '`pkg-config',
-    '--cflags', '--libs', 'iotivity', 'dlog', 'capi-network-wifi',
+    '-D_GNU_SOURCE', '-DTIZEN_DEBUG_ENABLE',
+    '`pkg-config', '--cflags', '--libs', 'iotivity', 'dlog', 'capi-network-wifi',
     'gobject-2.0', 'gio-2.0', 'gthread-2.0', 'glib-2.0`'
 ])
 
index 7a50f60..280fd72 100644 (file)
@@ -18,6 +18,8 @@
 #
 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
+import os
+
 Import('env')
 
 mediator_env = env.Clone()
@@ -27,38 +29,35 @@ target_os = env.get('TARGET_OS')
 ######################################################################
 # Build flags
 ######################################################################
-mediator_env.AppendUnique(LIBPATH=[env.get('BUILD_DIR')])
 
 if env.get('RELEASE'):
     mediator_env.AppendUnique(CCFLAGS=['-Os'])
-    mediator_env.AppendUnique(CPPDEFINES=['NDEBUG'])
 else:
     mediator_env.AppendUnique(CCFLAGS=['-g'])
 
-if env.get('LOGGING'):
-    env.AppendUnique(CPPDEFINES=['TB_LOG'])
-
-env.AppendUnique(CPPDEFINES=['CPP_MEDIATOR'])
+mediator_env.AppendUnique(CPPDEFINES=['CPP_MEDIATOR'])
 
 if target_os not in ['windows']:
     mediator_env.AppendUnique(CXXFLAGS=['-Wall', '-std=c++0x'])
 
 mediator_env.PrependUnique(CPPPATH=[
-    env.get('SRC_DIR') + '/resource/include',
-    env.get('SRC_DIR') + '/resource/oc_logger/include',
-    env.get('SRC_DIR') + '/resource/c_common/oic_malloc/include',
-    env.get('SRC_DIR') + '/resource/csdk/include',
-    env.get('SRC_DIR') + '/resource/csdk/stack/include',
-    env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include',
-    env.get('SRC_DIR') +
-    '/resource/csdk/security/provisioning/include/internal',
-    env.get('SRC_DIR') + '/resource/csdk/logger/include',
-    env.get('SRC_DIR') + '/resource/csdk/security/include',
-    env.get('SRC_DIR') + '/resource/csdk/connectivity/api',
-    env.get('SRC_DIR') + '/extlibs/cjson',
-    env.get('SRC_DIR') + '/service/easy-setup/mediator/richsdk/inc',
-    env.get('SRC_DIR') + '/service/easy-setup/mediator/richsdk/src',
-    env.get('SRC_DIR') + '/service/easy-setup/inc'
+    '#/resource/include',
+    '#/resource/oc_logger/include',
+    '#/resource/c_common',
+    '#/resource/c_common/ocrandom/include',
+    '#/resource/c_common/oic_malloc/include',
+    '#/resource/c_common/oic_string/include',
+    '#/resource/csdk/include',
+    '#/resource/csdk/stack/include',
+    '#/resource/csdk/security/provisioning/include',
+    '#/resource/csdk/security/provisioning/include/internal',
+    '#/resource/csdk/logger/include',
+    '#/resource/csdk/security/include',
+    '#/resource/csdk/connectivity/api',
+    '#/extlibs/cjson',
+    '#/service/easy-setup/mediator/richsdk/inc',
+    '#/service/easy-setup/mediator/richsdk/src',
+    '#/service/easy-setup/inc',
 ])
 
 if env.get('SECURED') == '1':