[Win32] Add SCons support for building /resource
[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 Import('env')
25 # Add third party libraries
26 lib_env = env.Clone()
27 SConscript(env.get('SRC_DIR') + '/resource/third_party_libs.scons', 'lib_env')
28
29 examples_env = lib_env.Clone()
30
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 target_os = env.get('TARGET_OS')
43 if target_os not in ['windows', 'winrt']:
44         examples_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
45
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'])
50
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'])
58
59 if target_os in ['msys_nt', 'windows']:
60         examples_env.PrependUnique(LIBS = ['mswsock', 'ws2_32', 'iphlpapi', 'ole32'])
61
62 if env.get('SECURED') == '1':
63     examples_env.AppendUnique(LIBS = ['tinydtls'])
64
65 if target_os == 'android':
66         examples_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
67         examples_env.AppendUnique(LIBS = ['gnustl_shared'])
68
69         if not env.get('RELEASE'):
70                 examples_env.AppendUnique(LIBS = ['log'])
71
72 if target_os in ['darwin', 'ios']:
73         examples_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
74
75 if env.get('LOGGING'):
76         examples_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
77 ######################################################################
78 # Source files and Targets
79 ######################################################################
80 simpleserver = examples_env.Program('simpleserver', 'simpleserver.cpp')
81 simpleclient = examples_env.Program('simpleclient', 'simpleclient.cpp')
82 simpleserverHQ = examples_env.Program('simpleserverHQ', 'simpleserverHQ.cpp')
83 simpleclientHQ = examples_env.Program('simpleclientHQ', 'simpleclientHQ.cpp')
84 fridgeserver = examples_env.Program('fridgeserver', 'fridgeserver.cpp')
85 fridgeclient = examples_env.Program('fridgeclient', 'fridgeclient.cpp')
86 presenceserver = examples_env.Program('presenceserver', 'presenceserver.cpp')
87 presenceclient = examples_env.Program('presenceclient', 'presenceclient.cpp')
88 simpleclientserver = examples_env.Program('simpleclientserver', 'simpleclientserver.cpp')
89 roomserver = examples_env.Program('roomserver', 'roomserver.cpp')
90 roomclient = examples_env.Program('roomclient', 'roomclient.cpp')
91 garageserver = examples_env.Program('garageserver', 'garageserver.cpp')
92 garageclient = examples_env.Program('garageclient', 'garageclient.cpp')
93 groupserver = examples_env.Program('groupserver', 'groupserver.cpp')
94 groupclient = examples_env.Program('groupclient', 'groupclient.cpp')
95 lightserver = examples_env.Program('lightserver', 'lightserver.cpp')
96 devicediscoveryserver = examples_env.Program('devicediscoveryserver', 'devicediscoveryserver.cpp')
97 devicediscoveryclient = examples_env.Program('devicediscoveryclient', 'devicediscoveryclient.cpp')
98 threadingsample = examples_env.Program('threadingsample', 'threadingsample.cpp')
99
100 clientjson = examples_env.Install(env.get('BUILD_DIR') + '/resource/examples/',
101                                 env.get('SRC_DIR') + '/resource/examples/' + 'oic_svr_db_client.json')
102 serverjson = examples_env.Install(env.get('BUILD_DIR') + '/resource/examples/',
103                                 env.get('SRC_DIR') + '/resource/examples/' + 'oic_svr_db_server.json')
104 Alias("examples", [simpleserver, simpleclient,
105                 simpleserverHQ, simpleclientHQ,
106                 fridgeserver, fridgeclient,
107                 presenceserver, presenceclient,
108                 simpleclientserver, roomserver, roomclient, garageserver,
109                 garageclient,
110                 groupserver, groupclient,
111                 lightserver,
112                 devicediscoveryserver, devicediscoveryclient,
113                 threadingsample,
114                 serverjson, clientjson
115      ])
116 env.AppendTarget('examples')