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