fix errata and revise build script
[platform/upstream/iotivity.git] / service / resource-hosting / 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 # NotificationManager build script
23 ##
24
25 Import('env')
26
27 if env.get('RELEASE'):
28         env.AppendUnique(CCFLAGS = ['-Os'])
29         env.AppendUnique(CPPDEFINES = ['NDEBUG'])
30 else:
31         env.AppendUnique(CCFLAGS = ['-g'])
32
33 if env.get('LOGGING'):
34         env.AppendUnique(CPPDEFINES = ['TB_LOG'])
35
36 lib_env = env.Clone()
37 SConscript(env.get('SRC_DIR') + '/service/third_party_libs.scons', 'lib_env')
38 resourcehosting_env = lib_env.Clone()
39
40 target_os = env.get('TARGET_OS')
41 ######################################################################
42 # Build flags
43 ######################################################################
44 resourcehosting_env.AppendUnique(CPPPATH = ['include'])
45 resourcehosting_env.AppendUnique(CPPPATH = ['../resource-encapsulation/include'])
46 resourcehosting_env.AppendUnique(CPPPATH = ['../resource-encapsulation/src/common/primitiveResource/include'])
47
48 resourcehosting_env.PrependUnique(LIBS = [
49         'rcs_client',
50         'rcs_server',
51         'rcs_common',
52         'oc',
53         'octbstack',
54         'oc_logger',
55         'connectivity_abstraction',
56         'libcoap'
57         ])
58
59 if target_os not in ['windows', 'winrt']:
60         resourcehosting_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0', '-std=c++0x'])
61
62 if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
63         resourcehosting_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
64
65 if target_os == 'linux':
66         resourcehosting_env.AppendUnique(LIBS = ['pthread'])
67
68 if target_os == 'android':
69         resourcehosting_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
70         resourcehosting_env.AppendUnique(LIBS = ['gnustl_shared','log'])
71
72         if not env.get('RELEASE'):
73                 resourcehosting_env.AppendUnique(LIBS = ['log'])
74
75 ######################################################################
76 # Source files and Targets
77 ######################################################################
78 HOSTING_SRC_DIR = 'src/'
79 resourcehosting_src = [
80         HOSTING_SRC_DIR + 'Hosting.cpp',
81         HOSTING_SRC_DIR + 'ResourceHosting.cpp',
82         HOSTING_SRC_DIR + 'HostingObject.cpp',
83         HOSTING_SRC_DIR + 'RequestObject.cpp'
84         ]
85
86 if target_os in ['tizen','android'] :
87     resourcehostingsdk = resourcehosting_env.SharedLibrary('resource_hosting', resourcehosting_src)
88 else :
89     resourcehostingsdk = resourcehosting_env.StaticLibrary('resource_hosting', resourcehosting_src)
90
91 resourcehosting_env.InstallTarget(resourcehostingsdk, 'libresource_hosting')
92 resourcehosting_env.UserInstallTargetLib(resourcehostingsdk, 'libresource_hosting')
93 resourcehosting_env.UserInstallTargetHeader('include/Hosting.h', 'iotivity-service', 'Hosting.h')
94
95 # Go to build Unit test
96 if target_os == 'linux':
97         SConscript('src/unittest/SConscript')
98
99 # Go to build sample apps
100 SConscript('SampleApp/SConscript')