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(env.get('SRC_DIR') + '/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',
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', 'winrt']:
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', 'winrt']:
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']])
104 resource_container_env.PrependUnique(LIBS = ['rcs_client', 'rcs_server', 'rcs_common', 'oc','octbstack', 'oc_logger', 'oc_logger_core', 'connectivity_abstraction'])
105 resource_container_env.AppendUnique(LIBS = ['dl', 'boost_system', 'boost_date_time', 'boost_thread'])
107 if int(containerJavaSupport):
109 print 'Java Lib: ', os.environ['JAVA_LIB']
110 resource_container_env.AppendUnique(LIBS = ['jvm'])
114 ######################################################################
115 # Source files and Targets
116 ######################################################################
117 res_container_src = ['src/BaseActivator.cpp','src/BundleActivator.cpp','src/RCSBundleInfo.cpp',
118 'src/BundleInfoInternal.cpp', 'src/BundleResource.cpp', 'src/Configuration.cpp', 'src/JavaBundleResource.cpp', 'src/ProtocolBridgeResource.cpp',
119 'src/ProtocolBridgeConnector.cpp', 'src/RCSResourceContainer.cpp', 'src/ResourceContainerBundleAPI.cpp', 'src/ResourceContainerImpl.cpp',
120 'src/SoftSensorResource.cpp', 'src/DiscoverResourceUnit.cpp', 'src/RemoteResourceUnit.cpp',
123 res_container_static = resource_container_env.StaticLibrary('rcs_container', res_container_src)
124 res_container_shared = resource_container_env.SharedLibrary('rcs_container', res_container_src)
126 resource_container_env.InstallTarget([res_container_static,res_container_shared], 'libResContainer')
128 ######################################################################
129 # build soft sensor sample bundle
130 ######################################################################
131 if target_os in ['linux', 'tizen', 'android']:
132 ss_resource_bundle_env = resource_container_env.Clone()
133 ss_resource_bundle_env.AppendUnique(CCFLAGS = ['-fPIC'])
135 SS_RESOURCE_BUNDLE_DIR = 'examples/SoftSensorSampleBundle/'
136 ss_resource_bundle_env.AppendUnique(CPPPATH = [
137 SS_RESOURCE_BUNDLE_DIR + 'include',
142 ss_resource_bundle_env.PrependUnique(LIBS = ['rcs_container'])
144 ss_resource_bundle_src = [ Glob(SS_RESOURCE_BUNDLE_DIR + 'src/*.cpp')]
146 SoftSensorBundle = ss_resource_bundle_env.SharedLibrary('SoftSensorBundle', ss_resource_bundle_src)
147 ss_resource_bundle_env.InstallTarget(SoftSensorBundle, 'libSoftSensorBundle')
149 ######################################################################
150 # build hue sample bundle
151 ######################################################################
153 conf2 = Configure(lib_env)
154 if not conf2.CheckLib('curl'):
156 *********************************** Error *************************************
157 * Cannot build hue sample. Please install libcurl.
159 * sudo apt-get install libcurl4-openssl-dev
161 * Hint: check with pkg-config --libs libcurl and clear scons cache.
162 * Skipping hue sample build.
163 *******************************************************************************
166 hue_resource_bundle_env = resource_container_env.Clone()
167 hue_resource_bundle_env.AppendUnique(CCFLAGS = ['-fPIC'])
169 HUE_RESOURCE_BUNDLE_DIR = 'examples/HueSampleBundle/'
170 hue_resource_bundle_env.AppendUnique(CPPPATH = [
171 HUE_RESOURCE_BUNDLE_DIR + 'include',
175 hue_resource_bundle_env.PrependUnique(LIBS = ['curl', 'rcs_container'])
177 hue_resource_bundle_src = [ Glob(HUE_RESOURCE_BUNDLE_DIR + 'src/*.cpp')]
179 HueBundle = hue_resource_bundle_env.SharedLibrary('HueBundle', hue_resource_bundle_src)
180 hue_resource_bundle_env.InstallTarget(HueBundle, 'libHueBundle')
181 lib_env = conf2.Finish()
183 ######################################################################
184 # build resource container unit tests
185 ######################################################################
186 if target_os == 'linux':
187 SConscript('unittests/SConscript')
189 ######################################################################
190 # Build Container Sample
191 ######################################################################
192 containersample_env = resource_container_env.Clone();
193 containersample_env.AppendUnique(LINKFLAGS=["-rdynamic"])
195 # Copy test configuration
196 Command("examples/ResourceContainerConfig.xml","examples/ResourceContainerConfig.xml", Copy("$TARGET", "$SOURCE"))
197 Ignore("examples/ResourceContainerConfig.xml", "examples/ResourceContainerConfig.xml")
199 containersample_env.AppendUnique(LIBS = ['rcs_container'])
201 containersampleapp_src = ['examples/ContainerSample.cpp']
202 containersampleapp = containersample_env.Program('ContainerSample',containersampleapp_src)
203 Alias("containersample", containersampleapp)
204 env.AppendTarget('containersample')
206 ######################################################################
207 # Build Container Sample Client
208 ######################################################################
209 containersampleclient_env = resource_container_env.Clone();
211 containersample_env.AppendUnique(LIBS = ['rcs_container'])
212 containersampleclient_src = ['examples/ContainerSampleClient.cpp']
213 containersampleclientapp = containersample_env.Program('ContainerSampleClient',containersampleclient_src)
214 Alias("containersampleclient", containersampleclientapp)
215 env.AppendTarget('containersampleclient')