# CA build script
##
+import os.path
+
Import('env')
ca_os = env.get('TARGET_OS')
ca_transport = env.get('TARGET_TRANSPORT')
secured = env.get('SECURED')
-root_dir = './../'
-ca_path = './'
-current_dir=env.get('SRC_DIR')
-
-# The tinydtls library location is ~/iotivity/extlibs. When scons run from connectivity folder,
-# the build folder is ~/iotivity/resource/csdk/connectivity/out/linux/x86_64/release/.
-# To include ~/iotivity/extlibs/tinyDTLS, it should go seven level up from the build folder.
-extlib_dir ='../../../../../../../../'
+with_ra = env.get ('WITH_RA')
+with_tcp = env.get('WITH_TCP')
+src_dir = env.get('SRC_DIR')
+root_dir = os.pardir
+ca_path = os.curdir
#####################################################################
# Source files and Target(s)
print"Reading ca script %s"%ca_transport
-env.PrependUnique(CPPPATH = [root_dir + '/api/'])
-env.AppendUnique(CPPPATH = [root_dir + '/inc/'])
-env.AppendUnique(CPPPATH = [root_dir + '/lib/libcoap-4.1.1/'])
-env.AppendUnique(CPPPATH = [root_dir + '/common/inc/'])
+env.PrependUnique(CPPPATH = [ os.path.join(root_dir, 'api') ])
+env.AppendUnique(CPPPATH = [ os.path.join(root_dir, 'inc'),
+ os.path.join(root_dir, 'lib/libcoap-4.1.1'),
+ os.path.join(src_dir, '/resource/csdk/logger/include/'),
+ os.path.join(root_dir, 'common/inc'),
+ os.path.join(root_dir, 'util/inc') ])
if ca_os not in ['arduino', 'windows', 'winrt']:
env.AppendUnique(CPPDEFINES = ['WITH_POSIX'])
-if ca_os in ['darwin']:
+if ca_os not in ['darwin', 'ios', 'windows', 'winrt']:
+ env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
+
+if ca_os in ['darwin','ios']:
env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
-#Getting common source files
+# Getting common source files
env.SConscript('./../common/SConscript')
+# Getting util source files
+env.SConscript(root_dir + '/util/SConscript')
+
+# The tinydtls library is found in '#extlibs/tinydtls', where the '#'
+# is interpreted by SCons as the top-level iotivity directory where
+# the SConscruct file is found.
if env.get('SECURED') == '1':
- if current_dir.find('connectivity') == -1:
- env.SConscript(current_dir +'/extlibs/tinydtls/SConscript')
+ if ca_os == 'tizen' and os.path.exists(root_dir + '/extlibs/tinydtls'):
+ env.SConscript(os.path.join(root_dir, 'extlibs/tinydtls/SConscript'))
else:
- env.SConscript(extlib_dir + '/extlibs/tinydtls/SConscript')
+ env.SConscript('#extlibs/tinydtls/SConscript')
+ if ca_os == 'tizen' and os.path.exists(root_dir + '/extlibs/timer'):
+ env.SConscript(os.path.join(root_dir, 'extlibs/timer/SConscript'))
+ env.AppendUnique(CPPPATH = [os.path.join(root_dir, 'extlibs/timer')])
+ else:
+ env.SConscript('#extlibs/timer/SConscript')
+ env.AppendUnique(CPPPATH = ['#extlibs/timer'])
+env.AppendUnique(CA_SRC = [os.path.join(ca_path,
+ 'adapter_util/caadapterutils.c')])
-env.AppendUnique(CA_SRC=[ca_path+'adapter_util/caadapterutils.c'])
-env.AppendUnique(CA_SRC=[ca_path+'adapter_util/camsgparser.c'])
if env.get('SECURED') == '1':
- env.AppendUnique(CA_SRC=[ca_path+'adapter_util/caadapternetdtls.c'])
- env.AppendUnique(CPPPATH = [root_dir + '/external/inc/'])
+ env.AppendUnique(CA_SRC = [os.path.join(ca_path,
+ 'adapter_util/caadapternetdtls.c')])
+ env.AppendUnique(CPPPATH = [os.path.join(root_dir,
+ 'external/inc')])
+if env.get('DTLS_WITH_X509') == '1':
+ env.AppendUnique(CPPPATH = [src_dir + '/resource/csdk/connectivity/inc/pkix'])
+ env.AppendUnique(CPPPATH = [src_dir + '/extlibs/tinydtls/ecc/'])
+ env.AppendUnique(CPPPATH = [src_dir + '/extlibs/tinydtls/sha2/'])
+ env.AppendUnique(CPPDEFINES = ['__WITH_X509__'])
+ if not env.get('RELEASE'):
+ env.AppendUnique(CPPDEFINES = ['X509_DEBUG'])
+ pkix_src = Glob('adapter_util/pkix/*.c');
+ env.AppendUnique(CA_SRC = pkix_src)
+
+ca_common_src = None
+
+if env.get('ROUTING') == 'GW':
+ env.AppendUnique(CPPDEFINES = ['ROUTING_GATEWAY'])
+elif env.get('ROUTING') == 'EP':
+ env.AppendUnique(CPPDEFINES = ['ROUTING_EP'])
if ca_os == 'arduino':
env.AppendUnique(CPPDEFINES = ['SINGLE_THREAD'])
+ env.AppendUnique(CPPDEFINES = ['WITH_ARDUINO'])
+ print "setting WITH_ARDUINO"
ca_common_src = [
- ca_path + 'caconnectivitymanager_singlethread.c',
- ca_path + 'cainterfacecontroller_singlethread.c',
- ca_path + 'camessagehandler_singlethread.c',
- ca_path + 'canetworkconfigurator.c',
- ca_path + 'caprotocolmessage.c',
- ca_path + 'caremotehandler.c',
- ca_path + 'caretransmission_singlethread.c',
+ 'caconnectivitymanager.c',
+ 'cainterfacecontroller.c',
+ 'camessagehandler.c',
+ 'canetworkconfigurator.c',
+ 'caprotocolmessage.c',
+ 'caretransmission.c',
]
else:
- env.AppendUnique(CPPDEFINES = ['MULTI_THREAD'])
ca_common_src = [
- ca_path + 'caconnectivitymanager.c',
- ca_path + 'cainterfacecontroller.c',
- ca_path + 'camessagehandler.c',
- ca_path + 'canetworkconfigurator.c',
- ca_path + 'caprotocolmessage.c',
- ca_path + 'caqueueingthread.c',
- ca_path + 'caremotehandler.c',
- ca_path + 'caretransmission.c',
+ 'caconnectivitymanager.c',
+ 'cainterfacecontroller.c',
+ 'camessagehandler.c',
+ 'canetworkconfigurator.c',
+ 'caprotocolmessage.c',
+ 'caqueueingthread.c',
+ 'caretransmission.c',
]
+ if (('IP' in ca_transport) or ('ALL' in ca_transport)):
+ env.AppendUnique(CA_SRC = [os.path.join(ca_path, 'cablockwisetransfer.c') ])
+ env.AppendUnique(CPPDEFINES = ['WITH_BWT'])
if secured == '1':
env.AppendUnique(CPPDEFINES = ['__WITH_DTLS__'])
- if current_dir.find('connectivity') == -1:
- env.AppendUnique(CPPPATH = [current_dir + '/extlibs/tinydtls'])
+ if ca_os == 'tizen' and os.path.exists(root_dir + '/extlibs/tinydtls'):
+ env.AppendUnique(CPPPATH = [os.path.join(root_dir, 'extlibs/tinydtls')])
else:
- env.AppendUnique(CPPPATH = [extlib_dir + '/extlibs/tinydtls'])
-env.AppendUnique(CA_SRC = ca_common_src)
+ env.AppendUnique(CPPPATH = ['#extlibs/tinydtls'])
+ca_common_src = [
+ os.path.join(ca_path, d) for d in ca_common_src ]
+env.AppendUnique(CA_SRC = ca_common_src)
if 'ALL' in ca_transport:
- env.SConscript(ca_path + 'ethernet_adapter/SConscript')
- env.SConscript(ca_path + 'wifi_adapter/SConscript')
- env.SConscript(ca_path + 'bt_edr_adapter/SConscript')
- env.SConscript(ca_path + 'bt_le_adapter/SConscript')
-
-if 'WIFI' in ca_transport:
- env.SConscript(ca_path + 'wifi_adapter/SConscript')
-
-if 'ETHERNET' in ca_transport:
- env.SConscript(ca_path + 'ethernet_adapter/SConscript')
+ transports = [ 'ip_adapter', 'bt_edr_adapter', 'bt_le_adapter']
+ if with_ra:
+ transports.append ('ra_adapter')
+ if ca_os in ['android']:
+ transports.append ('nfc_adapter')
+ env.SConscript(dirs = [
+ os.path.join(ca_path, d) for d in transports ])
+
+if 'IP' in ca_transport:
+ env.SConscript(os.path.join(ca_path, 'ip_adapter/SConscript'))
+ if ca_os == 'arduino':
+ if with_tcp:
+ transports = [ 'ip_adapter', 'tcp_adapter']
+ env.SConscript(dirs = [
+ os.path.join(ca_path, d) for d in transports ])
if 'BT' in ca_transport:
- env.SConscript(ca_path + 'bt_edr_adapter/SConscript')
+ env.SConscript(os.path.join(ca_path, 'bt_edr_adapter/SConscript'))
if 'BLE' in ca_transport:
- env.SConscript(ca_path + 'bt_le_adapter/SConscript')
+ env.SConscript(os.path.join(ca_path, 'bt_le_adapter/SConscript'))
+
+if 'NFC' in ca_transport:
+ env.SConscript(os.path.join(ca_path, 'nfc_adapter/SConscript'))
+
+if ca_os in ['linux', 'tizen', 'android']:
+ if with_tcp == True:
+ env.SConscript(os.path.join(ca_path, 'tcp_adapter/SConscript'))
+ env.AppendUnique(CPPDEFINES = ['WITH_TCP'])
+
+if ca_os in ['linux', 'tizen', 'android', 'arduino', 'ios']:
+ if (('BLE' in ca_transport) or ('BT' in ca_transport) or ('ALL' in ca_transport)):
+ env.AppendUnique(CPPDEFINES = ['WITH_TCP'])
+
+print "Include path is %s" % env.get('CPPPATH')
+print "Files path is %s" % env.get('CA_SRC')
+
+lib_env = env.Clone()
+
+if ca_os == 'android':
+ lib_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,libconnectivity_abstraction.so'])
-print "Include path is %s" %env.get('CPPPATH')
-print "Files path is %s" %env.get('CA_SRC')
if ca_os in ['android', 'tizen']:
- calib = env.SharedLibrary('connectivity_abstraction', env.get('CA_SRC'))
+ lib_env.AppendUnique(LIBS = ['coap'])
+ if lib_env.get('SECURED') == '1':
+ lib_env.AppendUnique(LIBS = ['tinydtls'])
+ lib_env.AppendUnique(LIBS = ['timer'])
+ if ca_os != 'android':
+ lib_env.AppendUnique(LIBS = ['rt'])
+ calib = lib_env.SharedLibrary('connectivity_abstraction', lib_env.get('CA_SRC'))
else:
- calib = env.StaticLibrary('connectivity_abstraction', env.get('CA_SRC'))
-env.InstallTarget(calib, 'libconnectivity_abstraction')
-
+ calib = lib_env.StaticLibrary('connectivity_abstraction', lib_env.get('CA_SRC'))
+lib_env.InstallTarget(calib, 'libconnectivity_abstraction')
+lib_env.UserInstallTargetLib(calib, 'libconnectivity_abstraction')