Merge branch 'master' into windows-port
[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(env.get('SRC_DIR') + '/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', 'winrt']:
63     easy_setup_env.AppendUnique(CXXFLAGS = ['-Wall', '-std=c++0x'])
64
65 if target_os in ['linux']:
66    easy_setup_env.AppendUnique(LIBS = ['pthread', 'dl'])
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 = ['coap'])
75         easy_setup_env.AppendUnique(LIBS = ['connectivity_abstraction'])
76         easy_setup_env.AppendUnique(LIBS = ['oc_logger'])
77         easy_setup_env.AppendUnique(LIBS = ['octbstack'])
78         easy_setup_env.AppendUnique(LIBS = ['oc'])
79         easy_setup_env.AppendUnique(LIBS = ['gnustl_shared'])
80         if env.get('SECURED') == '1':
81                 easy_setup_env.AppendUnique(LIBS = ['ocpmapi','ocprovision'])
82         if not env.get('RELEASE'):
83                 easy_setup_env.AppendUnique(LIBS = ['log'])
84
85 if target_os in ['linux']:
86         easy_setup_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
87         easy_setup_env.AppendUnique(RPATH = [env.get('BUILD_DIR')])
88         easy_setup_env.AppendUnique(CXXFLAGS = ['-pthread'])
89         easy_setup_env.PrependUnique(LIBS = ['coap'])
90         easy_setup_env.AppendUnique(LIBS = ['connectivity_abstraction'])
91         easy_setup_env.AppendUnique(LIBS = ['oc_logger'])
92         easy_setup_env.AppendUnique(LIBS = ['octbstack'])
93         easy_setup_env.AppendUnique(LIBS = ['oc'])
94         easy_setup_env.AppendUnique(LIBS = ['pthread'])
95         if env.get('SECURED') == '1':
96                 easy_setup_env.AppendUnique(LIBS = ['ocpmapi', 'ocprovision'])
97
98 if target_os in ['android','linux']:
99         easy_setup_env.PrependUnique(CPPPATH = [
100                 env.get('SRC_DIR') + '/resource/c_common/oic_malloc/include',
101                 env.get('SRC_DIR') + '/resource/include',
102                 env.get('SRC_DIR') + '/resource/csdk/logger/include',
103                 env.get('SRC_DIR') + '/resource/csdk/stack/include',
104                 env.get('SRC_DIR') + '/resource/csdk/logger/include',
105                 env.get('SRC_DIR') + '/resource/csdk/security/include',
106                 env.get('SRC_DIR') + '/extlibs/cjson',
107                 env.get('SRC_DIR') + '/extlibs/sqlite3',
108                 env.get('SRC_DIR') + '/service/easy-setup/inc',
109                 'inc'])
110         if env.get('SECURED') == '1':
111                 easy_setup_env.AppendUnique(CPPPATH = [
112                         env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include',
113                         env.get('SRC_DIR') + '/resource/csdk/connectivity/api/',
114                         env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include/internal',
115                         env.get('SRC_DIR') + '/resource/csdk/security/provisioning/include/oxm'])
116
117 ######################################################################
118 # Source files and Targets
119 ######################################################################
120
121
122 print"easysetup_path %s" % easysetup_path
123
124 es_src = None
125
126 if target_os in ['android','linux']:
127         if env.get('SECURED') == '1':
128                 env.AppendUnique(es_src = [os.path.join(easysetup_path, 'src/EnrolleeSecurity.cpp')])
129
130         es_common_src = ['src/RemoteEnrollee.cpp',
131                 'src/RemoteEnrolleeResource.cpp',
132                 'src/EasySetup.cpp',
133                 'src/ESException.cpp']
134
135         env.AppendUnique(es_src = es_common_src)
136
137         es_sdk_shared = easy_setup_env.SharedLibrary('ESMediatorRich', env.get('es_src'))
138         easy_setup_env.InstallTarget(es_sdk_shared, 'libESMediatorRich')
139
140 print "Files path is %s" % env.get('es_src')
141
142 ######################################################################
143 # Build RichSDK Mediator Sample App
144 ################################################ ######################
145 if target_os == 'linux':
146         SConscript('../../sampleapp/mediator/linux/richsdk_sample/SConscript')
147
148 ######################################################################
149 #Build UnitTestcases for Mediator[RichSDK]
150 ################################################ ######################
151 if target_os == 'linux':
152     SConscript('unittests/SConscript')
153