Fix build error with scons-4.4.0 version which is based on python3
[platform/upstream/iotivity.git] / resource / csdk / connectivity / SConscript
index bec1000..eade6db 100644 (file)
@@ -7,59 +7,115 @@ Import('env')
 target_os = env.get('TARGET_OS')
 transport = env.get('TARGET_TRANSPORT')
 build_sample = env.get('BUILD_SAMPLE')
+with_ra = env.get('WITH_RA')
+with_tcp = env.get('WITH_TCP')
+disable_tcp_server = env.get('DISABLE_TCP_SERVER')
+disable_ble_server = env.get('DISABLE_BLE_SERVER')
+with_mq = env.get('WITH_MQ')
+ble_custom_adv = env.get('BLE_CUSTOM_ADV')
 
-print "Given Transport is %s" % transport
-print "Given OS is %s" % target_os
-print "BUILD_SAMPLE is %s" % build_sample
+print("Given Transport is %s" % transport)
+print("Given OS is %s" % target_os)
+print("BUILD_SAMPLE is %s" % build_sample)
+print("MQ flag is %s" % with_mq)
 
 targets_disallow_multitransport = ['arduino']
 
 if target_os in targets_disallow_multitransport:
     if ('ALL' in transport) or (len(transport) != 1):
-        print "*** Error invalid option values: TARGET_TRANSPORT"
-        print "%s disallowed until testing can validate use of multiple transports on %s %d" % (transport, target_os, len(transport))
+        print("*** Error invalid option values: TARGET_TRANSPORT")
+        print("%s disallowed until testing can validate use of multiple transports on %s %d" % (transport, target_os, len(transport)))
         Exit(1)
 
 if 'ALL' in transport:
-       if target_os == 'linux':
-               env.AppendUnique(CPPDEFINES = ['IP_ADAPTER','NO_EDR_ADAPTER','NO_LE_ADAPTER'])
+       if with_ra == True:
+                       env.AppendUnique(CPPDEFINES = ['RA_ADAPTER'])
+       if with_tcp == True:
+                       env.AppendUnique(CPPDEFINES = ['TCP_ADAPTER'])
+       if disable_tcp_server == True:
+                       env.AppendUnique(CPPDEFINES = ['DISABLE_TCP_SERVER'])
+       if disable_ble_server == True:
+               if target_os in ['tizen']:
+                       env.AppendUnique(CPPDEFINES = ['DISABLE_BLE_SERVER'])
+       if target_os in ['linux']:
+               env.AppendUnique(CPPDEFINES = ['IP_ADAPTER','NO_EDR_ADAPTER','LE_ADAPTER'])
        elif target_os == 'tizen':
                env.AppendUnique(CPPDEFINES = ['IP_ADAPTER','EDR_ADAPTER','LE_ADAPTER'])
+       elif target_os == 'android':
+               env.AppendUnique(CPPDEFINES = ['IP_ADAPTER','EDR_ADAPTER','LE_ADAPTER', 'NFC_ADAPTER'])
        elif target_os in['darwin','ios']:
                env.AppendUnique(CPPDEFINES = ['IP_ADAPTER','NO_EDR_ADAPTER','NO_LE_ADAPTER'])
+       elif target_os in ['msys_nt', 'windows']:
+               env.AppendUnique(CPPDEFINES = ['IP_ADAPTER','NO_EDR_ADAPTER','NO_LE_ADAPTER'])
        else:
                env.AppendUnique(CPPDEFINES = ['IP_ADAPTER','EDR_ADAPTER','LE_ADAPTER'])
-       print "CA Transport is ALL"
+       print("CA Transport is ALL")
 else:
        if 'BT' in transport:
-               if target_os == 'linux':
-                       print "CA Transport BT is not supported in Linux"
+               if target_os in ['linux']:
+                       print("CA Transport BT is not supported in Linux")
                        Exit(1)
                else:
                        env.AppendUnique(CPPDEFINES = ['EDR_ADAPTER'])
-                       print "CA Transport is BT"
+                       print("CA Transport is BT")
        else:
                env.AppendUnique(CPPDEFINES = ['NO_EDR_ADAPTER'])
 
        if 'BLE' in transport:
-               if target_os == 'linux':
-                       print "CA Transport BLE is not supported in Linux"
-                       Exit(1)
+               env.AppendUnique(CPPDEFINES = ['LE_ADAPTER'])
+               print("CA Transport is BLE")
+               if ble_custom_adv in ['True']:
+                       env.AppendUnique(CPPDEFINES = ['BLE_CUSTOM_ADVERTISE'])
+                       print("BLE Custom advertisement supported")
                else:
-                       env.AppendUnique(CPPDEFINES = ['LE_ADAPTER'])
-                       print "CA Transport is BLE"
+                       print("BLE Custom advertisement not supported")
+               if disable_ble_server == True:
+                       if target_os in ['tizen']:
+                               env.AppendUnique(CPPDEFINES = ['DISABLE_BLE_SERVER'])
+                               print("BLE Server Disabled")
        else:
                env.AppendUnique(CPPDEFINES = ['NO_LE_ADAPTER'])
 
        if 'IP' in transport:
                env.AppendUnique(CPPDEFINES = ['IP_ADAPTER'])
-               print "CA Transport is IP"
+               print("CA Transport is IP")
        else:
                env.AppendUnique(CPPDEFINES = ['NO_IP_ADAPTER'])
 
-env.SConscript('./src/SConscript')
+       if with_tcp == True:
+               if target_os in ['linux', 'tizen', 'android', 'arduino', 'ios', 'tizenrt']:
+                       env.AppendUnique(CPPDEFINES = ['TCP_ADAPTER', 'WITH_TCP'])
+                       print("CA Transport is TCP")
+               else:
+                       print("CA Transport TCP is not supported ")
+                       Exit(1)
+       else:
+               env.AppendUnique(CPPDEFINES = ['NO_TCP_ADAPTER'])
+
+       if disable_tcp_server == True:
+               if target_os in ['linux', 'tizen', 'android', 'arduino', 'ios', 'tizenrt']:
+                       env.AppendUnique(CPPDEFINES = ['DISABLE_TCP_SERVER'])
 
-if build_sample == 'ON':
-       if target_os in ['linux', 'arduino', 'android']:
-               env.SConscript('./samples/' + target_os + '/SConscript')
-       
+       if 'NFC' in transport:
+               if target_os in['android']:
+                       env.AppendUnique(CPPDEFINES = ['NFC_ADAPTER'])
+                       print("CA Transport is NFC")
+               else:
+                       print("CA Transport NFC is not supported ")
+                       Exit(1)
+       else:
+               env.AppendUnique(CPPDEFINES = ['NO_NFC_ADAPTER'])
+
+if 'SUB' in with_mq:
+       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")
+
+if 'BROKER' in with_mq:
+       env.AppendUnique(CPPDEFINES = ['MQ_BROKER', 'WITH_MQ'])
+       print("MQ Broker support")
+
+env.SConscript('./src/SConscript')