[CONPRO-1337] Disabled Presence Feature
[platform/upstream/iotivity.git] / resource / examples / SConscript
1 #******************************************************************
2 #
3 # Copyright 2014 Intel Mobile Communications GmbH 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
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')
33
34 ######################################################################
35 # Build flags
36 ######################################################################
37 examples_env.AppendUnique(CPPPATH = [
38                 '../include/',
39                 '../csdk/stack/include',
40                 '../c_common/ocrandom/include',
41                 '../csdk/logger/include',
42                 '../oc_logger/include'
43                 ])
44
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'])
52
53 compiler = examples_env.get('CXX')
54 if 'g++' in compiler:
55         examples_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
56
57 if target_os in ['msys_nt', 'windows']:
58         examples_env.PrependUnique(LIBS = ['mswsock', 'ws2_32', 'iphlpapi', 'ole32'])
59
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'])
65
66 if target_os == 'android':
67         examples_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
68         examples_env.AppendUnique(LIBS = ['gnustl_shared'])
69
70         if not examples_env.get('RELEASE'):
71                 examples_env.AppendUnique(LIBS = ['log'])
72
73 if target_os in ['darwin', 'ios']:
74         examples_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
75
76 if examples_env.get('WITH_CLOUD'):
77         examples_env.AppendUnique(CPPDEFINES = ['WITH_CLOUD'])
78
79 if ble_custom_adv == True:
80                 env.AppendUnique(CPPDEFINES = ['BLE_CUSTOM_ADVERTISE'])
81
82 if target_os in ['msys_nt', 'windows']:
83         examples_env.AppendUnique(LIBS = ['Comctl32', 'Gdi32', 'User32'])
84
85 if examples_env.get('LOGGING'):
86         examples_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
87
88 def make_single_file_cpp_program(program_name):
89         return examples_env.Program(program_name, program_name + ".cpp")
90
91 ######################################################################
92 # Source files and Targets
93 ######################################################################
94 example_names = [
95         'simpleserver', 'simpleclient',
96         'simpleclientserver',
97         'directpairingclient',
98         'devicediscoveryserver', 'devicediscoveryclient',
99         'simpleserverHQ', 'simpleclientHQ',
100         ]
101
102 if target_os not in ['windows', 'msys_nt']:
103         example_names += [
104                 'fridgeserver', 'fridgeclient',
105                 'roomserver', 'roomclient',
106                 'garageserver',
107                 'garageclient',
108                 'groupserver',
109                 'groupclient',
110                 'lightserver',
111                 'threadingsample',
112                 ]
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']
119
120 examples = map(make_single_file_cpp_program, example_names)
121
122 ######################################################################
123 # Other examples
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')
131
132 examples += [clientjson, serverjson, directpairingdat]
133
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]
138
139 Alias("examples", examples)
140 examples_env.AppendTarget('examples')