Imported Upstream version 1.2.0
[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 = ['mbedtls', 'mbedx509','mbedcrypto'])
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('WITH_CLOUD'):
74         examples_env.AppendUnique(CPPDEFINES = ['WITH_CLOUD'])
75
76 if target_os in ['msys_nt', 'windows']:
77         examples_env.AppendUnique(LIBS = ['Comctl32', 'Gdi32', 'User32'])
78
79 if examples_env.get('LOGGING'):
80         examples_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
81
82 def make_single_file_cpp_program(program_name):
83         return examples_env.Program(program_name, program_name + ".cpp")
84
85 ######################################################################
86 # Source files and Targets
87 ######################################################################
88 example_names = [
89         'simpleserver', 'simpleclient',
90         'simpleclientserver',
91         'directpairingclient',
92         'devicediscoveryserver', 'devicediscoveryclient',
93         'simpleserverHQ', 'simpleclientHQ',
94         ]
95
96 if target_os not in ['windows', 'msys_nt']:
97         example_names += [
98                 'fridgeserver', 'fridgeclient',
99                 'presenceserver', 'presenceclient',
100                 'roomserver', 'roomclient',
101                 'garageserver',
102                 'garageclient',
103                 'groupserver',
104                 'groupclient',
105                 'lightserver',
106                 'threadingsample'
107                 ]
108
109 examples = map(make_single_file_cpp_program, example_names)
110
111 ######################################################################
112 # Other examples
113 ######################################################################
114 clientjson = examples_env.Install(examples_env.get('BUILD_DIR') + '/resource/examples/',
115                                 examples_env.get('SRC_DIR') + '/resource/examples/' + 'oic_svr_db_client.dat')
116 serverjson = examples_env.Install(examples_env.get('BUILD_DIR') + '/resource/examples/',
117                                 examples_env.get('SRC_DIR') + '/resource/examples/' + 'oic_svr_db_server.dat')
118 directpairingdat = examples_env.Install(examples_env.get('BUILD_DIR') + '/resource/examples/',
119                                 examples_env.get('SRC_DIR') + '/resource/examples/' + 'oic_svr_db_client_directpairing.dat')
120
121 examples += [clientjson, serverjson, directpairingdat]
122
123 if target_os in ['msys_nt', 'windows']:
124         winUIClient = examples_env.Program('winUIClient', ['winuiclientgui.cpp', 'winuiclient.cpp'])
125         mediaserver = examples_env.Program('mediaserver', 'mediaserver.cpp')
126         examples += [winUIClient, mediaserver]
127
128 Alias("examples", examples)
129 examples_env.AppendTarget('examples')