Imported Upstream version 1.2.0
[platform/upstream/iotivity.git] / resource / oc_logger / 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 # liboc_logger (share library) build script
23 ##
24
25 Import('env')
26
27 lib_env = env.Clone()
28 SConscript('#resource/third_party_libs.scons', 'lib_env')
29
30 liboc_logger_env = lib_env.Clone()
31 ######################################################################
32 # Build flags
33 ######################################################################
34 liboc_logger_env.PrependUnique(CPPPATH = ['include'])
35
36 target_os = env.get('TARGET_OS')
37 if target_os == 'android':
38         liboc_logger_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
39         liboc_logger_env.AppendUnique(LIBS = ['gnustl_shared', 'log'])
40         liboc_logger_env.AppendUnique(LINKFLAGS = ['-Wl,-soname,liboc_logger.so'])
41
42 if target_os not in ['arduino', 'windows']:
43         liboc_logger_env.AppendUnique(CFLAGS = ['-Wall', '-std=c99', '-fPIC'])
44         liboc_logger_env.AppendUnique(CXXFLAGS = ['-Wall', '-std=c++0x', '-fPIC'])
45
46 if target_os not in ['darwin', 'ios', 'windows', 'msys_nt']:
47         liboc_logger_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
48
49 ######################################################################
50 # Source files and Targets
51 ######################################################################
52
53 oc_logger_libs = []
54
55 if target_os in ['windows', 'msys_nt']:
56         # If oc_logger APIs have to be exported from a Windows DLL, these functions
57         # should be exported from octbstack.dll. Building a separate oc_logger.dll here
58         # would result in duplicated code and data across these two DLLs. Using just
59         # the static oc_logger.lib is good enough for Windows for now.
60         oc_logger_libs += liboc_logger_env.StaticLibrary('oc_logger',
61                 ['c/oc_logger.c', 'c/oc_console_logger.c', 'cpp/oc_ostream_logger.cpp'])
62 else:
63         oc_logger_libs += Flatten(liboc_logger_env.SharedLibrary('oc_logger_core',
64                 ['c/oc_logger.c'],  OBJPREFIX='core_'))
65         oc_logger_libs += Flatten(liboc_logger_env.SharedLibrary('oc_logger',
66                 ['c/oc_logger.c', 'c/oc_console_logger.c', 'cpp/oc_ostream_logger.cpp']))
67
68 liboc_logger_env.InstallTarget(oc_logger_libs, 'oc_logger')
69 liboc_logger_env.UserInstallTargetLib(oc_logger_libs, 'oc_logger')
70 liboc_logger_env.UserInstallTargetHeader('include/oc_logger.hpp', 'resource', 'oc_logger.hpp')
71 liboc_logger_env.UserInstallTargetHeader('include/oc_logger.h', 'resource', 'oc_logger.h')
72 liboc_logger_env.UserInstallTargetHeader('include/oc_logger_types.h', 'resource', 'oc_logger_types.h')
73 liboc_logger_env.UserInstallTargetHeader('include/oc_log_stream.hpp', 'resource', 'oc_log_stream.hpp')
74 liboc_logger_env.UserInstallTargetHeader('include/targets/oc_console_logger.h', 'resource/targets', 'oc_console_logger.h')
75 liboc_logger_env.UserInstallTargetHeader('include/targets/oc_ostream_logger.h', 'resource/targets', 'oc_ostream_logger.h')
76
77 if target_os not in ['ios', 'android']:
78         SConscript('examples/SConscript')
79