fix the easy-setup mediator SConscript
[platform/upstream/iotivity.git] / service / easy-setup / mediator / richsdk / SConscript
1 #******************************************************************
2 #
3 # Copyright 2016 Samsung Electronics 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 # easy-setup Mediator C++[Rich] SDK build script
23 ######################################################################
24 import os.path
25 Import('env')
26
27 easysetup_path = os.curdir
28
29 if env.get('RELEASE'):
30     env.AppendUnique(CCFLAGS = ['-Os'])
31     env.AppendUnique(CPPDEFINES = ['NDEBUG'])
32 else:
33     env.AppendUnique(CCFLAGS = ['-g'])
34
35 if env.get('LOGGING'):
36     env.AppendUnique(CPPDEFINES = ['TB_LOG'])
37
38 # Easysetup provides reference implemenation of Arduino Enrollee.
39 # Mediator applications developed on different platforms will be default defining the
40 # flag 'REMOTE_ARDUINO_ENROLEE'. If the target Enrollee is not Arduino, the below commented
41 # modifications must be enabled instead (and the existing define must be commented).
42 #
43 ##### The following lines must be uncommented, if target Enrollee is not Arduino
44 target_enrollee = env.get('ES_TARGET_ENROLLEE')
45 if target_enrollee == 'arduino':
46         print "REMOTE_ARDUINO_ENROLEE flag is defined."
47         print "The Mediator application will be working only with Arduino Enrollee."
48         env.AppendUnique(CPPDEFINES = ['REMOTE_ARDUINO_ENROLEE'])
49
50 # Add third party libraries
51 lib_env = env.Clone()
52 SConscript('#service/third_party_libs.scons', 'lib_env')
53
54 easy_setup_env = lib_env.Clone()
55 target_os = env.get('TARGET_OS')
56
57 ######################################################################
58 # Build flags
59 ######################################################################
60 easy_setup_env.AppendUnique(CPPPATH = ['inc', 'src', '../../inc'])
61
62 if target_os not in ['windows']:
63     easy_setup_env.AppendUnique(CXXFLAGS = ['-Wall', '-std=c++0x'])
64
65 if target_os in ['linux','tizen']:
66    easy_setup_env.AppendUnique(LIBS = ['pthread', 'dl', 'coap'])
67
68 if target_os in ['android']:
69         easy_setup_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
70         if env.get('SECURED') == '1':
71                 easy_setup_env.AppendUnique(LIBPATH = [env.get('SRC_DIR')+'/android/android_api/base/libs/armeabi'])
72         easy_setup_env.AppendUnique(RPATH = [env.get('BUILD_DIR')])
73         easy_setup_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
74         easy_setup_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'gnustl_shared'])
75         if env.get('SECURED') == '1':
76                 easy_setup_env.AppendUnique(LIBS = ['ocpmapi','ocprovision'])
77         if not env.get('RELEASE'):
78                 easy_setup_env.AppendUnique(LIBS = ['log'])
79
80 if target_os in ['linux', 'tizen']:
81         easy_setup_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
82         easy_setup_env.AppendUnique(RPATH = [env.get('BUILD_DIR')])
83         easy_setup_env.AppendUnique(CXXFLAGS = ['-pthread'])
84         easy_setup_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger'])
85         if env.get('SECURED') == '1':
86                 easy_setup_env.AppendUnique(LIBS = ['ocpmapi', 'ocprovision'])
87
88 if target_os in ['android','ios','linux','tizen']:
89         easy_setup_env.PrependUnique(CPPPATH = [
90                 env.get('SRC_DIR') + '/resource/c_common/oic_malloc/include',
91                 env.get('SRC_DIR') + '/resource/include',
92                 env.get('SRC_DIR') + '/resource/csdk/logger/include',
93                 env.get('SRC_DIR') + '/resource/csdk/include',
94                 env.get('SRC_DIR') + '/resource/csdk/stack/include',
95                 env.get('SRC_DIR') + '/resource/csdk/logger/include',
96                 env.get('SRC_DIR') + '/resource/csdk/security/include',
97                 env.get('SRC_DIR') + '/extlibs/cjson',
98                 env.get('SRC_DIR') + '/service/easy-setup/inc'])
99         if target_os not in ['linux', 'tizen']:
100                 easy_setup_env.PrependUnique(CPPPATH = [env.get('SRC_DIR') + '/extlibs/sqlite3'])
101         if env.get('SECURED') == '1':
102                 with_upstream_libcoap = easy_setup_env.get('WITH_UPSTREAM_LIBCOAP')
103                 if with_upstream_libcoap == '1':
104                         # For bring up purposes only, we manually copy the forked version to where the unforked version is downloaded.
105                         easy_setup_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
106                 else:
107                         # For bring up purposes only, the forked version will live here.
108                         easy_setup_env.AppendUnique(CPPPATH = [env.get('SRC_DIR') + '/resource/csdk/connectivity/lib/libcoap-4.1.1/include'])
109                 easy_setup_env.AppendUnique(CPPPATH = [
110                         env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include',
111                         env.get('SRC_DIR') + '/resource/csdk/security/include/internal',
112                         env.get('SRC_DIR') + '/resource/csdk/connectivity/api/',
113                         env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include/internal',
114                         env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include/cloud',
115                         env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include/oxm'])
116                 if env.get('WITH_TCP') == True:
117                         easy_setup_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509', 'mbedcrypto'])
118
119 if not env.get('RELEASE') and target_os not in ['ios']:
120     easy_setup_env.PrependUnique(LIBS = ['gcov'])
121     easy_setup_env.AppendUnique(CCFLAGS = ['--coverage'])
122
123 ######################################################################
124 # Source files and Targets
125 ######################################################################
126
127 print"easysetup_path %s" % easysetup_path
128
129 es_src = None
130
131 if target_os in ['android','linux','ios','tizen']:
132         if env.get('SECURED') == '1':
133                 env.AppendUnique(es_src = [os.path.join(easysetup_path, 'src/EnrolleeSecurity.cpp')])
134
135         es_common_src = ['src/RemoteEnrollee.cpp',
136                 'src/EnrolleeResource.cpp',
137                 'src/CloudResource.cpp',
138                 'src/EasySetup.cpp',
139                 'src/ESException.cpp']
140
141         env.AppendUnique(es_src = es_common_src)
142
143         es_sdk_static = easy_setup_env.StaticLibrary('ESMediatorRich', env.get('es_src'))
144         easy_setup_env.InstallTarget(es_sdk_static, 'libESMediatorRich')
145         if target_os not in ['ios']:
146                 es_sdk_shared = easy_setup_env.SharedLibrary('ESMediatorRich', env.get('es_src'))
147                 easy_setup_env.UserInstallTargetLib(es_sdk_shared, 'libESMediatorRich')
148                 easy_setup_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,libESMediatorRich.so'])
149
150 filenames = [ 'ESException.h', 'ESRichCommon.h', 'EasySetup.hpp', 'RemoteEnrollee.h' ]
151 for filename in filenames:
152         easy_setup_env.UserInstallTargetHeader('inc/' + filename, "service/easy-setup", filename)
153
154 print "Files path is %s" % env.get('es_src')
155
156 ######################################################################
157 # Generate RichSDK Mediator AAR
158 ################################################ ######################
159 if target_os in ['android']:
160         SConscript('android/SConscript')
161
162 ######################################################################
163 # Build RichSDK Mediator Sample App
164 ################################################ ######################
165 if target_os in ['linux']:
166         SConscript('../../sampleapp/mediator/linux/richsdk_sample/SConscript')
167
168 if target_os in ['android']:
169         SConscript('../../sampleapp/mediator/android/SConscript')
170
171
172 ######################################################################
173 #Build UnitTestcases for Mediator[RichSDK]
174 ################################################ ######################
175 if env.get('SECURED') == '0':
176    if target_os == 'linux':
177        SConscript('unittests/SConscript')
178