replace : iotivity -> iotivity-sec
[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                 'presenceserver', 'presenceclient',
106                 'roomserver', 'roomclient',
107                 'garageserver',
108                 'garageclient',
109                 'groupserver',
110                 'groupclient',
111                 'lightserver',
112                 'threadingsample',
113                 ]
114         if 'CLIENT' in examples_env.get('RD_MODE'):
115                 examples_env.AppendUnique(CPPPATH = ['../csdk/resource-directory/include'])
116                 example_names += ['rdclient']
117                 examples_env.AppendUnique(LIBS = ['resource_directory'])
118
119 examples = map(make_single_file_cpp_program, example_names)
120
121 ######################################################################
122 # Other examples
123 ######################################################################
124 clientjson = examples_env.Install(examples_env.get('BUILD_DIR') + '/resource/examples/',
125                                 examples_env.get('SRC_DIR') + '/resource/examples/' + 'oic_svr_db_client.dat')
126 serverjson = examples_env.Install(examples_env.get('BUILD_DIR') + '/resource/examples/',
127                                 examples_env.get('SRC_DIR') + '/resource/examples/' + 'oic_svr_db_server.dat')
128 directpairingdat = examples_env.Install(examples_env.get('BUILD_DIR') + '/resource/examples/',
129                                 examples_env.get('SRC_DIR') + '/resource/examples/' + 'oic_svr_db_client_directpairing.dat')
130
131 examples += [clientjson, serverjson, directpairingdat]
132
133 if target_os in ['msys_nt', 'windows']:
134         winUIClient = examples_env.Program('winUIClient', ['winuiclientgui.cpp', 'winuiclient.cpp'])
135         mediaserver = examples_env.Program('mediaserver', 'mediaserver.cpp')
136         examples += [winUIClient, mediaserver]
137
138 Alias("examples", examples)
139 examples_env.AppendTarget('examples')