Fix build error with scons-4.4.0 version which is based on python3
[platform/upstream/iotivity.git] / build_common / SConscript
old mode 100644 (file)
new mode 100755 (executable)
index b373665..ea739b2
@@ -19,7 +19,7 @@ host_target_map = {
 # Map of os and allowed archs (os: allowed archs)
 os_arch_map = {
                'linux': ['x86', 'x86_64', 'arm', 'arm-v7a', 'armeabi-v7a', 'arm64'],
-               'tizen': ['x86', 'x86_64', 'arm', 'arm-v7a', 'armeabi-v7a', 'arm64'],
+               'tizen': ['x86', 'x86_64', 'arm', 'arm-v7a', 'armeabi-v7a', 'arm64', 'riscv64'],
                'android': ['x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'armeabi-v7a-hard', 'arm64-v8a'],
                'windows': ['x86', 'amd64', 'arm'],
                'msys_nt':['x86', 'x86_64'],
@@ -37,8 +37,8 @@ host = platform.system().lower()
 if 'msys_nt' in host:
        host = 'msys_nt'
 
-if not host_target_map.has_key(host):
-       print "\nError: Current system (%s) isn't supported\n" % host
+if host not in host_target_map:
+       print(("\nError: Current system (%s) isn't supported\n" % host))
        Exit(1)
 
 ######################################################################
@@ -47,7 +47,7 @@ if not host_target_map.has_key(host):
 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])
+       print(("\nError: Unknown target os: %s (Allow values: %s)\n" % (target_os, host_target_map[host])))
        Exit(1)
 
 if target_os == 'android':
@@ -80,7 +80,7 @@ else:
 # targets that do not support the DTLS build (SECURED=1 build option)
 targets_without_dtls_support = ['arduino'];
 if ARGUMENTS.get('SECURED') == '1' and target_os in targets_without_dtls_support:
-       print "\nError: DTLS not supported on target os: %s MUST build with SECURED=0\n" % (target_os)
+       print(("\nError: DTLS not supported on target os: %s MUST build with SECURED=0\n" % (target_os)))
        Exit(1)
 
 ######################################################################
@@ -96,15 +96,18 @@ help_vars.Add(EnumVariable('TARGET_OS', 'Target platform', host, host_target_map
 
 help_vars.Add(BoolVariable('WITH_RA', 'Build with Remote Access module', False))
 help_vars.Add(BoolVariable('WITH_TCP', 'Build with TCP adapter', False))
+help_vars.Add(BoolVariable('DISABLE_TCP_SERVER', 'Disable TCP server', False))
 help_vars.Add(BoolVariable('WITH_PROXY', 'Build with CoAP-HTTP Proxy', False))
 help_vars.Add(ListVariable('WITH_MQ', 'Build with MQ publisher/broker', 'OFF', ['OFF', 'SUB', 'PUB', 'BROKER']))
 help_vars.Add(BoolVariable('WITH_CLOUD', 'Build including AccountManager class and Cloud Client sample', False))
 help_vars.Add(ListVariable('RD_MODE', 'Resource Directory build mode', 'CLIENT', ['CLIENT', 'SERVER']))
+help_vars.Add(BoolVariable('DISABLE_PRESENCE', 'Disable Presence Feature', False))
+help_vars.Add(BoolVariable('DISABLE_BLE_SERVER', 'Disable BLE server', False))
 
 help_vars.Add(BoolVariable('SIMULATOR', 'Build with simulator module', False))
 
 help_vars.Add(BoolVariable('WITH_RA_IBB', 'Build with Remote Access module(workssys)', False))
-
+help_vars.Add(BoolVariable('WITH_ASAN', 'Build with Address Sanitizer support', False))
 
 if target_os in targets_disallow_multitransport:
        help_vars.Add(ListVariable('TARGET_TRANSPORT', 'Target transport', 'IP', ['BT', 'BLE', 'IP', 'NFC']))
@@ -130,9 +133,14 @@ help_vars.Add(EnumVariable('WITH_UPSTREAM_LIBCOAP', 'Use latest stable version o
 help_vars.Add(EnumVariable('BLE_CUSTOM_ADV', 'Build with CUSTOM Advertisement', 'False', allowed_values=('True', 'False')))
 help_vars.Add(EnumVariable('BLE_DIVISION', 'BLE Build with division code', 'OFF', allowed_values=('OFF', 'MCD', 'VD')))
 help_vars.Add(EnumVariable('BLE_TIZEN_30', 'Build with tizen 3.0 BLE api', 'False', allowed_values=('True', 'False')))
+help_vars.Add(EnumVariable('BLE_TIZEN_40', 'Build with tizen 4.0 BLE api', 'False', allowed_values=('True', 'False')))
+help_vars.Add(EnumVariable('BLE_TIZEN_55', 'Build with tizen 5.5 BLE api', 'False', allowed_values=('True', 'False')))
 help_vars.Add(PathVariable('TIZENRT_OS_DIR', 'Absolute Path to TizenRT OS directory', None, PathVariable.PathAccept))
 help_vars.Add(EnumVariable('PLATFORM_TLS', 'Use platform tls instead of local mbedtls', '0', allowed_values=('0', '1')))
 help_vars.Add(EnumVariable('OIC_SUPPORT_TIZEN_TRACE', 'Tizen Trace(T-trace) api availability', 'False', allowed_values=('True', 'False')))
+help_vars.Add(BoolVariable('WITH_PROCESS_EVENT','Build including process event logics in ocstack', 'False'))
+help_vars.Add(BoolVariable('DISABLE_AUTO_TCP_NSPROVIDER_DISCOVERY', 'Disable auto-discovery of NSProvider over TCP for TCP connected events', False))
+help_vars.Add(BoolVariable('ENABLE_DUP','Enable duplicate IPv4/IPv6 packets', 'False'))
 AddOption('--prefix',
                   dest='prefix',
                   type='string',
@@ -163,6 +171,17 @@ else:
                        PREFIX = GetOption('prefix'),
                        LIB_INSTALL_DIR = ARGUMENTS.get('LIB_INSTALL_DIR') #for 64bit build
                        )
+
+targets_support_gcov = ['linux', 'darwin']
+if target_os in targets_support_gcov:
+    # Build option to enable coverage checking using gcov.
+    # Requires gcc or clang family compilers.
+    # Actual compiler flags need to be set in target-specific script.
+    help_vars.Add(
+        BoolVariable('COVERAGE_CHECKS',
+                     'Build support for running code coverage checks',
+                      default=False))
+
 Help(help_vars.GenerateHelpText(env))
 
 tc_set_msg = '''
@@ -198,11 +217,11 @@ if target_os in targets_support_cc:
                env.AppendUnique(CCFLAGS = ['--sysroot=' + sys_root])
                env.AppendUnique(LINKFLAGS = ['--sysroot=' + sys_root])
 
-        if target_os == 'tizenrt':
+       if target_os == 'tizenrt':
                 env.PrependENVPath('PATH', os.environ['PATH'])
 
        if prefix or tc_path:
-               print tc_set_msg
+               print(tc_set_msg)
 
 # If cross-compiling, honor environment settings for toolchain to avoid picking up native tools
 if os.environ.get('PKG_CONFIG') != None:
@@ -225,12 +244,12 @@ env.SConscriptChdir(1)
 
 def __set_dir(env, dir):
        if not os.path.exists(dir + '/SConstruct'):
-               print '''
+               print(('''
 *************************************** Error *********************************
 * The directory(%s) seems isn't a source code directory, no SConstruct file is
 * found. *
 *******************************************************************************
-''' % dir
+''' % dir))
                Exit(1)
 
        if env.get('RELEASE'):
@@ -352,6 +371,24 @@ if env.get('WITH_TCP'):
     if env.get('SECURED') == '1':
         defines.append('-D__WITH_TLS__=1')
 
+if env.get('DISABLE_TCP_SERVER'):
+       defines.append('-DDISABLE_TCP_SERVER=1')
+
+if env.get('DISABLE_PRESENCE') == False:
+    env.AppendUnique(CPPDEFINES = ['WITH_PRESENCE'])
+
+if env.get('DISABLE_BLE_SERVER'):
+    defines.append('-DDISABLE_BLE_SERVER=1')
+
+if env.get('WITH_PROCESS_EVENT'):
+    env.AppendUnique(CPPDEFINES=['WITH_PROCESS_EVENT'])
+
+if env.get('DISABLE_AUTO_TCP_NSPROVIDER_DISCOVERY'):
+       env.AppendUnique(CPPDEFINES = ['DISABLE_AUTO_TCP_NSPROVIDER_DISCOVERY'])
+
+if env.get('ENABLE_DUP'):
+        env.AppendUnique(CPPDEFINES = ['ENABLE_DUP'])
+
 libs = []
 if env.get('SECURED') == '1':
     defines.append('-D__WITH_DTLS__=1')
@@ -408,7 +445,7 @@ if target_os == "yocto":
         if os.environ['LDFLAGS'] != None:
             env.AppendUnique(LINKFLAGS = Split(os.environ['LDFLAGS']))
     except:
-        print "ERROR in Yocto cross-toolchain environment"
+        print("ERROR in Yocto cross-toolchain environment")
         Exit(1)
     '''
     Now reset TARGET_OS to linux so that all linux specific build configurations