Imported Upstream version 1.1.1
[platform/upstream/iotivity.git] / service / resource-encapsulation / src / common / SConscript
1 #******************************************************************
2 #
3 # Copyright 2015 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 # rcs_common (primitiveResource and expiryTimer) build script
23 ##
24 import os
25
26 # SConscript file for Local PKI google tests
27 gtest_env = SConscript('#extlibs/gtest/SConscript')
28 lib_env = gtest_env.Clone()
29
30
31
32 # Add third party libraries
33 SConscript(lib_env.get('SRC_DIR') + '/service/third_party_libs.scons', exports = 'lib_env')
34 rcs_common_env = lib_env.Clone()
35 target_os = rcs_common_env.get('TARGET_OS')
36 release = rcs_common_env.get('RELEASE')
37 src_dir = rcs_common_env.get('SRC_DIR')
38
39 ######################################################################
40 # Build flags
41 ######################################################################
42 rcs_common_env.AppendUnique(CPPPATH = [
43     rcs_common_env.get('SRC_DIR')+'/extlibs',
44     '../../include',
45     'primitiveResource/include'])
46
47 rcs_common_env.AppendUnique(CPPPATH = [
48     'expiryTimer/include',
49     'expiryTimer/src'])
50
51 rcs_common_env.AppendUnique(LIBPATH = [rcs_common_env.get('BUILD_DIR')])
52
53 if target_os not in ['windows', 'winrt']:
54     rcs_common_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
55     if target_os != 'android':
56         rcs_common_env.AppendUnique(CXXFLAGS = ['-pthread'])
57         rcs_common_env.AppendUnique(LIBS = ['pthread'])
58
59 if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
60     rcs_common_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
61
62 if target_os == 'android':
63     rcs_common_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
64     rcs_common_env.PrependUnique(LIBS = ['gnustl_shared', 'log'])
65
66 rcs_common_env.AppendUnique(LIBS = ['dl', 'oc'])
67
68 if not release:
69     rcs_common_env.AppendUnique(CXXFLAGS = ['--coverage'])
70     rcs_common_env.PrependUnique(LIBS = ['gcov'])
71
72 ######################################################################
73 # Source files and Targets
74 ######################################################################
75 TIMER_SRC_DIR = 'expiryTimer/src/'
76 RESOURCE_SRC = 'primitiveResource/src/'
77 rcs_common_src = [
78         TIMER_SRC_DIR + 'ExpiryTimerImpl.cpp',
79                 TIMER_SRC_DIR + 'ExpiryTimer.cpp',
80                 RESOURCE_SRC + 'PresenceSubscriber.cpp',
81                 RESOURCE_SRC + 'PrimitiveResource.cpp',
82                 RESOURCE_SRC + 'RCSException.cpp',
83                 RESOURCE_SRC + 'RCSAddress.cpp',
84                 RESOURCE_SRC + 'RCSResourceAttributes.cpp',
85                 RESOURCE_SRC + 'RCSRepresentation.cpp'
86         ]
87
88 rcs_common_static = rcs_common_env.StaticLibrary('rcs_common', rcs_common_src)
89 rcs_common_shared = rcs_common_env.SharedLibrary('rcs_common', rcs_common_src)
90 rcs_common_env.InstallTarget([rcs_common_static,rcs_common_shared], 'rcs_common')
91 rcs_common_env.UserInstallTargetLib([rcs_common_static,rcs_common_shared], 'rcs_common')
92
93 ######################################################################
94 # Build Test Expiry Timer and primitive Resource
95 ######################################################################
96 if target_os == 'linux':
97         rcs_common_test_env = rcs_common_env.Clone();
98
99         rcs_common_test_env.PrependUnique(CPPPATH = [
100                 rcs_common_test_env.get('SRC_DIR')+'/extlibs/hippomocks-master',
101                 'utils/include'
102                 ])
103
104         rcs_common_test_env.PrependUnique(LIBS = [
105                 'octbstack',
106                 'oc_logger',
107                 'connectivity_abstraction',
108                 'coap',
109                 'rcs_common',
110                 'gtest',
111                 'gtest_main',
112                 'pthread'
113                 ])
114
115         rcs_common_test_src = [
116                 rcs_common_test_env.Glob('primitiveResource/unittests/*.cpp'),
117                 'expiryTimer/unittests/ExpiryTimerTest.cpp'
118                 ]
119
120         rcs_common_test = rcs_common_test_env.Program('rcs_common_test', rcs_common_test_src)
121         Alias("rcs_common_test", rcs_common_test)
122         rcs_common_test_env.AppendTarget('rcs_common_test')
123
124         if rcs_common_test_env.get('TEST') == '1':
125                 from tools.scons.RunTest import *
126                 run_test(rcs_common_test_env, '',
127                         'service/resource-encapsulation/src/common/rcs_common_test')