RD client features in base layer
[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 ######################################################################
32 # Build flags
33 ######################################################################
34 examples_env.AppendUnique(CPPPATH = [
35                 '../include/',
36                 '../csdk/stack/include',
37                 '../c_common/ocrandom/include',
38                 '../csdk/logger/include',
39                 '../oc_logger/include'
40                 ])
41
42 examples_env.AppendUnique(LIBPATH = [examples_env.get('BUILD_DIR')])
43 examples_env.AppendUnique(RPATH = [examples_env.get('BUILD_DIR')])
44 examples_env.PrependUnique(LIBS = ['coap'])
45 examples_env.AppendUnique(LIBS = ['connectivity_abstraction'])
46 examples_env.AppendUnique(LIBS = ['oc_logger'])
47 examples_env.AppendUnique(LIBS = ['octbstack'])
48 examples_env.AppendUnique(LIBS = ['oc'])
49
50 compiler = examples_env.get('CXX')
51 if 'g++' in compiler:
52         examples_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
53
54 if target_os in ['msys_nt', 'windows']:
55         examples_env.PrependUnique(LIBS = ['mswsock', 'ws2_32', 'iphlpapi', 'ole32'])
56
57 if examples_env.get('SECURED') == '1':
58         examples_env.AppendUnique(LIBS = ['tinydtls'])
59         examples_env.AppendUnique(CPPDEFINES = ['_WITH_DTLS_'])
60         if target_os in ['msys_nt', 'windows']:
61                 examples_env.AppendUnique(LIBS = ['advapi32'])
62
63 if target_os == 'android':
64         examples_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
65         examples_env.AppendUnique(LIBS = ['gnustl_shared'])
66
67         if not examples_env.get('RELEASE'):
68                 examples_env.AppendUnique(LIBS = ['log'])
69
70 if target_os in ['darwin', 'ios']:
71         examples_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
72
73 if examples_env.get('LOGGING'):
74         examples_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
75
76 if examples_env.get('WITH_CLOUD'):
77         examples_env.AppendUnique(CPPDEFINES = ['WITH_CLOUD'])
78
79 if target_os in ['msys_nt', 'windows']:
80         examples_env.AppendUnique(LIBS = ['Comctl32', 'Gdi32', 'User32'])
81
82 if examples_env.get('LOGGING'):
83         examples_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
84
85 if 'CLIENT' in examples_env.get('RD_MODE'):
86         examples_env.AppendUnique(CPPDEFINES = ['RD_CLIENT'])
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         ]
100
101 if target_os not in ['windows', 'msys_nt']:
102         example_names += [
103                 'simpleserverHQ', 'simpleclientHQ',
104                 'fridgeserver', 'fridgeclient',
105                 'presenceserver', 'presenceclient',
106                 'roomserver', 'roomclient',
107                 'garageserver',
108                 'garageclient',
109                 'groupserver',
110                 'groupclient',
111                 'lightserver',
112                 'threadingsample'
113                 ]
114
115 if 'CLIENT' in examples_env.get('RD_MODE'):
116         example_names += [
117                 'rdclient'
118                 ]
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')