Support Signaling Message for CoAP over TCP
[iotivity.git] / resource / csdk / connectivity / src / SConscript
1 ##
2 # CA build script
3 ##
4 import os.path
5
6 Import('connectivity_env')
7
8 ca_os = connectivity_env.get('TARGET_OS')
9 ca_transport = connectivity_env.get('TARGET_TRANSPORT')
10 secured = connectivity_env.get('SECURED')
11 multiple_owner = connectivity_env.get('MULTIPLE_OWNER')
12 with_ra = connectivity_env.get('WITH_RA')
13 with_ra_ibb = connectivity_env.get('WITH_RA_IBB')
14 with_tcp = connectivity_env.get('WITH_TCP')
15 root_dir = os.pardir
16
17 print("Reading ca script; transports requested: %s" % ca_transport)
18
19 #####################################################################
20 # Source files and Target(s)
21 ######################################################################
22
23 connectivity_env.PrependUnique(CPPPATH=[os.path.join(root_dir, 'api')])
24
25 with_upstream_libcoap = connectivity_env.get('WITH_UPSTREAM_LIBCOAP')
26 if with_upstream_libcoap == '1':
27     connectivity_env.AppendUnique(
28         CPPPATH=[os.path.join('#extlibs', 'libcoap', 'libcoap', 'include')])
29 else:
30     connectivity_env.AppendUnique(CPPPATH=[
31         os.path.join('#resource', 'csdk', 'connectivity', 'lib', 'libcoap-4.1.1', 'include')
32     ])
33
34 connectivity_env.AppendUnique(CPPPATH=[
35     os.path.join(root_dir, 'inc'),
36     '#/resource/csdk/logger/include',
37     os.path.join(root_dir, 'common', 'inc'),
38     os.path.join(root_dir, 'util', 'inc'),
39 ])
40
41 if ca_os not in ['darwin', 'ios', 'windows']:
42     connectivity_env.AppendUnique(LINKFLAGS=['-Wl,--no-undefined'])
43
44 # Pick up source files from ../common
45 connectivity_env.SConscript(root_dir + '/common/SConscript',
46                             exports='connectivity_env')
47
48 # Pick up source files from ../util
49 connectivity_env.SConscript(root_dir + '/util/SConscript',
50                             exports='connectivity_env')
51
52 src_files = [File(src) for src in (
53     'adapter_util/caadapterutils.c',
54     'adapter_util/cacertprofile.c'
55 )]
56
57 if (('BLE' in ca_transport) or ('ALL' in ca_transport)):
58     src_files.append(File('adapter_util/cafragmentation.c'))
59
60 # Build mbedtls as ocstack uses hash functions from mbedcrypto.lib.
61 tls_path = 'extlibs/mbedtls'
62 tls_headers_path = 'mbedtls/include'
63 if ca_os == 'tizen' and os.path.exists(root_dir + '/' + tls_path):
64     connectivity_env.SConscript(
65         os.path.join(root_dir, tls_path + '/SConscript'))
66     connectivity_env.AppendUnique(
67         CPPPATH=[os.path.join(root_dir, tls_path + '/' + tls_headers_path)])
68 else:
69     if ca_os != 'android':
70         connectivity_env.SConscript('#' + tls_path + '/SConscript')
71     connectivity_env.AppendUnique(
72         CPPPATH=['#' + tls_path + '/' + tls_headers_path])
73
74 if connectivity_env.get('SECURED') == '1':
75     connectivity_env.AppendUnique(
76         CPPPATH=['#/resource/c_common/octimer/include'])
77     connectivity_env.AppendUnique(
78         CPPPATH=['#/resource/csdk/security/include'])
79     connectivity_env.AppendUnique(
80         CPPPATH=[os.path.join(root_dir, 'external/inc')])
81     if ca_os != 'tizen' or not os.path.exists(root_dir + '/' + tls_path):
82         src_files.append(File('adapter_util/ca_adapter_net_ssl.c'))
83
84 if with_ra_ibb:
85     connectivity_env.SConscript('#/extlibs/wksxmppxep/SConscript')
86
87 src_files.extend([File(src) for src in (
88     'caconnectivitymanager.c',
89     'cainterfacecontroller.c',
90     'camessagehandler.c',
91     'canetworkconfigurator.c',
92     'caprotocolmessage.c',
93     'caqueueingthread.c',
94     'caretransmission.c',
95 )])
96
97 if  with_tcp:
98     src_files.append(File('caping.c'))
99
100 if (('IP' in ca_transport) or ('ALL' in ca_transport)):
101     src_files.append(File('cablockwisetransfer.c'))
102
103 connectivity_env.AppendUnique(CA_SRC=src_files)
104
105 transports = set()
106 if 'ALL' in ca_transport:
107     if with_ra:
108         transports.add('ra_adapter')
109
110     if ca_os in ['linux']:
111         transports.add('ip_adapter')
112         transports.add('bt_le_adapter')
113     elif ca_os in ['tizen']:
114         transports.add('ip_adapter')
115         transports.add('bt_edr_adapter')
116         transports.add('bt_le_adapter')
117     elif ca_os in ['android']:
118         transports.add('ip_adapter')
119         transports.add('bt_edr_adapter')
120         transports.add('bt_le_adapter')
121         transports.add('nfc_adapter')
122     elif ca_os in ['darwin', 'ios', 'msys_nt', 'windows']:
123         transports.add('ip_adapter')
124     else:
125         transports.add('ip_adapter')
126         transports.add('bt_edr_adapter')
127         transports.add('bt_le_adapter')
128
129 if 'IP' in ca_transport:
130     transports.add('ip_adapter')
131
132 if 'BT' in ca_transport:
133     transports.add('bt_edr_adapter')
134
135 if 'BLE' in ca_transport:
136     transports.add('bt_le_adapter')
137
138 if 'NFC' in ca_transport:
139     transports.add('nfc_adapter')
140
141 if ca_os in ['linux', 'tizen', 'android', 'ios', 'windows'] and with_tcp:
142     transports.add('tcp_adapter')
143
144 SConscript(dirs=list(transports), exports='connectivity_env')
145
146 # prevent unused-parameter warning from bluez-glue.c and object_manager-glue.c
147 # files when building bt_le_adapter. These files are generated by a tool and
148 # should not be changed. We should not be hiding the unused-parameter but in
149 # this limited case a exception is made.
150 if ca_os in ['linux']:
151     if 'bt_le_adapter' in transports:
152         connectivity_env.AppendUnique(CCFLAGS=['-Wno-unused-parameter'])
153
154 if ca_os == 'android':
155     connectivity_env.AppendUnique(LINKFLAGS=['-Wl,-soname,libca-interface.so'])
156     connectivity_env.AppendUnique(
157         LINKFLAGS=['-Wl,-soname,libconnectivity_abstraction.so'])
158
159 if connectivity_env.get('SECURED') == '1':
160     connectivity_env.AppendUnique(LIBS=['mbedtls', 'mbedx509'])
161
162 if ca_os in ['tizen']:
163     connectivity_env.AppendUnique(LIBS=['pthread'])
164
165 # c_common calls into mbedcrypto.
166 connectivity_env.AppendUnique(LIBS=['mbedcrypto'])
167
168 calib_internal = connectivity_env.StaticLibrary(
169     'connectivity_abstraction_internal', connectivity_env.get('CA_SRC'))
170 calib = Flatten(calib_internal)
171
172 if ca_os in ['android', 'tizen', 'linux', 'yocto']:
173     connectivity_env.AppendUnique(LIBS=['coap'])
174     if ca_os != 'android':
175         connectivity_env.AppendUnique(LIBS=['rt'])
176     static_calib = connectivity_env.StaticLibrary(
177         'connectivity_abstraction', connectivity_env.get('CA_SRC'))
178     shared_calib = connectivity_env.SharedLibrary(
179         'connectivity_abstraction', connectivity_env.get('CA_SRC'))
180     calib += Flatten([static_calib, shared_calib])
181 elif ca_os not in ['msys_nt', 'windows']:
182     static_calib = connectivity_env.StaticLibrary(
183         'connectivity_abstraction', connectivity_env.get('CA_SRC'))
184     calib += Flatten(static_calib)
185
186 connectivity_env.InstallTarget(calib, 'connectivity_abstraction')
187 connectivity_env.UserInstallTargetLib(calib, 'connectivity_abstraction')