replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / service / coap-http-proxy / 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 import os
22 import os.path
23
24 ##
25 # CoAP-HTTP Proxy Unit Test build script
26 ##
27 # SConscript file for Local PKI google tests
28 gtest_env = SConscript('#extlibs/gtest/SConscript')
29 lib_env = gtest_env.Clone()
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 SConscript('#service/third_party_libs.scons', 'lib_env')
41
42 ######################################################################
43 #unit test setting
44 ######################################################################
45 src_dir = lib_env.get('SRC_DIR')
46
47 CoAP_test_env = lib_env.Clone()
48 target_os = CoAP_test_env.get('TARGET_OS')
49
50 ######################################################################
51 # Build flags
52 ######################################################################
53
54 CoAP_test_env.AppendUnique(LIBPATH = [lib_env.get('BUILD_DIR')])
55 CoAP_test_env.AppendUnique(LIBS = [
56     'coap_http_proxy','oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'coap'])
57
58 if target_os not in ['windows']:
59     CoAP_test_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0'])
60
61 if not CoAP_test_env.get('RELEASE'):
62     CoAP_test_env.PrependUnique(LIBS = ['gcov'])
63     CoAP_test_env.AppendUnique(CXXFLAGS = ['--coverage'])
64
65 CoAP_test_env.AppendUnique(CPPPATH = [src_dir + '/extlibs/hippomocks-master',
66                         '../include',
67                         os.path.join(src_dir, 'resource/csdk/stack/include'),
68                         os.path.join(src_dir, 'resource/csdk/connectivity/common/inc/'),
69                         os.path.join(src_dir, 'resource/csdk/connectivity/lib/libcoap-4.1.1'),
70                         os.path.join(src_dir, 'extlibs/cjson'),
71                 ])
72
73 CoAP_test_env.AppendUnique(CPPPATH = ['../../resource-encapsulation/include'])
74 CoAP_test_env.AppendUnique(CPPPATH = ['../../resource-encapsulation/src/common/primitiveResource/include'])
75 CoAP_test_env.AppendUnique(CPPPATH = ['../../resource-encapsulation/src/common/utils/include'])
76
77
78 if target_os in ['linux']:
79     CoAP_test_env.AppendUnique(LIBS = ['pthread', 'curl'])
80
81
82 if CoAP_test_env.get('SECURED') == '1':
83     CoAP_test_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509', 'mbedcrypto'])
84 ######################################################################
85 # Build Test
86 ######################################################################
87
88 CoAP_unit_test_src = CoAP_test_env.Glob('./CoAPHttpUnitTest.cpp')
89 CoAP_unit_test = CoAP_test_env.Program('CoAP_unit_test', CoAP_unit_test_src)
90 Alias("CoAP_unit_test", CoAP_unit_test)
91 CoAP_test_env.AppendTarget('CoAP_unit_test')
92 CoAP_test_env.InstallTarget(CoAP_unit_test, 'CoAP_unit_test')
93