[Win32] Modify SConscripts to prepare for VS
[platform/upstream/iotivity.git] / resource / csdk / connectivity / test / 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 Import('env')
22 import os
23 import os.path
24 catest_env = env.Clone()
25
26 src_dir = catest_env.get('SRC_DIR')
27
28 ######################################################################
29 # Build flags
30 ######################################################################
31 catest_env.PrependUnique(CPPPATH = [
32                 '../../logger/include',
33                 '../../stack/include',
34                 '../../extlibs/cjson',
35                 '../../../oc_logger/include',
36                 '../../../../extlibs/gtest/gtest-1.7.0/include'
37                ])
38
39 tmplist = catest_env['LINKFLAGS'][:]
40 if '-lpthread' in tmplist:
41     tmplist.remove('-lpthread')
42     catest_env.Replace(LINKFLAGS = tmplist)
43
44 catest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
45 catest_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
46 catest_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
47 catest_env.PrependUnique(LIBS = ['octbstack',
48                                     'connectivity_abstraction',
49                                     'coap',
50                                     'gtest',
51                                     'gtest_main'])
52
53 target_os = env.get('TARGET_OS')
54
55 if target_os not in ['arduino', 'darwin', 'ios', 'msys_nt', 'windows']:
56         catest_env.AppendUnique(LIBS=['rt'])
57
58 if env.get('SECURED') == '1':
59         catest_env.AppendUnique(LIBS = ['tinydtls'])
60         catest_env.AppendUnique(LIBS = ['timer'])
61
62 if env.get('WITH_RD') == '1':
63         catest_env.PrependUnique(LIBS = ['resource_directory'])
64
65 if env.get('LOGGING'):
66         catest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
67
68 if target_os in ['msys_nt', 'windows']:
69         catest_env.AppendUnique(LINKFLAGS = ['/subsystem:CONSOLE'])
70         catest_env.AppendUnique(LIBS = ['ws2_32',
71                                         'advapi32',
72                                         'iphlpapi'])
73 else:
74         catest_env.PrependUnique(LIBS = ['m', 'pthread'])
75
76 ######################################################################
77 # Source files and Targets
78 ######################################################################
79
80 target_os = env.get('TARGET_OS')
81 target_transport = env.get('TARGET_TRANSPORT')
82
83 if (('IP' in target_transport) or ('ALL' in target_transport)):
84         if target_os != 'arduino':
85                 catests = catest_env.Program('catests', ['catests.cpp',
86                                                          'caprotocolmessagetest.cpp',
87                                                          'cablocktransfertest.cpp',
88                                                          'ca_api_unittest.cpp',
89                                                          'camutex_tests.cpp',
90                                                          'uarraylist_test.cpp'
91                                                                ])
92 else:
93         catests = catest_env.Program('catests', ['catests.cpp',
94                                                  'caprotocolmessagetest.cpp',
95                                                  'ca_api_unittest.cpp',
96                                                  'camutex_tests.cpp',
97                                                  'uarraylist_test.cpp'
98                                                        ])
99
100 Alias("test", [catests])
101
102 env.AppendTarget('test')
103 if env.get('TEST') == '1':
104         if target_os in ['linux', 'windows']:
105                 catest_env.AppendENVPath('PATH', env.get('BUILD_DIR'))
106                 from tools.scons.RunTest import *
107                 run_test(catest_env,
108                          'resource_csdk_connectivity_test.memcheck',
109                          'resource/csdk/connectivity/test/catests')