Fix build error with scons-4.4.0 version which is based on python3
[platform/upstream/iotivity.git] / plugins / src / SConscript
1 #******************************************************************
2 #
3 # Copyright 2015 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 # Plugin Interface build script
22 ##
23
24 import os.path
25
26 Import('env')
27
28 target_os = env.get('TARGET_OS')
29 src_dir = env.get('SRC_DIR')
30 pi_path = os.path.join(src_dir, 'plugins')
31
32 print("Reading PI script")
33
34 ######################################################################
35 # Build flags
36 ######################################################################
37 with_unforked_libcoap = env.get('WITH_UNFORKED_LIBCOAP')
38 if with_unforked_libcoap == '1':
39     # For bring up purposes only, we manually copy the forked version to where the unforked version is downloaded.
40     env.PrependUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
41 else:
42     # For bring up purposes only, the forked version will live here.
43     env.PrependUnique(CPPPATH = [os.path.join(src_dir, 'resource', 'csdk', 'connectivity', 'lib', 'libcoap-4.1.1', 'include')])
44
45 env.PrependUnique(CPPPATH = [ os.path.join(src_dir, 'resource', 'c_common', 'oic_malloc', 'include'),
46                               os.path.join(src_dir, 'resource', 'c_common', 'oic_string', 'include'),
47                               os.path.join(src_dir, 'resource', 'c_common', 'oic_time', 'include'),
48                               os.path.join(src_dir, 'resource', 'oc_logger', 'include'),
49                               os.path.join(src_dir, 'resource', 'csdk', 'logger', 'include'),
50                               os.path.join(src_dir, 'resource', 'csdk', 'stack', 'include')
51                             ])
52 env.AppendUnique(CPPPATH = [ os.path.join(pi_path, 'include'),
53                              os.path.join(pi_path, 'include', 'internal'),
54                              os.path.join(pi_path, 'zigbee_wrapper', 'include'),
55                              os.path.join(pi_path, 'include', 'internal')
56                            ])
57
58 if target_os not in ['arduino', 'windows']:
59         env.AppendUnique(CPPDEFINES = ['WITH_POSIX'])
60
61 if target_os in ['darwin','ios']:
62         env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
63
64 env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-Wextra', '-Werror'])
65 env.AppendUnique(RPATH = [env.get('BUILD_DIR')])
66 env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
67
68 env.PrependUnique(LIBS = ['zigbee_wrapper'])
69
70 if env.get('LOGGING'):
71         env.AppendUnique(CPPDEFINES = ['TB_LOG'])
72
73 #####################################################################
74 # Source files and Target(s)
75 ######################################################################
76 pi_src = [
77          os.path.join(src_dir, 'resource', 'csdk', 'logger', 'src', 'logger.c'),
78          'pluginlist.c',
79          'plugininterface.c',
80              ]
81
82 env.AppendUnique(PI_SRC = pi_src)
83
84 print("Include path is %s" % env.get('CPPPATH'))
85 print("Files path is %s" % env.get('PI_SRC'))
86 if target_os in ['android', 'tizen']:
87         calib = env.SharedLibrary('plugin_interface', env.get('PI_SRC'))
88 else:
89         calib = env.StaticLibrary('plugin_interface', env.get('PI_SRC'))
90 env.InstallTarget(calib, 'plugin_interface')
91 env.UserInstallTargetLib(calib, 'plugin_interface')
92