build: Reformat resource/c_common SConscripts
authorMats Wichmann <mats@linux.com>
Sat, 3 Jun 2017 13:19:05 +0000 (07:19 -0600)
committerPhil Coval <philippe.coval@osg.samsung.com>
Wed, 28 Jun 2017 19:00:48 +0000 (19:00 +0000)
[Mats Wichmann]

Reformat all of the resource/c_common SConscripts to be more Pythonic

There are not intended to be any functional changes
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]

Ported to 1.3-rel from master

Conflicts:
resource/c_common/unittests/SConscript

Change-Id: I7957659932535f63f7e3e98a786b997c6a0dca3b
Signed-off-by: Mats Wichmann <mats@linux.com>
Origin: master
Bug: https://jira.iotivity.org/browse/IOT-1745
Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/20573
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Ziran Sun <ziran.sun@samsung.com>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
resource/c_common/SConscript
resource/c_common/ocrandom/test/SConscript
resource/c_common/oic_malloc/test/SConscript
resource/c_common/oic_string/test/SConscript
resource/c_common/oic_time/test/SConscript
resource/c_common/windows/SConscript
resource/c_common/windows/test/SConscript

index 1a7c4ff..e7e8581 100644 (file)
@@ -18,7 +18,6 @@
 #
 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
-
 Import('env')
 import os
 import datetime
@@ -30,13 +29,14 @@ src_dir = env.get('SRC_DIR')
 ######################################################################
 # Generate iotivity_config.h using presence of headers
 ######################################################################
-config_h_file_path = os.path.join(src_dir, 'resource', 'c_common', 'iotivity_config.h')
+config_h_file_path = os.path.join(src_dir, 'resource', 'c_common',
+                                  'iotivity_config.h')
 
 if (os.path.exists(config_h_file_path)) and (env.GetOption('clean')):
     os.remove(config_h_file_path)
 
 if (not os.path.isfile(config_h_file_path)) and (not env.GetOption('clean')):
-    conf = Configure(env.Clone(LIBS = []))
+    conf = Configure(env.Clone(LIBS=[]))
 
     config_h_header = '''
 /* ****************************************************************************
@@ -61,35 +61,37 @@ if (not os.path.isfile(config_h_file_path)) and (not env.GetOption('clean')):
 
 '''
 
-    cxx_headers = ['arpa/inet.h',
-                   'fcntl.h',
-                   'grp.h',
-                   'in6addr.h',
-                   'linux/limits.h',
-                   'memory.h',
-                   'net/if.h',
-                   'netdb.h',
-                   'netinet/in.h',
-                   'pthread.h',
-                   'pwd.h',
-                   'stdlib.h',
-                   'string.h',
-                   'strings.h',
-                   'sys/ioctl.h',
-                   'sys/poll.h',
-                   'sys/select.h',
-                   'sys/socket.h',
-                   'sys/stat.h',
-                   'sys/time.h',
-                   'sys/types.h',
-                   'sys/unistd.h',
-                   'syslog.h',
-                   'time.h',
-                   'unistd.h',
-                   'uuid/uuid.h',
-                   'windows.h',
-                   'winsock2.h',
-                   'ws2tcpip.h']
+    cxx_headers = [
+        'arpa/inet.h',
+        'fcntl.h',
+        'grp.h',
+        'in6addr.h',
+        'linux/limits.h',
+        'memory.h',
+        'net/if.h',
+        'netdb.h',
+        'netinet/in.h',
+        'pthread.h',
+        'pwd.h',
+        'stdlib.h',
+        'string.h',
+        'strings.h',
+        'sys/ioctl.h',
+        'sys/poll.h',
+        'sys/select.h',
+        'sys/socket.h',
+        'sys/stat.h',
+        'sys/time.h',
+        'sys/types.h',
+        'sys/unistd.h',
+        'syslog.h',
+        'time.h',
+        'unistd.h',
+        'uuid/uuid.h',
+        'windows.h',
+        'winsock2.h',
+        'ws2tcpip.h'
+    ]
 
     cxx_functions = ['strptime']
 
@@ -102,16 +104,18 @@ if (not os.path.isfile(config_h_file_path)) and (not env.GetOption('clean')):
         cxx_headers.remove('pthread.h')
 
     def get_define_from_string(header_file):
-        header_file_converted = header_file.replace("/","_").replace(".","_").upper()
+        header_file_converted = header_file.replace("/", "_").replace(".", "_").upper()
         return "HAVE_" + header_file_converted
 
     for header_file_name in cxx_headers:
         if conf.CheckCXXHeader(header_file_name):
-            config_h_body += "#define %s 1\n\n" % get_define_from_string(header_file_name)
+            config_h_body += "#define %s 1\n\n" % get_define_from_string(
+                header_file_name)
 
     for function_name in cxx_functions:
         if conf.CheckFunc(function_name):
-            config_h_body += "#define %s 1\n\n" % get_define_from_string(function_name)
+            config_h_body += "#define %s 1\n\n" % get_define_from_string(
+                function_name)
     conf.Finish()
 
     # Autoconf feature doesn't work with Jenkins' arduino toolchain, so hardcode it here.
@@ -131,14 +135,15 @@ if (not os.path.exists(config_h_file_path)) and (not env.GetOption('clean')):
     Exit(1)
 
 # iotivity_config.h should be copied to the build dir
-env.UserInstallTargetHeader(config_h_file_path, 'c_common', 'iotivity_config.h')
+env.UserInstallTargetHeader(
+    config_h_file_path, 'c_common', 'iotivity_config.h')
 
 # Use the generated file internally
-env.AppendUnique(CPPPATH = [os.path.join(src_dir, 'resource', 'c_common')])
+env.AppendUnique(CPPPATH=[os.path.join(src_dir, 'resource', 'c_common')])
 
 ######################################################################
 
-env.AppendUnique(CPPPATH = [
+env.AppendUnique(CPPPATH=[
     os.path.join(Dir('.').abspath, 'oic_malloc', 'include'),
     os.path.join(Dir('.').abspath, 'oic_string', 'include'),
     os.path.join(Dir('.').abspath, 'oic_time', 'include'),
@@ -147,11 +152,12 @@ env.AppendUnique(CPPPATH = [
     os.path.join(Dir('.').abspath, 'octhread', 'include'),
     os.path.join(Dir('.').abspath, 'oic_platform', 'include'),
     os.path.join(Dir('.').abspath, 'octimer', 'include'),
-   '#/extlibs/mbedtls/mbedtls/include'
+    '#/extlibs/mbedtls/mbedtls/include'
 ])
 
 if target_os not in ['tizen']:
-    env.AppendUnique(LIBPATH = [os.path.join(env.get('BUILD_DIR'), 'resource', 'c_common')])
+    env.AppendUnique(
+        LIBPATH=[os.path.join(env.get('BUILD_DIR'), 'resource', 'c_common')])
 
 if target_os in ['tizen', 'linux']:
     env.ParseConfig("pkg-config --cflags --libs uuid")
@@ -178,7 +184,7 @@ common_src = [
 
 if env['POSIX_SUPPORTED']:
     common_src.append('octhread/src/posix/octhread.c')
-elif target_os  in ['windows']:
+elif target_os in ['windows']:
     common_src.append('octhread/src/windows/octhread.c')
 else:
     common_src.append('octhread/src/noop/octhread.c')
@@ -198,22 +204,24 @@ else:
 # C++ Arduino's <Timer.h> is included so use C++ compiler/flags
 if target_os in ['arduino']:
     octimer_env = common_env.Clone()
-    octimer_env.Replace(CC = env.get('CXX'))
-    octimer_env.Replace(CFLAGS = env.get('CXXFLAGS'))
+    octimer_env.Replace(CC=env.get('CXX'))
+    octimer_env.Replace(CFLAGS=env.get('CXXFLAGS'))
     octimer = octimer_env.Object('octimer/src/octimer.c')
     common_src.append(octimer)
 else:
     common_src.append('octimer/src/octimer.c')
 
-common_env.AppendUnique(LIBS = ['logger'])
-common_env.AppendUnique(CPPPATH = ['#resource/csdk/logger/include'])
+common_env.AppendUnique(LIBS=['logger'])
+common_env.AppendUnique(CPPPATH=['#resource/csdk/logger/include'])
 commonlib = common_env.StaticLibrary('c_common', common_src)
 common_env.InstallTarget(commonlib, 'c_common')
 common_env.UserInstallTargetLib(commonlib, 'c_common')
-common_env.UserInstallTargetHeader('iotivity_debug.h', 'c_common', 'iotivity_debug.h')
-common_env.UserInstallTargetHeader('platform_features.h', 'c_common', 'platform_features.h')
+common_env.UserInstallTargetHeader(
+    'iotivity_debug.h', 'c_common', 'iotivity_debug.h')
+common_env.UserInstallTargetHeader(
+    'platform_features.h', 'c_common', 'platform_features.h')
 
 Clean(commonlib, config_h_file_path)
 
 # c_common calls into logger.
-env.PrependUnique(LIBS = ['c_common', 'logger'])
+env.PrependUnique(LIBS=['c_common', 'logger'])
index bc0150c..f874ea6 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,20 +32,20 @@ target_os = randomtest_env.get('TARGET_OS')
 # Build flags
 ######################################################################
 
-randomtest_env.PrependUnique(CPPPATH = [
-        '../include',
-               '../../logger/include',
-               '../../../oc_logger/include',
-               ])
-randomtest_env.PrependUnique(LIBS = ['uuid'])
+randomtest_env.PrependUnique(CPPPATH=[
+    '../include',
+    '../../logger/include',
+    '../../../oc_logger/include',
+])
+randomtest_env.PrependUnique(LIBS=['uuid'])
 
-randomtest_env.PrependUnique(CPPPATH = ['../include'])
+randomtest_env.PrependUnique(CPPPATH=['../include'])
 
 if target_os in ['linux']:
-    randomtest_env.AppendUnique(LIBS = ['m'])
+    randomtest_env.AppendUnique(LIBS=['m'])
 
 if randomtest_env.get('LOGGING'):
-       randomtest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+    randomtest_env.AppendUnique(CPPDEFINES=['TB_LOG'])
 
 ######################################################################
 # Source files and Targets
@@ -56,7 +56,6 @@ Alias("test", [randomtests])
 
 randomtest_env.AppendTarget('test')
 if randomtest_env.get('TEST') == '1':
-       if target_os in ['linux', 'windows']:
-                run_test(randomtest_env,
-                         'resource_csdk_random_test.memcheck',
-                         'resource/c_common/ocrandom/test/randomtests')
+    if target_os in ['linux', 'windows']:
+        run_test(randomtest_env, 'resource_csdk_random_test.memcheck',
+                 'resource/c_common/ocrandom/test/randomtests')
index 1450a09..a6bd067 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')
 
@@ -31,25 +31,26 @@ target_os = malloctest_env.get('TARGET_OS')
 ######################################################################
 # Build flags
 ######################################################################
-malloctest_env.PrependUnique(CPPPATH = [
-        '../include'])
+malloctest_env.PrependUnique(CPPPATH=['../include'])
 
-malloctest_env.AppendUnique(LIBPATH = [os.path.join(malloctest_env.get('BUILD_DIR'), 'resource', 'c_common')])
-malloctest_env.PrependUnique(LIBS = ['c_common'])
+malloctest_env.AppendUnique(LIBPATH=[
+    os.path.join(malloctest_env.get('BUILD_DIR'), 'resource', 'c_common')
+])
+malloctest_env.PrependUnique(LIBS=['c_common'])
 
 if malloctest_env.get('LOGGING'):
-       malloctest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+    malloctest_env.AppendUnique(CPPDEFINES=['TB_LOG'])
 #
 ######################################################################
 # Source files and Targets
 ######################################################################
-malloctests = malloctest_env.Program('malloctests', ['linux/oic_malloc_tests.cpp'])
+malloctests = malloctest_env.Program('malloctests',
+                                     ['linux/oic_malloc_tests.cpp'])
 
 Alias("test", [malloctests])
 
 malloctest_env.AppendTarget('test')
 if malloctest_env.get('TEST') == '1':
-       if target_os in ['linux', 'windows']:
-                run_test(malloctest_env,
-                         'resource_ccommon_malloc_test.memcheck',
-                         'resource/c_common/oic_malloc/test/malloctests')
+    if target_os in ['linux', 'windows']:
+        run_test(malloctest_env, 'resource_ccommon_malloc_test.memcheck',
+                 'resource/c_common/oic_malloc/test/malloctests')
index a0e10e2..69e17f1 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')
 
@@ -31,24 +31,26 @@ target_os = stringtest_env.get('TARGET_OS')
 ######################################################################
 # Build flags
 ######################################################################
-stringtest_env.PrependUnique(CPPPATH = ['../include'])
+stringtest_env.PrependUnique(CPPPATH=['../include'])
 
-stringtest_env.AppendUnique(LIBPATH = [os.path.join(stringtest_env.get('BUILD_DIR'), 'resource', 'c_common')])
-stringtest_env.PrependUnique(LIBS = ['c_common'])
+stringtest_env.AppendUnique(LIBPATH=[
+    os.path.join(stringtest_env.get('BUILD_DIR'), 'resource', 'c_common')
+])
+stringtest_env.PrependUnique(LIBS=['c_common'])
 
 if stringtest_env.get('LOGGING'):
-    stringtest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+    stringtest_env.AppendUnique(CPPDEFINES=['TB_LOG'])
 #
 ######################################################################
 # Source files and Targets
 ######################################################################
-stringtests = stringtest_env.Program('stringtests', ['linux/oic_string_tests.cpp'])
+stringtests = stringtest_env.Program('stringtests',
+                                     ['linux/oic_string_tests.cpp'])
 
 Alias("test", [stringtests])
 
 stringtest_env.AppendTarget('test')
 if stringtest_env.get('TEST') == '1':
     if target_os in ['linux', 'windows']:
-                run_test(stringtest_env,
-                         'resource_ccommon_string_test.memcheck',
-                         'resource/c_common/oic_string/test/stringtests')
+        run_test(stringtest_env, 'resource_ccommon_string_test.memcheck',
+                 'resource/c_common/oic_string/test/stringtests')
index a0d616b..84cd42e 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')
 
@@ -31,14 +31,15 @@ target_os = timetest_env.get('TARGET_OS')
 ######################################################################
 # Build flags
 ######################################################################
-timetest_env.PrependUnique(CPPPATH = [
-        '../include'])
+timetest_env.PrependUnique(CPPPATH=['../include'])
 
-timetest_env.AppendUnique(LIBPATH = [os.path.join(timetest_env.get('BUILD_DIR'), 'resource', 'c_common')])
-timetest_env.PrependUnique(LIBS = ['c_common'])
+timetest_env.AppendUnique(LIBPATH=[
+    os.path.join(timetest_env.get('BUILD_DIR'), 'resource', 'c_common')
+])
+timetest_env.PrependUnique(LIBS=['c_common'])
 
 if timetest_env.get('LOGGING'):
-    timetest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+    timetest_env.AppendUnique(CPPDEFINES=['TB_LOG'])
 #
 ######################################################################
 # Source files and Targets
@@ -50,6 +51,5 @@ Alias("test", [timetests])
 timetest_env.AppendTarget('test')
 if timetest_env.get('TEST') == '1':
     if target_os in ['linux', 'windows']:
-                run_test(timetest_env,
-                         'resource_ccommon_time_test.memcheck',
-                         'resource/c_common/oic_time/test/timetests')
+        run_test(timetest_env, 'resource_ccommon_time_test.memcheck',
+                 'resource/c_common/oic_time/test/timetests')
index 2f98c61..eb0e22f 100644 (file)
@@ -6,33 +6,37 @@ import os.path
 
 # Include any headers that might be missing on Windows
 header = os.path.abspath('./include')
-env.AppendUnique(CPPPATH = [header])
-common_env.AppendUnique(CPPPATH = [header])
+env.AppendUnique(CPPPATH=[header])
+common_env.AppendUnique(CPPPATH=[header])
 
 ######################################################################
 # Source files and Targets
 ######################################################################
 src_dir = Dir('src').abspath
 helper_src = [
-       os.path.join(src_dir, 'getopt.c'),
-       os.path.join(src_dir, 'memmem.c'),
-       os.path.join(src_dir, 'win_sleep.c'),
-       os.path.join(src_dir, 'snprintf.c'),
-       os.path.join(src_dir, 'pthread_create.c')
-       ]
+    os.path.join(src_dir, 'getopt.c'),
+    os.path.join(src_dir, 'memmem.c'),
+    os.path.join(src_dir, 'win_sleep.c'),
+    os.path.join(src_dir, 'snprintf.c'),
+    os.path.join(src_dir, 'pthread_create.c')
+]
 
 win_helper_env = common_env.Clone()
 
-win_helper_env.AppendUnique(CPPPATH = ['#resource/csdk/logger/include'])
+win_helper_env.AppendUnique(CPPPATH=['#resource/csdk/logger/include'])
 static_libwinhelper = win_helper_env.StaticLibrary('win_helper', helper_src)
 
 win_helper_env.InstallTarget(static_libwinhelper, 'win_helper')
 win_helper_env.UserInstallTargetLib(static_libwinhelper, 'win_helper')
-win_helper_env.UserInstallTargetHeader('include/memmem.h', 'c_common/windows/include', 'memmem.h')
-win_helper_env.UserInstallTargetHeader('include/win_sleep.h', 'c_common/windows/include', 'win_sleep.h')
-win_helper_env.UserInstallTargetHeader('include/pthread_create.h', 'c_common/windows/include', 'pthread_create.h')
-win_helper_env.UserInstallTargetHeader('include/vs12_snprintf.h', 'c_common/windows/include', 'vs12_snprintf.h')
+win_helper_env.UserInstallTargetHeader(
+    'include/memmem.h', 'c_common/windows/include', 'memmem.h')
+win_helper_env.UserInstallTargetHeader(
+    'include/win_sleep.h', 'c_common/windows/include', 'win_sleep.h')
+win_helper_env.UserInstallTargetHeader(
+    'include/pthread_create.h', 'c_common/windows/include', 'pthread_create.h')
+win_helper_env.UserInstallTargetHeader(
+    'include/vs12_snprintf.h', 'c_common/windows/include', 'vs12_snprintf.h')
 
 helper_lib = ['win_helper']
-env.AppendUnique(LIBS = helper_lib)
-common_env.AppendUnique(LIBS = helper_lib)
+env.AppendUnique(LIBS=helper_lib)
+common_env.AppendUnique(LIBS=helper_lib)
index fae8637..c0b4c87 100644 (file)
@@ -19,7 +19,7 @@
 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
 import os.path
-from tools.scons.RunTest import *
+from tools.scons.RunTest import run_test
 
 Import('test_env')
 
@@ -28,18 +28,22 @@ c_common_windows_test_env = test_env.Clone()
 ######################################################################
 # Build flags
 ######################################################################
-c_common_windows_test_env.PrependUnique(CPPPATH = ['../include'])
+c_common_windows_test_env.PrependUnique(CPPPATH=['../include'])
 
-c_common_windows_test_env.AppendUnique(LIBPATH = [os.path.join(c_common_windows_test_env.get('BUILD_DIR'), 'resource', 'c_common')])
-c_common_windows_test_env.PrependUnique(LIBS = ['win_helper'])
+c_common_windows_test_env.AppendUnique(LIBPATH=[
+    os.path.join(
+        c_common_windows_test_env.get('BUILD_DIR'), 'resource', 'c_common')
+])
+c_common_windows_test_env.PrependUnique(LIBS=['win_helper'])
 
 if c_common_windows_test_env.get('LOGGING'):
-    c_common_windows_test_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+    c_common_windows_test_env.AppendUnique(CPPDEFINES=['TB_LOG'])
 
 ######################################################################
 # Source files and Targets
 ######################################################################
-c_common_windows_tests = c_common_windows_test_env.Program('c_common_windows_tests', ['snprintf_test.cpp'])
+c_common_windows_tests = c_common_windows_test_env.Program(
+    'c_common_windows_tests', ['snprintf_test.cpp'])
 
 Alias("test", [c_common_windows_tests])