1 #******************************************************************
3 # Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 # http://www.apache.org/licenses/LICENSE-2.0
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.
19 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
22 # Examples build script
25 # Add third party libraries
27 SConscript(env.get('SRC_DIR') + '/resource/third_party_libs.scons', 'lib_env')
29 examples_env = lib_env.Clone()
31 ######################################################################
33 ######################################################################
34 examples_env.AppendUnique(CPPPATH = [
36 '../csdk/stack/include',
37 '../c_common/ocrandom/include',
38 '../csdk/logger/include',
39 '../oc_logger/include'
42 target_os = env.get('TARGET_OS')
43 if target_os not in ['windows', 'winrt']:
44 examples_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
46 # Note: 'pthread' is in libc for android. On other platform, if use
47 # new gcc(>4.9?) it isn't required, otherwise, it's required
48 if target_os != 'android':
49 examples_env.AppendUnique(LIBS = ['-lpthread'])
51 examples_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
52 examples_env.AppendUnique(RPATH = [env.get('BUILD_DIR')])
53 examples_env.PrependUnique(LIBS = ['coap'])
54 examples_env.AppendUnique(LIBS = ['connectivity_abstraction'])
55 examples_env.AppendUnique(LIBS = ['oc_logger'])
56 examples_env.AppendUnique(LIBS = ['octbstack'])
57 examples_env.AppendUnique(LIBS = ['oc'])
59 if target_os in ['msys_nt', 'windows']:
60 examples_env.PrependUnique(LIBS = ['mswsock', 'ws2_32', 'iphlpapi', 'ole32'])
62 if env.get('SECURED') == '1':
63 examples_env.AppendUnique(LIBS = ['tinydtls'])
64 examples_env.AppendUnique(CPPDEFINES = ['_WITH_DTLS_'])
65 if target_os in ['msys_nt', 'windows']:
66 examples_env.AppendUnique(LIBS = ['advapi32'])
68 if target_os == 'android':
69 examples_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
70 examples_env.AppendUnique(LIBS = ['gnustl_shared'])
72 if not env.get('RELEASE'):
73 examples_env.AppendUnique(LIBS = ['log'])
75 if target_os in ['darwin', 'ios']:
76 examples_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
78 if env.get('LOGGING'):
79 examples_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
81 if target_os in ['msys_nt', 'windows']:
82 examples_env.AppendUnique(LIBS = ['Comctl32', 'Gdi32', 'User32'])
84 if env.get('LOGGING'):
85 examples_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
87 def make_single_file_cpp_program(program_name):
88 return examples_env.Program(program_name, program_name + ".cpp")
90 ######################################################################
91 # Source files and Targets
92 ######################################################################
94 'simpleserver', 'simpleclient',
96 'devicediscoveryserver', 'devicediscoveryclient'
99 if target_os not in ['windows', 'msys_nt']:
101 'simpleserverHQ', 'simpleclientHQ',
102 'fridgeserver', 'fridgeclient',
103 'presenceserver', 'presenceclient',
104 'roomserver', 'roomclient',
113 examples = map(make_single_file_cpp_program, example_names)
115 ######################################################################
117 ######################################################################
118 clientjson = examples_env.Install(env.get('BUILD_DIR') + '/resource/examples/',
119 env.get('SRC_DIR') + '/resource/examples/' + 'oic_svr_db_client.dat')
120 serverjson = examples_env.Install(env.get('BUILD_DIR') + '/resource/examples/',
121 env.get('SRC_DIR') + '/resource/examples/' + 'oic_svr_db_server.dat')
123 examples += [clientjson, serverjson]
125 if target_os in ['msys_nt', 'windows']:
126 winUIClient = examples_env.Program('winUIClient', ['winuiclientgui.cpp', 'winuiclient.cpp'])
127 mediaserver = examples_env.Program('mediaserver', 'mediaserver.cpp')
128 examples += [winUIClient, mediaserver]
130 Alias("examples", examples)
131 env.AppendTarget('examples')