0cfb61c03dc7adc48678e457c4f1aa834025d499
[contrib/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 Import('env')
22
23 ##
24 # Examples build script
25 ##
26 lib_env = env.Clone()
27 SConscript('#build_common/thread.scons', exports = {'thread_env' : lib_env})
28
29 # Add third party libraries
30 SConscript('#resource/third_party_libs.scons', 'lib_env')
31 examples_env = lib_env.Clone()
32 target_os = examples_env.get('TARGET_OS')
33
34 ######################################################################
35 # Build flags
36 ######################################################################
37 examples_env.AppendUnique(CPPPATH = [
38         '#/resource/csdk/security/include',
39         '#/resource/include/',
40         '#/resource/csdk/include',
41         '#/resource/csdk/stack/include',
42         '#/resource/c_common/ocrandom/include',
43         '#/resource/csdk/logger/include',
44         '#/resource/oc_logger/include'
45         ])
46
47 examples_env.AppendUnique(RPATH = [examples_env.get('BUILD_DIR')])
48 examples_env.PrependUnique(LIBS = ['coap'])
49 examples_env.AppendUnique(LIBS = ['connectivity_abstraction'])
50 examples_env.AppendUnique(LIBS = ['oc_logger'])
51 examples_env.AppendUnique(LIBS = ['octbstack'])
52 examples_env.AppendUnique(LIBS = ['oc'])
53
54 compiler = examples_env.get('CXX')
55 if 'g++' in compiler:
56     examples_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
57
58 if target_os in ['msys_nt', 'windows']:
59     examples_env.PrependUnique(LIBS = ['mswsock', 'ws2_32', 'iphlpapi', 'ole32'])
60
61 if examples_env.get('SECURED') == '1':
62     examples_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509','mbedcrypto'])
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 ['msys_nt', 'windows']:
74     examples_env.AppendUnique(LIBS = ['Comctl32', 'Gdi32', 'User32'])
75
76 def make_single_file_cpp_program(program_name):
77     return examples_env.Program(program_name, program_name + ".cpp")
78
79 ######################################################################
80 # Source files and Targets
81 ######################################################################
82 example_names = [
83     'simpleserver', 'simpleclient',
84     'simpleclientserver',
85     'directpairingclient',
86     'devicediscoveryserver', 'devicediscoveryclient',
87     'simpleserverHQ', 'simpleclientHQ',
88     ]
89
90 if target_os not in ['windows', 'msys_nt']:
91     example_names += [
92         'fridgeserver', 'fridgeclient',
93         'presenceserver', 'presenceclient',
94         'roomserver', 'roomclient',
95         'garageserver',
96         'garageclient',
97         'groupserver',
98         'groupclient',
99         'lightserver',
100         'threadingsample',
101         ]
102     if 'CLIENT' in examples_env.get('RD_MODE'):
103         examples_env.AppendUnique(CPPPATH = ['../csdk/resource-directory/include'])
104         examples_env.AppendUnique(LIBS = ['resource_directory'])
105         example_names += ['rdclient']
106
107 examples = map(make_single_file_cpp_program, example_names)
108
109 ######################################################################
110 # Other examples
111 ######################################################################
112 clientjson = examples_env.Install(examples_env.get('BUILD_DIR') + '/resource/examples/',
113                 examples_env.get('SRC_DIR') + '/resource/examples/' + 'oic_svr_db_client.dat')
114 serverjson = examples_env.Install(examples_env.get('BUILD_DIR') + '/resource/examples/',
115                 examples_env.get('SRC_DIR') + '/resource/examples/' + 'oic_svr_db_server.dat')
116 light_introspection_json = examples_env.Install(examples_env.get('BUILD_DIR') + '/resource/examples/',
117                 examples_env.get('SRC_DIR') + '/resource/examples/' + 'light_introspection.json')
118
119 directpairingdat = examples_env.Install(examples_env.get('BUILD_DIR') + '/resource/examples/',
120                 examples_env.get('SRC_DIR') + '/resource/examples/' + 'oic_svr_db_client_directpairing.dat')
121
122 examples += [clientjson, serverjson, directpairingdat]
123
124 if target_os in ['msys_nt', 'windows']:
125     winUIClient = examples_env.Program('winUIClient', ['winuiclientgui.cpp', 'winuiclient.cpp'])
126     mediaserver = examples_env.Program('mediaserver', 'mediaserver.cpp')
127     examples += [winUIClient, mediaserver]
128
129 Alias("examples", examples)
130 examples_env.AppendTarget('examples')