1 #******************************************************************
3 # Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 # http://www.apache.org/licenses/LICENSE-2.0
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.
19 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
22 # Examples build script
24 thread_env = SConscript('#build_common/thread.scons')
25 lib_env = thread_env.Clone()
27 # Add third party libraries
28 SConscript('#resource/third_party_libs.scons', 'lib_env')
29 examples_env = lib_env.Clone()
30 target_os = examples_env.get('TARGET_OS')
31 rd_mode = examples_env.get('RD_MODE')
32 ble_custom_adv = examples_env.get('BLE_CUSTOM_ADV')
34 ######################################################################
36 ######################################################################
37 examples_env.AppendUnique(CPPPATH = [
39 '../csdk/stack/include',
40 '../c_common/ocrandom/include',
41 '../csdk/logger/include',
42 '../oc_logger/include'
45 examples_env.AppendUnique(LIBPATH = [examples_env.get('BUILD_DIR')])
46 examples_env.AppendUnique(RPATH = [examples_env.get('BUILD_DIR')])
47 examples_env.PrependUnique(LIBS = ['coap'])
48 examples_env.AppendUnique(LIBS = ['connectivity_abstraction'])
49 examples_env.AppendUnique(LIBS = ['oc_logger'])
50 examples_env.AppendUnique(LIBS = ['octbstack'])
51 examples_env.AppendUnique(LIBS = ['oc'])
53 compiler = examples_env.get('CXX')
55 examples_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
57 if target_os in ['msys_nt', 'windows']:
58 examples_env.PrependUnique(LIBS = ['mswsock', 'ws2_32', 'iphlpapi', 'ole32'])
60 if examples_env.get('SECURED') == '1':
61 examples_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509','mbedcrypto'])
62 examples_env.AppendUnique(CPPDEFINES = ['_WITH_DTLS_'])
63 if target_os in ['msys_nt', 'windows']:
64 examples_env.AppendUnique(LIBS = ['advapi32'])
66 if target_os == 'android':
67 examples_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
68 examples_env.AppendUnique(LIBS = ['gnustl_shared'])
70 if not examples_env.get('RELEASE'):
71 examples_env.AppendUnique(LIBS = ['log'])
73 if target_os in ['darwin', 'ios']:
74 examples_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
76 if examples_env.get('WITH_CLOUD'):
77 examples_env.AppendUnique(CPPDEFINES = ['WITH_CLOUD'])
79 if ble_custom_adv == True:
80 env.AppendUnique(CPPDEFINES = ['BLE_CUSTOM_ADVERTISE'])
82 if target_os in ['msys_nt', 'windows']:
83 examples_env.AppendUnique(LIBS = ['Comctl32', 'Gdi32', 'User32'])
85 if examples_env.get('LOGGING'):
86 examples_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
88 def make_single_file_cpp_program(program_name):
89 return examples_env.Program(program_name, program_name + ".cpp")
91 ######################################################################
92 # Source files and Targets
93 ######################################################################
95 'simpleserver', 'simpleclient',
97 'directpairingclient',
98 'devicediscoveryserver', 'devicediscoveryclient',
99 'simpleserverHQ', 'simpleclientHQ',
102 if target_os not in ['windows', 'msys_nt']:
104 'fridgeserver', 'fridgeclient',
105 'roomserver', 'roomclient',
113 if 'CLIENT' in examples_env.get('RD_MODE'):
114 examples_env.AppendUnique(CPPPATH = ['../csdk/resource-directory/include'])
115 example_names += ['rdclient']
116 examples_env.AppendUnique(LIBS = ['resource_directory'])
117 if examples_env.get('DISABLE_PRESENCE') == False:
118 example_names += ['presenceserver', 'presenceclient']
120 examples = map(make_single_file_cpp_program, example_names)
122 ######################################################################
124 ######################################################################
125 clientjson = examples_env.Install(examples_env.get('BUILD_DIR') + '/resource/examples/',
126 examples_env.get('SRC_DIR') + '/resource/examples/' + 'oic_svr_db_client.dat')
127 serverjson = examples_env.Install(examples_env.get('BUILD_DIR') + '/resource/examples/',
128 examples_env.get('SRC_DIR') + '/resource/examples/' + 'oic_svr_db_server.dat')
129 directpairingdat = examples_env.Install(examples_env.get('BUILD_DIR') + '/resource/examples/',
130 examples_env.get('SRC_DIR') + '/resource/examples/' + 'oic_svr_db_client_directpairing.dat')
132 examples += [clientjson, serverjson, directpairingdat]
134 if target_os in ['msys_nt', 'windows']:
135 winUIClient = examples_env.Program('winUIClient', ['winuiclientgui.cpp', 'winuiclient.cpp'])
136 mediaserver = examples_env.Program('mediaserver', 'mediaserver.cpp')
137 examples += [winUIClient, mediaserver]
139 Alias("examples", examples)
140 examples_env.AppendTarget('examples')