1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
##
# liboctbstack (share library) build script
##
Import('env')
lib_env = env.Clone()
SConscript(env.get('SRC_DIR') + '/resource/third_party_libs.scons', 'lib_env')
liboctbstack_env = lib_env.Clone()
target_os = env.get('TARGET_OS')
# As in the source code, it includes arduino Time library (C++)
# It requires compile the .c with g++
if target_os == 'arduino':
liboctbstack_env.Replace(CC = env.get('CXX'))
liboctbstack_env.Replace(CFLAGS = env.get('CXXFLAGS'))
######################################################################
# Build flags
######################################################################
liboctbstack_env.PrependUnique(CPPPATH = [
'../../extlibs/cjson/',
'logger/include',
'ocrandom/include',
'ocmalloc/include',
'stack/include',
'stack/include/internal',
'../oc_logger/include',
'connectivity/lib/libcoap-4.1.1',
'connectivity/inc',
'connectivity/api',
'security/include',
'security/include/internal',
])
if target_os not in ['arduino', 'windows', 'winrt']:
liboctbstack_env.AppendUnique(CPPDEFINES = ['WITH_POSIX'])
liboctbstack_env.AppendUnique(CFLAGS = ['-std=c99'])
if target_os not in ['windows', 'winrt']:
liboctbstack_env.AppendUnique(CFLAGS = ['-Wall'])
liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
liboctbstack_env.AppendUnique(LIBS = ['coap', 'm'])
if target_os == 'arduino':
liboctbstack_env.AppendUnique(CPPDEFINES = ['NDEBUG', 'WITH_ARDUINO'])
else:
liboctbstack_env.AppendUnique(CFLAGS = ['-fPIC'])
if target_os in ['darwin', 'ios']:
liboctbstack_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
liboctbstack_env.AppendUnique(LIBS = ['coap'])
if not env.get('RELEASE'):
liboctbstack_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
######################################################################
# Source files and Targets
######################################################################
OCTBSTACK_SRC = 'stack/src/'
liboctbstack_src = [
'../../extlibs/cjson/cJSON.c',
OCTBSTACK_SRC + 'ocstack.c',
OCTBSTACK_SRC + 'occlientcb.c',
OCTBSTACK_SRC + 'ocresource.c',
OCTBSTACK_SRC + 'ocobserve.c',
OCTBSTACK_SRC + 'ocserverrequest.c',
OCTBSTACK_SRC + 'occollection.c',
OCTBSTACK_SRC + 'oicgroup.c',
'security/src/ocsecurity.c',
'logger/src/logger.c',
'ocrandom/src/ocrandom.c',
'ocmalloc/src/ocmalloc.c'
]
if target_os == 'arduino':
liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
else:
liboctbstack = liboctbstack_env.SharedLibrary('octbstack', liboctbstack_src)
liboctbstack_env.InstallTarget(liboctbstack, 'liboctbstack')
|