1a645ef0c8558ba3102441a7bd90b0017fc05eb7
[platform/upstream/iotivity.git] / service / soft-sensor-manager / SConscript
1 #******************************************************************
2 #
3 # Copyright 2014 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 # soft-sensor-manager project build script
23 ##
24
25 Import('env')
26
27 # Add third party libraries
28 lib_env = env.Clone()
29 SConscript(env.get('SRC_DIR') + '/service/third_party_libs.scons', 'lib_env')
30 soft_sensor_manager_env = lib_env.Clone()
31
32 target_os = env.get('TARGET_OS')
33 # As in the source code, it includes arduino Time library (C++)
34 # It requires compile the .c with g++
35 if target_os == 'arduino':
36         soft_sensor_manager_env.Replace(CC = env.get('CXX'))
37         soft_sensor_manager_env.Replace(CFLAGS = env.get('CXXFLAGS'))
38
39 ######################################################################
40 # Build flags
41 ######################################################################
42 if target_os not in ['windows', 'winrt']:
43         soft_sensor_manager_env.AppendUnique(CXXFLAGS = ['-Wall', '-DLINUX','-std=c++0x'])
44         if target_os != 'android':
45                 soft_sensor_manager_env.AppendUnique(LIBS = ['pthread'])
46                 soft_sensor_manager_env.AppendUnique(CXXFLAGS = ['-pthread'])
47
48 if target_os == 'android':
49         soft_sensor_manager_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
50         soft_sensor_manager_env.AppendUnique(LIBS = ['gnustl_shared'])
51
52         if not env.get('RELEASE'):
53                 soft_sensor_manager_env.AppendUnique(LIBS = ['log'])
54
55 #######################################################################
56 ## build SSM SDK
57 #######################################################################
58 sdk_env = soft_sensor_manager_env.Clone()
59 sdk_env.AppendUnique(CPPPATH = ['SSMCore/include'])
60 sdk_env.AppendUnique(CPPPATH = ['SSMCore/src'])
61 sdk_env.AppendUnique(CPPPATH = ['SDK/cpp/include'])
62
63 ssm_sdk_cpp_src = [
64                 Glob('SDK/cpp/src/*.cpp')
65                 ]
66
67 env.AppendTarget('libSSMSDK')
68 libssmsdk = sdk_env.StaticLibrary(
69                 target = 'libSSMSDK',
70                 source = [ssm_sdk_cpp_src]
71                 )
72 sdk_env.InstallTarget(libssmsdk, 'libSSMCORE')
73
74 ######################################################################
75 # build DiscomfortIndexSensor plugin
76 ######################################################################
77 DiscomfortIndexSensor_env = soft_sensor_manager_env.Clone()
78
79 DiscomfortIndexSensor_env.AppendUnique(CCFLAGS = ['-fPIC'])
80 DISCOMFORTINDEXSENSOR_DIR = 'SoftSensorPlugin/DiscomfortIndexSensor/'
81 DiscomfortIndexSensor_env.AppendUnique(CPPPATH = [
82                 DISCOMFORTINDEXSENSOR_DIR + 'include',
83                 'SSMCore/src/SSMInterface/'
84                 ])
85
86 DiscomfortIndexSensor_src = [ Glob(DISCOMFORTINDEXSENSOR_DIR + 'src/*.cpp')]
87
88 DiscomfortIndexSensor = DiscomfortIndexSensor_env.SharedLibrary('DiscomfortIndexSensor', DiscomfortIndexSensor_src)
89 DiscomfortIndexSensor_env.InstallTarget(DiscomfortIndexSensor, 'libDiscomfortIndexSensor')
90
91
92
93
94 ######################################################################
95 # build BMISensor plugin
96 ######################################################################
97 BMISensor_env = soft_sensor_manager_env.Clone()
98
99 BMISensor_env.AppendUnique(CCFLAGS = ['-fPIC'])
100 BMISENSOR_DIR = 'SoftSensorPlugin/BMISensor/'
101 BMISensor_env.AppendUnique(CPPPATH = [
102                 BMISENSOR_DIR + 'include',
103                 'SSMCore/src/SSMInterface/'
104                 ])
105
106 BMISensor_src = [ Glob(BMISENSOR_DIR + 'src/*.cpp')]
107
108 BMISensor = BMISensor_env.SharedLibrary('BMISensor', BMISensor_src)
109 BMISensor_env.InstallTarget(BMISensor, 'libBMISensor')
110
111
112
113 ######################################################################
114 # build SSM CORE
115 ######################################################################
116 ssmcore_env = soft_sensor_manager_env.Clone()
117
118 ssmcore_env.AppendUnique(CPPPATH = [
119                 env.get('SRC_DIR')+'/extlibs',
120                 'SSMCore/include/',
121                 'SSMCore/src/',
122                 'SSMCore/src/Common/'
123                 'SSMCore/src/QueryProcessor/'
124                 'SSMCore/src/SensorProcessor/'
125                 'SSMCore/src/SSMInterface/'
126                 ])
127
128 import os.path
129
130 SSMINTERFACE_PATH = 'SSMCore/src/SSMInterface/'
131
132 if target_os != 'android':
133         omit_src = ['SSMCore_JNI.cpp']
134         ssminterface_src = [f for f in env.Glob(SSMINTERFACE_PATH + '*.cpp') if os.path.basename(f.path) not in omit_src]
135 else :
136         ssminterface_src = Glob(SSMINTERFACE_PATH + '*.cpp')
137
138 ssm_core_cpp_src = [
139                 Glob('SSMCore/src/Common/*.cpp'),
140                 Glob('SSMCore/src/QueryProcessor/*.cpp'),
141                 Glob('SSMCore/src/SensorProcessor/*.cpp'),
142                 ssminterface_src,
143                 ]
144
145 ssm_core_c_src = [
146                 'SSMCore/src/Common/sqlite3.c'
147 ]
148
149
150 static_libssmcore = ssmcore_env.StaticLibrary(
151                 target = 'SSMCore',
152                 source = [ssm_core_cpp_src, ssm_core_c_src]
153                 )
154
155 ssmcore_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
156 ssmcore_env.AppendUnique(LIBS = ['oc', 'octbstack', 'oc_logger',
157             'connectivity_abstraction', 'coap'])
158
159 shared_libssmcore = ssmcore_env.SharedLibrary(
160                 target = 'SSMCore',
161                 source = [ssm_core_cpp_src, ssm_core_c_src]
162                 )
163
164 ssmcore_env.InstallTarget([shared_libssmcore, static_libssmcore], 'libSSMCORE')
165
166 #######################################################################
167 ## build SampleApp
168 #######################################################################
169 SConscript('SampleApp/SConscript')
170
171
172 ######################################################################
173 # Copy description xml and deliverables
174 ######################################################################
175 if target_os == 'linux':
176         Command("SSMTesterApp","SampleApp/linux/SSMTesterApp/SSMTesterApp", Copy("$TARGET", "$SOURCE"))
177         Command("SoftSensorDescription.xml", "SoftSensorPlugin/SoftSensorDescription.xml", Copy("$TARGET", "$SOURCE"))
178         Command("THSensorApp","SampleApp/linux/THSensorApp/THSensorApp", Copy("$TARGET", "$SOURCE"))
179         Command("THSensorApp1","SampleApp/linux/THSensorApp1/THSensorApp1", Copy("$TARGET", "$SOURCE"))
180         Command("HeightSensorApp","SampleApp/linux/HeightSensorApp/HeightSensorApp", Copy("$TARGET", "$SOURCE"))
181         Command("WeightSensorApp","SampleApp/linux/WeightSensorApp/WeightSensorApp", Copy("$TARGET", "$SOURCE"))