summaryrefslogtreecommitdiff
path: root/service/notification/SConscript
blob: c3fd78697fe41c8488c6423966edf04981bc2f70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#******************************************************************
#
# Copyright 2016 Samsung Electronics All Rights Reserved.
#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

##
# Notification Service build script
##

import platform
Import('env')

if env.get('RELEASE'):
	env.AppendUnique(CCFLAGS = ['-Os'])
	env.AppendUnique(CPPDEFINES = ['NDEBUG'])
else:
	env.AppendUnique(CCFLAGS = ['-g'])

if env.get('LOGGING'):
	env.AppendUnique(CPPDEFINES = ['TB_LOG'])

lib_env = env.Clone()
SConscript(env.get('SRC_DIR') + '/service/third_party_libs.scons', 'lib_env')
notification_env = lib_env.Clone()

target_os = env.get('TARGET_OS')
######################################################################
# Build flags
######################################################################
notification_env.AppendUnique(CPPPATH = ['include'])
notification_env.AppendUnique(CPPPATH = ['src/common'])
notification_env.AppendUnique(CPPPATH = ['src/provider'])
notification_env.AppendUnique(CPPPATH = ['src/consumer'])
notification_env.AppendUnique(CPPPATH = ['../../resource/csdk/stack/include'])
notification_env.AppendUnique(CPPPATH = ['../../resource/csdk/resource-directory/include'])
notification_env.AppendUnique(CPPPATH = ['../../resource/csdk/connectivity/api'])

notification_env.PrependUnique(LIBS = [
	'octbstack',
	'oc_logger',
	'connectivity_abstraction',
	'libcoap',
	'resource_directory'
	])

if target_os not in ['windows', 'winrt']:
	notification_env.AppendUnique(CCFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0'])

if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
	notification_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])

if target_os == 'linux':
	notification_env.AppendUnique(LIBS = ['pthread'])
	if not env.get('RELEASE'):
		notification_env.PrependUnique(LIBS = ['gcov'])
		notification_env.AppendUnique(CCFLAGS = ['--coverage'])

if target_os == 'android':
	notification_env.AppendUnique(CCFLAGS = ['-frtti', '-fexceptions'])
	notification_env.AppendUnique(LIBS = ['gnustl_shared','log'])

	if not env.get('RELEASE'):
		notification_env.AppendUnique(LIBS = ['log'])

if target_os == 'tizen':
	notification_env.AppendUnique(CPPDEFINES = ['__TIZEN__'])
	# notification_env.ParseConfig('pkg-config --cflags --libs sqlite3')

if 'CLIENT' in notification_env.get('RD_MODE'):
	notification_env.AppendUnique(CPPDEFINES = ['RD_CLIENT'])

if env.get('WITH_CLOUD') == True:
	notification_env.AppendUnique(CPPDEFINES = ['WITH_CLOUD'])

if env.get('SECURED') == '1':
	notification_env.AppendUnique(CPPDEFINES = ['SECURED'])

with_mq = env.get('WITH_MQ')
if 'SUB' in with_mq:
    notification_env.AppendUnique(CPPDEFINES = ['MQ_SUBSCRIBER', 'WITH_MQ'])
    print("MQ SUB support")

if 'PUB' in with_mq:
    notification_env.AppendUnique(CPPDEFINES = ['MQ_PUBLISHER', 'WITH_MQ'])
    print("MQ PUB support")

if 'BROKER' in with_mq:
    notification_env.AppendUnique(CPPDEFINES = ['MQ_BROKER', 'WITH_MQ'])
    print("MQ Broker support")


######################################################################
# Source files and Targets
######################################################################
notification_provider_env = notification_env.Clone()
notification_consumer_env = notification_env.Clone()

if target_os == 'android':
	notification_provider_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,libnotification_provider.so'])
if target_os == 'android':
	notification_consumer_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,libnotification_consumer.so'])

notification_common_obj = notification_provider_env.SharedObject(env.Glob('src/common/*.c'))

notification_provider_src = [
	env.Glob('src/provider/*.c'), notification_common_obj]
notification_consumer_src = [
	env.Glob('src/consumer/*.c'), notification_common_obj]

if target_os not in ['ios']:
    providersdk = notification_provider_env.SharedLibrary('notification_provider', notification_provider_src)
    notification_provider_env.InstallTarget(providersdk, 'libnotification_provider')
    notification_provider_env.UserInstallTargetLib(providersdk, 'libnotification_provider')
    consumersdk = notification_consumer_env.SharedLibrary('notification_consumer', notification_consumer_src)
    notification_consumer_env.InstallTarget(consumersdk, 'libnotification_consumer')
    notification_consumer_env.UserInstallTargetLib(consumersdk, 'libnotification_consumer')

providersdk = notification_provider_env.StaticLibrary('notification_provider', notification_provider_src)
notification_provider_env.InstallTarget(providersdk, 'libnotification_provider')
notification_provider_env.UserInstallTargetLib(providersdk, 'libnotification_provider')

consumersdk = notification_consumer_env.StaticLibrary('notification_consumer', notification_consumer_src)
notification_consumer_env.InstallTarget(consumersdk, 'libnotification_consumer')
notification_consumer_env.UserInstallTargetLib(consumersdk, 'libnotification_consumer')

notification_provider_env.UserInstallTargetHeader('include/NSProviderInterface.h',\
	'service/notification', 'NSProviderInterface.h')
notification_consumer_env.UserInstallTargetHeader('include/NSConsumerInterface.h',\
	'service/notification', 'NSConsumerInterface.h')
notification_consumer_env.UserInstallTargetHeader('include/NSCommon.h',\
	'service/notification', 'NSCommon.h')


# Go to build Unit test
if target_os == 'linux':
    SConscript('unittest/SConscript')

# Go to build c++ wrapper
SConscript('cpp-wrapper/SConscript')

if target_os == 'android':
    SConscript('android/SConscript')

# Go to build sample apps
#SConscript('examples/SConscript')