Add C++ Cloud provisioning
[platform/upstream/iotivity.git] / resource / provisioning / examples / 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 # Examples build script
23 ##
24 thread_env = SConscript('#build_common/thread.scons')
25 lib_env = thread_env.Clone()
26 target_os = lib_env.get('TARGET_OS')
27
28 # Add third party libraries
29 SConscript('#resource/third_party_libs.scons', 'lib_env')
30
31 with_ra = lib_env.get('WITH_RA')
32 with_ra_ibb = lib_env.get('WITH_RA_IBB')
33
34 examples_env = lib_env.Clone()
35
36 ######################################################################
37 # Build flags
38 ######################################################################
39 examples_env.AppendUnique(CPPPATH = [
40         '../../include/',
41         '../../../extlibs/cjson',
42         '../../csdk/stack/include',
43         '../../csdk/logger/include',
44         '../../oc_logger/include',
45         '../../csdk/connectivity/api',
46         '../../csdk/connectivity/inc/pkix',
47         '../../csdk/connectivity/common/inc',
48         '../../csdk/connectivity/lib/libcoap-4.1.1',
49         '../../csdk/security/include',
50         '../../csdk/security/include/internal',
51         '../../csdk/security/provisioning/include',
52         '../../csdk/security/provisioning/include/oxm',
53         '../../csdk/security/provisioning/include/cloud',
54         '../../csdk/security/provisioning/include/internal'
55                 ])
56
57 examples_env.AppendUnique(LIBPATH = [examples_env.get('BUILD_DIR')])
58 examples_env.AppendUnique(RPATH = [examples_env.get('BUILD_DIR')])
59 examples_env.PrependUnique(LIBS = ['ocprovision', 'oc', 'ocpmapi', 'octbstack',
60                                     'oc_logger', 'connectivity_abstraction', 'coap'])
61 if with_ra_ibb:
62         examples_env.AppendUnique(LIBS = examples_env['RALIBS'], LIBPATH = examples_env['RALIBPATH'], RPATH = examples_env['RARPATH'])
63         print "RALIBS = %s" % examples_env['RALIBS']
64         print "RALIBPATH = %s" % examples_env['RALIBPATH']
65         print "RARPATH = %s" % examples_env['RARPATH']
66         examples_env.AppendUnique(LIBS = 'wksxmppxep')
67 else :
68         if with_ra:
69                 examples_env.AppendUnique(LIBS = ['ra_xmpp'])
70
71 if examples_env.get('SECURED') == '1':
72     examples_env.AppendUnique(LIBS = ['tinydtls'])
73     examples_env.AppendUnique(LIBS = ['timer'])
74 if examples_env.get('DTLS_WITH_X509') == '1':
75         examples_env.AppendUnique(LIBS = ['CKManager'])
76         examples_env.AppendUnique(LIBS = ['asn1'])
77
78 if 'g++' in examples_env.get('CXX'):
79    examples_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
80
81 if target_os in ['android']:
82         examples_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
83         examples_env.AppendUnique(LIBS = ['gnustl_shared'])
84
85         if not examples_env.get('RELEASE'):
86                 examples_env.AppendUnique(LIBS = ['log'])
87
88 if target_os in ['darwin', 'ios']:
89         examples_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
90
91 if target_os == 'tizen':
92     examples_env.AppendUnique(CPPDEFINES = ['__TIZEN__'])
93
94
95 ######################################################################
96 # Source files and Targets
97 ######################################################################
98 provisioningclient = examples_env.Program('provisioningclient', 'provisioningclient.cpp')
99
100 if examples_env.get('WITH_TCP') == True:
101     cloudClient = examples_env.Program('cloudClient',['cloudClient.cpp', 'cloudAuth.cpp', 'cloudWrapper.cpp'])
102
103 src_dir = examples_env.get('SRC_DIR')
104 svr_db_src_dir = src_dir + '/resource/provisioning/examples/'
105 svr_db_build_dir = examples_env.get('BUILD_DIR') +'/resource/provisioning/examples/'
106
107 clientjson = examples_env.Install(svr_db_build_dir, svr_db_src_dir + 'oic_svr_db_client.json')
108 clientdat = examples_env.Install(svr_db_build_dir, svr_db_src_dir + 'oic_svr_db_client.dat')
109
110 if examples_env.get('WITH_TCP') == True:
111     clouddat = examples_env.Install(svr_db_build_dir,
112                 svr_db_src_dir + 'cloud.dat')
113     rootcert = examples_env.Install(svr_db_build_dir,
114                 svr_db_src_dir + 'rootca.crt')
115     Alias("cloud", [clouddat, rootcert, cloudClient])
116     examples_env.AppendTarget("cloud")
117
118 Alias("examples", [provisioningclient, clientjson,clientdat])
119 examples_env.AppendTarget('examples')