Merge branch 'notification-service'
[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/stack/include'])
50 notification_env.AppendUnique(CPPPATH = ['../../resource/csdk/connectivity/api'])
51
52 if target_os == 'linux':
53     notification_env.AppendUnique(CPPPATH = ['src/provider/cache/linux'])
54     notification_env.AppendUnique(CPPPATH = ['src/consumer/cache/linux'])
55
56 # [TO-DO] change to android DB. 
57 if target_os == 'android': 
58     notification_env.AppendUnique(CPPPATH = ['src/provider/cache/linux'])
59     notification_env.AppendUnique(CPPPATH = ['src/consumer/cache/linux'])
60
61 notification_env.PrependUnique(LIBS = [
62         'octbstack',
63         'oc_logger',
64         'connectivity_abstraction',
65         'libcoap'
66         ])
67
68 if target_os not in ['windows', 'winrt']:
69         notification_env.AppendUnique(CCFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0'])
70
71 if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
72         notification_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
73
74 if target_os == 'linux':
75         notification_env.AppendUnique(LIBS = ['pthread'])
76
77 if target_os == 'android':
78         notification_env.AppendUnique(CCFLAGS = ['-frtti', '-fexceptions'])
79         notification_env.AppendUnique(LIBS = ['gnustl_shared','log'])
80         notification_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,libnotification_provider.so'])
81
82         if not env.get('RELEASE'):
83                 notification_env.AppendUnique(LIBS = ['log'])
84
85 if not env.get('RELEASE'):
86     notification_env.PrependUnique(LIBS = ['gcov'])
87     notification_env.AppendUnique(CCFLAGS = ['--coverage'])
88     
89 if env.get('WITH_CLOUD') == True:       
90         notification_env.AppendUnique(CPPDEFINES = ['WITH_CLOUD'])    
91
92 ######################################################################
93 # Source files and Targets
94 ######################################################################
95
96 if target_os == 'linux':
97     PROVIDER_CACHE = File('src/provider/cache/linux/NSProviderMemoryCache.c')
98     CONSUMER_CACHE = File('src/consumer/cache/linux/NSConsumerMemoryCache.c')
99
100 if target_os == 'android':
101     PROVIDER_CACHE = File('src/provider/cache/linux/NSProviderMemoryCache.c')
102     CONSUMER_CACHE = File('src/consumer/cache/linux/NSConsumerMemoryCache.c')
103
104 notification_provider_src = [
105         env.Glob('src/provider/*.c'),
106         env.Glob('src/common/*.c'), PROVIDER_CACHE]
107 notification_consumer_src = [
108         env.Glob('src/consumer/*.c'),
109         env.Glob('src/common/*.c'), CONSUMER_CACHE]
110
111 providersdk = notification_env.SharedLibrary('notification_provider', notification_provider_src)
112 notification_env.InstallTarget(providersdk, 'libnotification_provider')
113 notification_env.UserInstallTargetLib(providersdk, 'libnotification_provider')
114
115 consumersdk = notification_env.SharedLibrary('notification_consumer', notification_consumer_src)
116 notification_env.InstallTarget(consumersdk, 'libnotification_consumer')
117 notification_env.UserInstallTargetLib(consumersdk, 'libnotification_consumer')
118
119 providersdk = notification_env.StaticLibrary('notification_provider', notification_provider_src)
120 notification_env.InstallTarget(providersdk, 'libnotification_provider')
121 notification_env.UserInstallTargetLib(providersdk, 'libnotification_provider')
122
123 consumersdk = notification_env.StaticLibrary('notification_consumer', notification_consumer_src)
124 notification_env.InstallTarget(consumersdk, 'libnotification_consumer')
125 notification_env.UserInstallTargetLib(consumersdk, 'libnotification_consumer')
126
127 notification_env.UserInstallTargetHeader('include/NSProviderInterface.h',\
128         'service/notification', 'NSProviderInterface.h')
129 notification_env.UserInstallTargetHeader('include/NSConsumerInterface.h',\
130         'service/notification', 'NSConsumerInterface.h')
131
132 # Go to build Unit test
133 if target_os == 'linux':
134  SConscript('unittest/SConscript')
135
136 # Go to build sample apps
137 SConscript('examples/SConscript')
138
139 # Go to build jni
140 if target_os == 'android':
141     SConscript('android/SConscript')
142
143  # Go to build c++ wrapper
144 #SConscript('cpp-wrapper/SConscript')