Fix to prevent of crash on the unit test.
[platform/upstream/iotivity.git] / service / notification / 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 # Notification Service build script
23 ##
24
25 import platform
26 Import('env')
27
28 if env.get('RELEASE'):
29         env.AppendUnique(CCFLAGS = ['-Os'])
30         env.AppendUnique(CPPDEFINES = ['NDEBUG'])
31 else:
32         env.AppendUnique(CCFLAGS = ['-g'])
33
34 if env.get('LOGGING'):
35         env.AppendUnique(CPPDEFINES = ['TB_LOG'])
36
37 lib_env = env.Clone()
38 SConscript(env.get('SRC_DIR') + '/service/third_party_libs.scons', 'lib_env')
39 notification_env = lib_env.Clone()
40
41 target_os = env.get('TARGET_OS')
42 ######################################################################
43 # Build flags
44 ######################################################################
45 notification_env.AppendUnique(CPPPATH = ['include'])
46 notification_env.AppendUnique(CPPPATH = ['src/common'])
47 notification_env.AppendUnique(CPPPATH = ['src/provider'])
48 notification_env.AppendUnique(CPPPATH = ['src/consumer'])
49 notification_env.AppendUnique(CPPPATH = ['#/resource/csdk/include'])
50 notification_env.AppendUnique(CPPPATH = ['#/resource/csdk/security/include'])
51 notification_env.AppendUnique(CPPPATH = ['#/resource/csdk/stack/include'])
52 notification_env.AppendUnique(CPPPATH = ['#/resource/csdk/resource-directory/include'])
53 notification_env.AppendUnique(CPPPATH = ['#/resource/csdk/connectivity/api'])
54
55 notification_env.PrependUnique(LIBS = [
56         'octbstack',
57         'oc_logger',
58         'connectivity_abstraction',
59         'libcoap',
60         'resource_directory'
61         ])
62
63 if target_os not in ['windows', 'winrt']:
64         notification_env.AppendUnique(CCFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0'])
65
66 if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
67         notification_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
68
69 if target_os == 'linux':
70         notification_env.AppendUnique(LIBS = ['pthread'])
71         if not env.get('RELEASE'):
72                 notification_env.PrependUnique(LIBS = ['gcov'])
73                 notification_env.AppendUnique(CCFLAGS = ['--coverage'])
74
75 if target_os == 'android':
76         notification_env.AppendUnique(CCFLAGS = ['-frtti', '-fexceptions'])
77         notification_env.AppendUnique(LIBS = ['gnustl_shared','log'])
78
79         if not env.get('RELEASE'):
80                 notification_env.AppendUnique(LIBS = ['log'])
81
82 if target_os == 'tizen':
83         notification_env.AppendUnique(CPPDEFINES = ['__TIZEN__'])
84         # notification_env.ParseConfig('pkg-config --cflags --libs sqlite3')
85
86 if env.get('WITH_CLOUD') == True:
87         notification_env.AppendUnique(CPPDEFINES = ['WITH_CLOUD'])
88
89 if env.get('SECURED') == '1':
90         notification_env.AppendUnique(CPPDEFINES = ['SECURED'])
91         
92 with_mq = env.get('WITH_MQ')
93 if 'SUB' in with_mq:
94     notification_env.AppendUnique(CPPDEFINES = ['MQ_SUBSCRIBER', 'WITH_MQ'])
95     print "MQ SUB support"
96
97 if 'PUB' in with_mq:
98     notification_env.AppendUnique(CPPDEFINES = ['MQ_PUBLISHER', 'WITH_MQ'])
99     print "MQ PUB support"
100
101 if 'BROKER' in with_mq:
102     notification_env.AppendUnique(CPPDEFINES = ['MQ_BROKER', 'WITH_MQ'])
103     print "MQ Broker support"
104
105
106 ######################################################################
107 # Source files and Targets
108 ######################################################################
109 notification_provider_env = notification_env.Clone()
110 notification_consumer_env = notification_env.Clone()
111
112 if target_os == 'android':
113         notification_provider_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,libnotification_provider.so'])
114 if target_os == 'android':
115         notification_consumer_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,libnotification_consumer.so'])
116
117 notification_common_obj = notification_provider_env.SharedObject(env.Glob('src/common/*.c'))
118
119 notification_provider_src = [
120         env.Glob('src/provider/*.c'), notification_common_obj]
121 notification_consumer_src = [
122         env.Glob('src/consumer/*.c'), notification_common_obj]
123
124 if target_os not in ['ios']:
125         providersdk = notification_provider_env.SharedLibrary('notification_provider', notification_provider_src)
126         notification_provider_env.InstallTarget(providersdk, 'libnotification_provider')
127         notification_provider_env.UserInstallTargetLib(providersdk, 'libnotification_provider')
128         consumersdk = notification_consumer_env.SharedLibrary('notification_consumer', notification_consumer_src)
129         notification_consumer_env.InstallTarget(consumersdk, 'libnotification_consumer')
130         notification_consumer_env.UserInstallTargetLib(consumersdk, 'libnotification_consumer')
131
132 providersdk = notification_provider_env.StaticLibrary('notification_provider', notification_provider_src)
133 notification_provider_env.InstallTarget(providersdk, 'libnotification_provider')
134 notification_provider_env.UserInstallTargetLib(providersdk, 'libnotification_provider')
135
136 consumersdk = notification_consumer_env.StaticLibrary('notification_consumer', notification_consumer_src)
137 notification_consumer_env.InstallTarget(consumersdk, 'libnotification_consumer')
138 notification_consumer_env.UserInstallTargetLib(consumersdk, 'libnotification_consumer')
139
140 notification_provider_env.UserInstallTargetHeader('include/NSProviderInterface.h',\
141         'service/notification', 'NSProviderInterface.h')
142 notification_consumer_env.UserInstallTargetHeader('include/NSConsumerInterface.h',\
143         'service/notification', 'NSConsumerInterface.h')
144 notification_consumer_env.UserInstallTargetHeader('include/NSCommon.h',\
145         'service/notification', 'NSCommon.h')
146
147
148 # Go to build Unit test
149 if target_os in ['linux']:
150     SConscript('unittest/SConscript')
151
152 # Go to build c++ wrapper
153 SConscript('cpp-wrapper/SConscript')
154
155
156 if target_os == 'android':
157     SConscript('android/SConscript')
158
159 # Go to build sample apps
160 SConscript('examples/SConscript')