Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / resource / provisioning / unittests / 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 provisiontests_env = env.Clone()
25
26 src_dir = provisiontests_env.get('SRC_DIR')
27 with_ra = env.get('WITH_RA')
28 with_ra_ibb = env.get('WITH_RA_IBB')
29 ######################################################################
30 # Build flags
31 ######################################################################
32 provisiontests_env.PrependUnique(CPPPATH = [
33                 '../../include',
34                 '../../oc_logger/include',
35                 '../../csdk/stack/include',
36                 '../../csdk/security/include',
37                 '../../csdk/security/provisioning/include',
38                 '../../csdk/security/provisioning/include/oxm',
39                 '../../csdk/security/provisioning/include/internal',
40                 '../../csdk/stack/include/internal',
41                 '../../csdk/connectivity/api',
42                 '../../csdk/connectivity/external/inc',
43                 '../../csdk/ocsocket/include',
44                 '../../csdk/ocrandom/include',
45                 '../../csdk/logger/include',
46                 '../../../extlibs/gtest/gtest-1.7.0/include',
47                 '../../../extlibs/hippomocks-master/HippoMocks',
48                 '../../../extlibs/hippomocks-master/HippoMocksTest'
49                 ])
50
51 provisiontests_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
52 provisiontests_env.AppendUnique(LIBS = ['-lpthread', '-ldl'])
53 provisiontests_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
54 provisiontests_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
55 provisiontests_env.PrependUnique(LIBS = [
56         'ocprovision',
57                 'oc',
58                 'ocpmapi',
59                 'octbstack',
60                 'oc_logger',
61                 'connectivity_abstraction',
62                 'coap',
63                 'gtest',
64                 'gtest_main',
65                 ])
66
67 if with_ra_ibb:
68         provisiontests_env.AppendUnique(LIBS = provisiontests_env['RALIBS'], LIBPATH = provisiontests_env['RALIBPATH'], RPATH = provisiontests_env['RARPATH'])
69         print "RALIBS = %s" % provisiontests_env['RALIBS']
70         print "RALIBPATH = %s" % provisiontests_env['RALIBPATH']
71         print "RARPATH = %s" % provisiontests_env['RARPATH']
72 else :
73         if with_ra:
74                 provisiontests_env.AppendUnique(LIBS = ['ra_xmpp'])
75
76 if env.get('SECURED') == '1':
77     provisiontests_env.AppendUnique(LIBS = ['tinydtls'])
78     provisiontests_env.AppendUnique(LIBS = ['timer'])
79 if env.get('DTLS_WITH_X509') == '1':
80         provisiontests_env.AppendUnique(LIBS = ['CKManager'])
81         provisiontests_env.AppendUnique(LIBS = ['asn1'])
82
83
84 if env.get('LOGGING'):
85         provisiontests_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
86
87 ######################################################################
88 # Source files and Targets
89 ######################################################################
90 unittests = provisiontests_env.Program('provisiontests', ['OCProvisioningTest.cpp'])
91
92 Alias("provisiontests", [unittests])
93
94 env.AppendTarget('provisiontests')
95 if env.get('TEST') == '1':
96         target_os = env.get('TARGET_OS')
97         if target_os == 'linux':
98                 out_dir = env.get('BUILD_DIR')
99                 result_dir = env.get('BUILD_DIR') + '/test_out/'
100                 if not os.path.isdir(result_dir):
101                         os.makedirs(result_dir)
102                 provisiontests_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
103                 provisiontests_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
104                 provisiontests_env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
105                 ut = provisiontests_env.Command ('ut', None, out_dir + 'resource/provisioning/unittests/provisiontests')
106                 AlwaysBuild ('ut')
107
108 src_dir = provisiontests_env.get('SRC_DIR')
109 svr_db_src_dir = src_dir + '/resource/provisioning/examples/'
110 svr_db_build_dir = env.get('BUILD_DIR') +'/resource/provisioning/unittests/'
111 provisiontests_env.Alias("install", provisiontests_env.Install( svr_db_build_dir,
112                                 svr_db_src_dir + 'oic_svr_db_client.json'))