Imported Upstream version 1.1.1
[platform/upstream/iotivity.git] / service / resource-hosting / unittest / 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 # ResourceHosting Unit Test build script
23 ##
24 # SConscript file for Local PKI google tests
25 gtest_env = SConscript('#extlibs/gtest/SConscript')
26 lib_env = gtest_env.Clone()
27
28 if lib_env.get('RELEASE'):
29     lib_env.AppendUnique(CCFLAGS = ['-Os'])
30     lib_env.AppendUnique(CPPDEFINES = ['NDEBUG'])
31 else:
32     lib_env.AppendUnique(CCFLAGS = ['-g'])
33
34 if lib_env.get('LOGGING'):
35     lib_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
36
37
38 SConscript('#service/third_party_libs.scons', 'lib_env')
39
40 ######################################################################
41 #unit test setting
42 ######################################################################
43 src_dir = lib_env.get('SRC_DIR')
44
45 hosting_test_env = lib_env.Clone()
46 target_os = hosting_test_env.get('TARGET_OS')
47
48 ######################################################################
49 # Build flags
50 ######################################################################
51
52 hosting_test_env.AppendUnique(LIBPATH = [hosting_test_env.get('BUILD_DIR')])
53 hosting_test_env.AppendUnique(LIBS = [
54         'resource_hosting', 'rcs_server', 'rcs_client','rcs_common',
55         'oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'coap',
56         'gtest_main', 'gtest'])
57
58 if target_os not in ['windows', 'winrt']:
59     hosting_test_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0', '-std=c++0x'])
60
61 if target_os in ['linux']:
62    hosting_test_env.AppendUnique(CXXFLAGS = ['-pthread'])
63    hosting_test_env.AppendUnique(LIBS = ['pthread'])
64
65 hosting_test_env.PrependUnique(CPPPATH = [ src_dir + '/extlibs/hippomocks-master'])
66 hosting_test_env.AppendUnique(CPPPATH = ['../src'])
67 hosting_test_env.AppendUnique(CPPPATH = ['../../resource-encapsulation/include'])
68 hosting_test_env.AppendUnique(CPPPATH = ['../../resource-encapsulation/src/common/primitiveResource/include'])
69 hosting_test_env.AppendUnique(CPPPATH = ['../../resource-encapsulation/src/common/utils/include'])
70 ######################################################################
71 # Build Test
72 ######################################################################
73
74 hosting_test_src = hosting_test_env.Glob('./*.cpp')
75 hosting_test = hosting_test_env.Program('hosting_test', hosting_test_src)
76 Alias("hosting_test", hosting_test)
77 hosting_test_env.AppendTarget('hosting_test')
78
79 if hosting_test_env.get('TEST') == '1':
80     target_os = hosting_test_env.get('TARGET_OS')
81     if target_os in ['linux']:
82             from tools.scons.RunTest import *
83             run_test(hosting_test_env, '', 'service/resource-hosting/unittest/hosting_test')
84