1 #******************************************************************
3 # Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 # http://www.apache.org/licenses/LICENSE-2.0
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.
19 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
22 # OCLib (share library) build script
25 thread_env = SConscript('#build_common/thread.scons')
26 lib_env = thread_env.Clone()
28 # Add third party libraries
29 SConscript('#resource/third_party_libs.scons', 'lib_env')
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')
37 ######################################################################
39 ######################################################################
40 with_upstream_libcoap = oclib_env.get('WITH_UPSTREAM_LIBCOAP')
41 if with_upstream_libcoap == '1':
42 # For bring up purposes only, we manually copy the forked version to where the unforked version is downloaded.
43 oclib_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
45 # For bring up purposes only, the forked version will live here.
46 oclib_env.AppendUnique(CPPPATH = ['../csdk/connectivity/lib/libcoap-4.1.1/include'])
48 oclib_env.AppendUnique(CPPPATH = [
50 '../csdk/stack/include',
51 '../c_common/ocrandom/include',
52 '../csdk/logger/include',
53 '../oc_logger/include',
54 '../csdk/connectivity/api'
57 oclib_env.AppendUnique(LIBPATH = [oclib_env.get('BUILD_DIR')])
59 oclib_env.AppendUnique(LIBS = ['oc_logger'])
60 oclib_env.PrependUnique(LIBS = ['octbstack', 'connectivity_abstraction', 'ocsrm'])
62 if 'g++' in oclib_env.get('CXX'):
63 oclib_env.AppendUnique(CXXFLAGS = ['-std=c++0x'])
64 oclib_env.AppendUnique(CXXFLAGS = ['-Wall'])
65 oclib_env.AppendUnique(CXXFLAGS = ['-fPIC'])
67 if target_os not in ['darwin', 'ios', 'windows']:
68 oclib_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
70 if target_os == 'android':
71 oclib_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
72 oclib_env.AppendUnique(LIBS = ['boost_thread', 'gnustl_shared', 'log'])
73 oclib_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,liboc.so'])
75 if target_os == 'tizen':
76 oclib_env.AppendUnique(CPPDEFINES = ['__TIZEN__'])
77 if target_os in ['linux', 'tizen']:
78 oclib_env.ParseConfig('pkg-config --cflags --libs sqlite3')
80 if target_os in ['linux'] and oclib_env.get('SIMULATOR', False):
81 oclib_env.Append( RPATH = oclib_env.Literal('\\$$ORIGIN'))
83 if target_os in ['msys_nt', 'windows']:
84 oclib_env.AppendUnique(LIBPATH = [os.path.join(oclib_env.get('BUILD_DIR'), 'resource', 'oc_logger')])
85 oclib_env.AppendUnique(LIBPATH = [os.path.join(oclib_env.get('BUILD_DIR'), 'resource', 'csdk')])
86 oclib_env.AppendUnique(LIBS=['octbstack', 'logger', 'oc_logger','connectivity_abstraction', 'ocsrm', 'c_common', 'routingmanager'])
87 oclib_env.AppendUnique(LIBS=[ 'coap', 'ws2_32' ,'iphlpapi'])
89 oclib_env.AppendUnique(LIBS=['mbedtls', 'mbedx509','mbedcrypto'])
92 oclib_env.AppendUnique(CPPDEFINES = ['WITH_CLOUD'])
95 oclib_env.AppendUnique(CPPDEFINES = ['MQ_SUBSCRIBER', 'WITH_MQ'])
98 oclib_env.AppendUnique(CPPDEFINES = ['MQ_PUBLISHER', 'WITH_MQ'])
100 if 'BROKER' in with_mq:
101 oclib_env.AppendUnique(CPPDEFINES = ['MQ_BROKER', 'WITH_MQ'])
103 ######################################################################
104 # Source files and Targets
105 ######################################################################
108 'OCPlatform_impl.cpp',
112 'OCRepresentation.cpp',
113 'InProcServerWrapper.cpp',
114 'InProcClientWrapper.cpp',
115 'OCResourceRequest.cpp',
117 'OCDirectPairing.cpp'
121 oclib_src = oclib_src + ['OCAccountManager.cpp']
123 if target_os in ['windows','ios']:
124 oclib_src = oclib_src + ['OCApi.cpp']
125 # TODO: Add OC_EXPORT prefixes to enable DLL generation
126 oclib = oclib_env.StaticLibrary('oc', oclib_src)
128 oclib = oclib_env.SharedLibrary('oc', oclib_src)
129 oclib_env.InstallTarget(oclib, 'oc')
130 oclib_env.UserInstallTargetLib(oclib, 'oc')
131 header_dir = os.path.join(oclib_env.get('SRC_DIR') , 'resource' , 'include') + os.sep
133 oclib_env.UserInstallTargetHeader(header_dir + 'OCApi.h', 'resource', 'OCApi.h')
134 oclib_env.UserInstallTargetHeader(header_dir + 'OCHeaderOption.h', 'resource', 'OCHeaderOption.h')
135 oclib_env.UserInstallTargetHeader(header_dir + 'OCException.h', 'resource', 'OCException.h')
136 oclib_env.UserInstallTargetHeader(header_dir + 'StringConstants.h', 'resource', 'StringConstants.h')
138 oclib_env.UserInstallTargetHeader(header_dir + 'OCPlatform.h', 'resource', 'OCPlatform.h')
139 oclib_env.UserInstallTargetHeader(header_dir + 'OCPlatform_impl.h', 'resource', 'OCPlatform_impl.h')
140 oclib_env.UserInstallTargetHeader(header_dir + 'WrapperFactory.h', 'resource', 'WrapperFactory.h')
141 oclib_env.UserInstallTargetHeader(header_dir + 'IClientWrapper.h', 'resource', 'IClientWrapper.h')
142 oclib_env.UserInstallTargetHeader(header_dir + 'IServerWrapper.h', 'resource', 'IServerWrapper.h')
143 oclib_env.UserInstallTargetHeader(header_dir + 'OutOfProcClientWrapper.h', 'resource', 'OutOfProcClientWrapper.h')
144 oclib_env.UserInstallTargetHeader(header_dir + 'OutOfProcServerWrapper.h', 'resource', 'OutOfProcServerWrapper.h')
145 oclib_env.UserInstallTargetHeader(header_dir + 'InProcClientWrapper.h', 'resource', 'InProcClientWrapper.h')
146 oclib_env.UserInstallTargetHeader(header_dir + 'InProcServerWrapper.h', 'resource', 'InProcServerWrapper.h')
147 oclib_env.UserInstallTargetHeader(header_dir + 'InitializeException.h', 'resource', 'InitializeException.h')
148 oclib_env.UserInstallTargetHeader(header_dir + 'ResourceInitException.h', 'resource', 'ResourceInitException.h')
150 oclib_env.UserInstallTargetHeader(header_dir + 'OCRepresentation.h', 'resource', 'OCRepresentation.h')
151 oclib_env.UserInstallTargetHeader(header_dir + 'AttributeValue.h', 'resource', 'AttributeValue.h')
153 oclib_env.UserInstallTargetHeader(header_dir + 'OCResource.h', 'resource', 'OCResource.h')
154 oclib_env.UserInstallTargetHeader(header_dir + 'OCResourceRequest.h', 'resource', 'OCResourceRequest.h')
155 oclib_env.UserInstallTargetHeader(header_dir + 'OCResourceResponse.h', 'resource', 'OCResourceResponse.h')
156 oclib_env.UserInstallTargetHeader(header_dir + 'OCUtilities.h', 'resource', 'OCUtilities.h')
158 oclib_env.UserInstallTargetHeader(header_dir + 'CAManager.h', 'resource', 'CAManager.h')
159 oclib_env.UserInstallTargetHeader(header_dir + 'OCDirectPairing.h', 'resource', 'OCDirectPairing.h')
162 oclib_env.UserInstallTargetHeader(header_dir + 'OCAccountManager.h', 'resource', 'OCAccountManager.h')
164 # Add Provisioning library
165 if target_os in ['linux', 'android', 'tizen', 'ios'] and secured == '1':
166 SConscript('../provisioning/SConscript')