resource-directory: Fix libs dependencies and order
[platform/upstream/iotivity.git] / resource / csdk / resource-directory / unittests / 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 # ResourceDirectory Unit Test build script
23 ##
24 # SConscript file for Local PKI google tests
25 from tools.scons.RunTest import run_test
26
27 gtest_env = SConscript('#extlibs/gtest/SConscript')
28 lib_env = gtest_env.Clone()
29 target_os = lib_env.get('TARGET_OS')
30
31 if lib_env.get('RELEASE'):
32     lib_env.AppendUnique(CCFLAGS = ['-Os'])
33     lib_env.AppendUnique(CPPDEFINES = ['NDEBUG'])
34 else:
35     lib_env.AppendUnique(CCFLAGS = ['-g'])
36
37 if lib_env.get('LOGGING'):
38     lib_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
39
40 # Add third party libraries
41 SConscript('#resource/third_party_libs.scons', 'lib_env')
42
43 if target_os in ['linux']:
44     # Verify that 'hippomocks' mocking code is installed.  If not,
45     # get it and install it
46     SConscript('#extlibs/hippomocks.scons')
47
48 rd_test_env = lib_env.Clone()
49
50 ######################################################################
51 #unit test setting
52 ######################################################################
53 src_dir = lib_env.get('SRC_DIR')
54
55 ######################################################################
56 # Build flags
57 ######################################################################
58 rd_test_env.AppendUnique(
59         CPPPATH = [
60                 src_dir + '/extlibs/hippomocks-master',
61                 '../include',
62                 src_dir + '/resource/include',
63                 src_dir + '/resource/csdk/include',
64                 src_dir + '/resource/csdk/stack/include',
65                 src_dir + '/resource/csdk/security/include',
66                 src_dir + '/resource/csdk/stack/test/',
67                 src_dir + '/resource/oc_logger/include',])
68
69 rd_test_env.AppendUnique(LIBPATH = [lib_env.get('BUILD_DIR')])
70 rd_test_env.AppendUnique(RPATH = [lib_env.get('BUILD_DIR')])
71 rd_test_env.PrependUnique(LIBS = ['octbstack'])
72
73 if rd_test_env.get('RD_MODE'):
74     rd_mode = rd_test_env.get('RD_MODE')
75     rd_test_env.PrependUnique(LIBS = ['resource_directory'])
76     if 'CLIENT' in rd_mode:
77         rd_test_env.AppendUnique(CPPDEFINES = ['RD_CLIENT'])
78         rd_test_env.AppendUnique(LIBS = ['oc', 'oc_logger'])
79     if 'SERVER' in rd_mode:
80         rd_test_env.AppendUnique(CPPDEFINES = ['RD_SERVER'])
81
82 ######################################################################
83 # Build Test
84 ######################################################################
85 rd_test_src = ['rdtests.cpp']
86 if 'SERVER' in rd_test_env.get('RD_MODE'):
87     rd_test_src += ['rddatabase.cpp']
88
89 rd_client_test = rd_test_env.Program('rdtests', rd_test_src)
90 Alias("rd_client_test", rd_client_test)
91 rd_test_env.AppendTarget('rd_client_test')
92
93 if rd_test_env.get('TEST') == '1':
94     target_os = rd_test_env.get('TARGET_OS')
95     if target_os in ['linux']:
96         run_test(rd_test_env,
97                  'resource_csdk_resource-directory_unittests_rdtests.memcheck',
98                  'resource/csdk/resource-directory/unittests/rdtests',
99                  rd_client_test)