1 #******************************************************************
3 # Copyright 2015 Samsung Electronics 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 # resource container build script
28 containerJavaSupport = ARGUMENTS.get('containerJavaSupport',0)
30 def filtered_glob(env, pattern, omit=[],
31 ondisk=True, source=False, strings=False):
33 lambda f: os.path.basename(f.path) not in omit,
36 env.AddMethod(filtered_glob, "FilteredGlob");
38 # Add third party libraries
40 SConscript('#service/third_party_libs.scons', exports = 'lib_env')
42 resource_container_env = lib_env.Clone()
43 target_os = env.get('TARGET_OS')
44 ######################################################################
46 ######################################################################
48 if int(containerJavaSupport):
50 print 'Java Home: ', os.environ['JAVA_HOME']
51 print 'Java Lib: ', os.environ['JAVA_LIB']
52 resource_container_env.Append(CPPDEFINES={'JAVA_SUPPORT':1})
55 *********************************** Error *************************************
56 * Building resource container without Java support. JAVA_HOME or JAVA_LIB are not set properly
57 * Please configure JAVA_HOME to point to your Java 7 JDK and
58 * JAVA_LIB to your folder containing libjvm
59 * Example: export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386
60 * export JAVA_LIB=/usr/lib/jvm/java-7-openjdk-i386/jre/lib/i386/server
61 *******************************************************************************
63 resource_container_env.Append(CPPDEFINES={'JAVA_SUPPORT':0})
66 resource_container_env.AppendUnique(
68 env.get('SRC_DIR')+'/extlibs',
69 '../resource-encapsulation/include',
75 if int(containerJavaSupport):
77 resource_container_env.AppendUnique(
79 os.environ['JAVA_HOME']+'/include',
80 os.environ['JAVA_HOME']+'/include/linux'
86 if target_os not in ['windows']:
87 resource_container_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
88 if target_os != 'android':
89 resource_container_env.AppendUnique(CXXFLAGS = ['-pthread'])
91 if target_os not in ['darwin', 'ios', 'windows']:
92 resource_container_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
94 if target_os == 'android':
95 resource_container_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
96 resource_container_env.PrependUnique(LIBS = ['gnustl_shared', 'log'])
99 resource_container_env.AppendUnique(LIBPATH = [os.environ['JAVA_LIB']])
103 resource_container_env.PrependUnique(LIBS = ['coap'])
104 resource_container_env.AppendUnique(LIBS = ['connectivity_abstraction'])
105 resource_container_env.AppendUnique(LIBS = ['oc_logger'])
106 resource_container_env.AppendUnique(LIBS = ['octbstack'])
107 resource_container_env.AppendUnique(LIBS = ['oc'])
108 resource_container_env.AppendUnique(LIBS = ['rcs_client'])
109 resource_container_env.AppendUnique(LIBS = ['rcs_server'])
110 resource_container_env.AppendUnique(LIBS = ['rcs_common'])
111 resource_container_env.AppendUnique(LIBS = ['dl'])
112 resource_container_env.AppendUnique(LIBS = ['boost_system'])
113 resource_container_env.AppendUnique(LIBS = ['boost_date_time'])
114 resource_container_env.AppendUnique(LIBS = ['boost_thread'])
116 if resource_container_env.get('SECURED') == '1':
117 if resource_container_env.get('WITH_TCP') == True:
118 resource_container_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509', 'mbedcrypto'])
120 if int(containerJavaSupport):
122 print 'Java Lib: ', os.environ['JAVA_LIB']
123 resource_container_env.AppendUnique(LIBS = ['jvm'])
127 ######################################################################
128 # Source files and Targets
129 ######################################################################
130 res_container_src = [ Glob('src/*.cpp') ]
132 res_container_static = resource_container_env.StaticLibrary('rcs_container', res_container_src)
133 res_container_shared = resource_container_env.SharedLibrary('rcs_container', res_container_src)
135 resource_container_env.InstallTarget([res_container_static,res_container_shared], 'libResContainer')
136 resource_container_env.UserInstallTargetLib([res_container_static,res_container_shared], 'libResContainer')
138 resource_container_env.UserInstallTargetHeader('include/RCSBundleInfo.h', 'service/resource-container', 'RCSBundleInfo.h')
139 resource_container_env.UserInstallTargetHeader('include/RCSResourceContainer.h', 'service/resource-container', 'RCSResourceContainer.h')
141 ######################################################################
142 # build discomfort index sensor sample bundle
143 ######################################################################
144 if target_os in ['linux', 'tizen', 'android']:
145 DI_sensor_bundle_env = resource_container_env.Clone()
146 DI_sensor_bundle_env.AppendUnique(CCFLAGS = ['-fPIC'])
148 DI_SENSOR_BUNDLE_DIR = 'examples/DiscomfortIndexSensorBundle/'
149 DI_sensor_bundle_env.AppendUnique(CPPPATH = [ DI_SENSOR_BUNDLE_DIR + 'include' ])
151 DI_sensor_bundle_env.PrependUnique(LIBS = ['rcs_container'])
153 DI_sensor_bundle_src = [ Glob(DI_SENSOR_BUNDLE_DIR + 'src/*.cpp')]
155 DISensorBundle = DI_sensor_bundle_env.SharedLibrary('DISensorBundle', DI_sensor_bundle_src)
156 DI_sensor_bundle_env.InstallTarget(DISensorBundle, 'libDISensorBundle')
157 DI_sensor_bundle_env.UserInstallTargetLib(DISensorBundle, 'libDISensorBundle')
159 if target_os in ['linux']:
160 SConscript(DI_SENSOR_BUNDLE_DIR + 'src/inputSensors/SConscript')
161 Command("THSensorApp", DI_SENSOR_BUNDLE_DIR + "src/inputSensors/THSensorApp/THSensorApp", Copy("$TARGET", "$SOURCE"))
162 Command("THSensorApp1", DI_SENSOR_BUNDLE_DIR + "src/inputSensors/THSensorApp1/THSensorApp1", Copy("$TARGET", "$SOURCE"))
164 ######################################################################
165 # build BMI sensor sample bundle
166 ######################################################################
167 if target_os in ['linux', 'tizen', 'android']:
168 BMI_sensor_bundle_env = resource_container_env.Clone()
169 BMI_sensor_bundle_env.AppendUnique(CCFLAGS = ['-fPIC'])
171 BMI_SENSOR_BUNDLE_DIR = 'examples/BMISensorBundle/'
172 BMI_sensor_bundle_env.AppendUnique(CPPPATH = [ BMI_SENSOR_BUNDLE_DIR + 'include' ])
174 BMI_sensor_bundle_env.PrependUnique(LIBS = ['rcs_container'])
176 BMI_sensor_bundle_src = [ Glob(BMI_SENSOR_BUNDLE_DIR + 'src/*.cpp')]
178 BMISensorBundle = BMI_sensor_bundle_env.SharedLibrary('BMISensorBundle', BMI_sensor_bundle_src)
179 BMI_sensor_bundle_env.InstallTarget(BMISensorBundle, 'libBMISensorBundle')
180 BMI_sensor_bundle_env.UserInstallTargetLib(BMISensorBundle, 'libBMISensorBundle')
182 if target_os in ['linux']:
183 SConscript(BMI_SENSOR_BUNDLE_DIR + 'src/inputSensors/SConscript')
184 Command("HeightSensorApp", BMI_SENSOR_BUNDLE_DIR + "src/inputSensors/HeightSensorApp/HeightSensorApp", Copy("$TARGET", "$SOURCE"))
185 Command("WeightSensorApp", BMI_SENSOR_BUNDLE_DIR + "src/inputSensors/WeightSensorApp/WeightSensorApp", Copy("$TARGET", "$SOURCE"))
187 ######################################################################
188 # build hue sample bundle
189 ######################################################################
191 conf2 = Configure(lib_env)
192 if not conf2.CheckLib('curl'):
194 *********************************** Error *************************************
195 * Cannot build hue sample. Please install libcurl.
197 * sudo apt-get install libcurl4-openssl-dev
199 * Hint: check with pkg-config --libs libcurl and clear scons cache.
200 * Skipping hue sample build.
201 *******************************************************************************
204 hue_resource_bundle_env = resource_container_env.Clone()
205 hue_resource_bundle_env.AppendUnique(CCFLAGS = ['-fPIC'])
207 HUE_RESOURCE_BUNDLE_DIR = 'examples/HueSampleBundle/'
208 hue_resource_bundle_env.AppendUnique(CPPPATH = [
209 HUE_RESOURCE_BUNDLE_DIR + 'include',
213 hue_resource_bundle_env.PrependUnique(LIBS = ['curl', 'rcs_container'])
215 hue_resource_bundle_src = [ Glob(HUE_RESOURCE_BUNDLE_DIR + 'src/*.cpp')]
217 HueBundle = hue_resource_bundle_env.SharedLibrary('HueBundle', hue_resource_bundle_src)
218 hue_resource_bundle_env.InstallTarget(HueBundle, 'libHueBundle')
219 hue_resource_bundle_env.UserInstallTargetLib(HueBundle, 'libHueBundle')
220 lib_env = conf2.Finish()
222 ######################################################################
223 # build resource container unit tests
224 ######################################################################
225 if target_os in ['linux']:
226 SConscript('unittests/SConscript')
228 ######################################################################
229 # Build Container Sample
230 ######################################################################
231 containersample_env = resource_container_env.Clone();
232 containersample_env.AppendUnique(LINKFLAGS=["-rdynamic"])
234 # Copy test configuration
235 Command("examples/ResourceContainerConfig.xml","examples/ResourceContainerConfig.xml", Copy("$TARGET", "$SOURCE"))
236 Ignore("examples/ResourceContainerConfig.xml", "examples/ResourceContainerConfig.xml")
238 containersample_env.AppendUnique(LIBS = ['rcs_container'])
240 containersampleapp_src = ['examples/ContainerSample.cpp']
241 containersampleapp = containersample_env.Program('ContainerSample',containersampleapp_src)
242 Alias("containersample", containersampleapp)
243 env.AppendTarget('containersample')
245 ######################################################################
246 # Build Container Sample Client
247 ######################################################################
248 containersampleclient_env = resource_container_env.Clone();
250 containersample_env.AppendUnique(LIBS = ['rcs_container'])
251 containersampleclient_src = ['examples/ContainerSampleClient.cpp']
252 containersampleclientapp = containersample_env.Program('ContainerSampleClient',containersampleclient_src)
253 Alias("containersampleclient", containersampleclientapp)
254 env.AppendTarget('containersampleclient')
256 ######################################################################
257 # Build Container Java SDK
258 ######################################################################
259 if target_os == 'android':
260 SConscript('android/SConscript')