Enable GCOV Coverage & Logging in UT. (#628)
[platform/upstream/iotivity.git] / resource / src / SConscript
1 #******************************************************************
2 #
3 # Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
4 #
5 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #      http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 ##
22 # OCLib (share library) build script
23 ##
24 import os
25 thread_env = SConscript('#build_common/thread.scons')
26 lib_env = thread_env.Clone()
27
28 # Add third party libraries
29 SConscript('#resource/third_party_libs.scons', 'lib_env')
30
31 oclib_env = lib_env.Clone()
32 secured = oclib_env.get('SECURED')
33 target_os = oclib_env.get('TARGET_OS')
34 with_cloud = oclib_env.get('WITH_CLOUD')
35 with_mq = oclib_env.get('WITH_MQ')
36 ble_custom_adv = oclib_env.get('BLE_CUSTOM_ADV')
37
38 ######################################################################
39 # Build flags
40 ######################################################################
41 with_upstream_libcoap = oclib_env.get('WITH_UPSTREAM_LIBCOAP')
42 if with_upstream_libcoap == '1':
43         # For bring up purposes only, we manually copy the forked version to where the unforked version is downloaded.
44         oclib_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
45 else:
46         # For bring up purposes only, the forked version will live here.
47         oclib_env.AppendUnique(CPPPATH = ['../csdk/connectivity/lib/libcoap-4.1.1/include'])
48
49 oclib_env.AppendUnique(CPPPATH = [
50                 '../include/',
51                 '../csdk/stack/include',
52                 '../c_common/ocrandom/include',
53                 '../csdk/logger/include',
54                 '../oc_logger/include',
55                 '../csdk/connectivity/api'
56                 ])
57
58 oclib_env.AppendUnique(LIBPATH = [oclib_env.get('BUILD_DIR')])
59
60 oclib_env.AppendUnique(LIBS = ['oc_logger'])
61 oclib_env.PrependUnique(LIBS = ['octbstack', 'connectivity_abstraction', 'ocsrm'])
62
63 if not oclib_env.get('RELEASE'):
64     oclib_env.PrependUnique(LIBS = ['gcov'])
65     oclib_env.AppendUnique(CCFLAGS = ['--coverage'])
66
67 if 'g++' in oclib_env.get('CXX'):
68         oclib_env.AppendUnique(CXXFLAGS = ['-std=c++0x'])
69         oclib_env.AppendUnique(CXXFLAGS = ['-Wall'])
70         oclib_env.AppendUnique(CXXFLAGS = ['-fPIC'])
71
72 if target_os not in ['darwin', 'ios', 'windows']:
73         oclib_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
74
75 if target_os == 'android':
76     oclib_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
77     oclib_env.AppendUnique(LIBS = ['boost_thread', 'gnustl_shared', 'log'])
78     oclib_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,liboc.so'])
79
80 if target_os == 'tizen':
81         oclib_env.AppendUnique(CPPDEFINES = ['__TIZEN__'])
82 if target_os in ['linux', 'tizen']:
83         oclib_env.ParseConfig('pkg-config --cflags --libs sqlite3')
84
85 if target_os in ['linux'] and oclib_env.get('SIMULATOR', False):
86     oclib_env.Append( RPATH = oclib_env.Literal('\\$$ORIGIN'))
87
88 if target_os in ['msys_nt', 'windows']:
89         oclib_env.AppendUnique(LIBPATH = [os.path.join(oclib_env.get('BUILD_DIR'), 'resource', 'oc_logger')])
90         oclib_env.AppendUnique(LIBPATH = [os.path.join(oclib_env.get('BUILD_DIR'), 'resource', 'csdk')])
91         oclib_env.AppendUnique(LIBS=['octbstack', 'logger', 'oc_logger','connectivity_abstraction', 'ocsrm', 'c_common', 'routingmanager'])
92         oclib_env.AppendUnique(LIBS=[ 'coap', 'ws2_32' ,'iphlpapi'])
93         if secured == '1':
94                 oclib_env.AppendUnique(LIBS=['mbedtls', 'mbedx509','mbedcrypto'])
95
96 if with_cloud:
97         oclib_env.AppendUnique(CPPDEFINES = ['WITH_CLOUD'])
98
99 if ble_custom_adv == True:
100                 env.AppendUnique(CPPDEFINES = ['BLE_CUSTOM_ADVERTISE'])
101
102 if 'SUB' in with_mq:
103         oclib_env.AppendUnique(CPPDEFINES = ['MQ_SUBSCRIBER', 'WITH_MQ'])
104
105 if 'PUB' in with_mq:
106         oclib_env.AppendUnique(CPPDEFINES = ['MQ_PUBLISHER', 'WITH_MQ'])
107
108 if 'BROKER' in with_mq:
109         oclib_env.AppendUnique(CPPDEFINES = ['MQ_BROKER', 'WITH_MQ'])
110
111 ######################################################################
112 # Source files and Targets
113 ######################################################################
114 oclib_src = [
115                 'OCPlatform.cpp',
116                 'OCPlatform_impl.cpp',
117                 'OCResource.cpp',
118                 'OCUtilities.cpp',
119                 'OCException.cpp',
120                 'OCRepresentation.cpp',
121                 'InProcServerWrapper.cpp',
122                 'InProcClientWrapper.cpp',
123                 'OCResourceRequest.cpp',
124                 'CAManager.cpp',
125                 'OCDirectPairing.cpp'
126         ]
127
128 if with_cloud:
129         oclib_src = oclib_src + ['OCAccountManager.cpp']
130
131 if target_os in ['windows','ios']:
132         oclib_src = oclib_src + ['OCApi.cpp']
133         # TODO: Add OC_EXPORT prefixes to enable DLL generation
134         oclib = oclib_env.StaticLibrary('oc', oclib_src)
135 else:
136         oclib = oclib_env.SharedLibrary('oc', oclib_src)
137 oclib_env.InstallTarget(oclib, 'oc')
138 oclib_env.UserInstallTargetLib(oclib, 'oc')
139 header_dir = os.path.join(oclib_env.get('SRC_DIR') , 'resource' , 'include') + os.sep
140
141 oclib_env.UserInstallTargetHeader(header_dir + 'OCApi.h', 'resource', 'OCApi.h')
142 oclib_env.UserInstallTargetHeader(header_dir + 'OCHeaderOption.h', 'resource', 'OCHeaderOption.h')
143 oclib_env.UserInstallTargetHeader(header_dir + 'OCException.h', 'resource', 'OCException.h')
144 oclib_env.UserInstallTargetHeader(header_dir + 'StringConstants.h', 'resource', 'StringConstants.h')
145
146 oclib_env.UserInstallTargetHeader(header_dir + 'OCPlatform.h', 'resource', 'OCPlatform.h')
147 oclib_env.UserInstallTargetHeader(header_dir + 'OCPlatform_impl.h', 'resource', 'OCPlatform_impl.h')
148 oclib_env.UserInstallTargetHeader(header_dir + 'WrapperFactory.h', 'resource', 'WrapperFactory.h')
149 oclib_env.UserInstallTargetHeader(header_dir + 'IClientWrapper.h', 'resource', 'IClientWrapper.h')
150 oclib_env.UserInstallTargetHeader(header_dir + 'IServerWrapper.h', 'resource', 'IServerWrapper.h')
151 oclib_env.UserInstallTargetHeader(header_dir + 'OutOfProcClientWrapper.h', 'resource', 'OutOfProcClientWrapper.h')
152 oclib_env.UserInstallTargetHeader(header_dir + 'OutOfProcServerWrapper.h', 'resource', 'OutOfProcServerWrapper.h')
153 oclib_env.UserInstallTargetHeader(header_dir + 'InProcClientWrapper.h', 'resource', 'InProcClientWrapper.h')
154 oclib_env.UserInstallTargetHeader(header_dir + 'InProcServerWrapper.h', 'resource', 'InProcServerWrapper.h')
155 oclib_env.UserInstallTargetHeader(header_dir + 'InitializeException.h', 'resource', 'InitializeException.h')
156 oclib_env.UserInstallTargetHeader(header_dir + 'ResourceInitException.h', 'resource', 'ResourceInitException.h')
157
158 oclib_env.UserInstallTargetHeader(header_dir + 'OCRepresentation.h', 'resource', 'OCRepresentation.h')
159 oclib_env.UserInstallTargetHeader(header_dir + 'AttributeValue.h', 'resource', 'AttributeValue.h')
160
161 oclib_env.UserInstallTargetHeader(header_dir + 'OCResource.h', 'resource', 'OCResource.h')
162 oclib_env.UserInstallTargetHeader(header_dir + 'OCResourceRequest.h', 'resource', 'OCResourceRequest.h')
163 oclib_env.UserInstallTargetHeader(header_dir + 'OCResourceResponse.h', 'resource', 'OCResourceResponse.h')
164 oclib_env.UserInstallTargetHeader(header_dir + 'OCUtilities.h', 'resource', 'OCUtilities.h')
165
166 oclib_env.UserInstallTargetHeader(header_dir + 'CAManager.h', 'resource', 'CAManager.h')
167 oclib_env.UserInstallTargetHeader(header_dir + 'OCDirectPairing.h', 'resource', 'OCDirectPairing.h')
168
169 if with_cloud:
170         oclib_env.UserInstallTargetHeader(header_dir + 'OCAccountManager.h', 'resource', 'OCAccountManager.h')
171
172 # Add Provisioning library
173 if target_os in ['linux', 'android', 'tizen', 'ios'] and secured == '1':
174         SConscript('../provisioning/SConscript')