forked from intel/dps-for-iot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConscript
executable file
·220 lines (186 loc) · 6.68 KB
/
SConscript
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
import os
import string
Import(['env', 'ext_libs'])
platform = env['PLATFORM']
env['UV_LIBS'].append(ext_libs)
# Additional warning for the lib object files
# Core libraries
libenv = env.Clone()
# Additional warnings for the core object files
if platform == 'win32':
libenv.Append(LIBS = env['UV_LIBS'])
elif platform == 'posix':
libenv.Append(CCFLAGS = ['-Wall', '-Wno-format-extra-args'])
libenv.Install('#/build/dist/inc/dps', libenv.Glob('#/inc/dps/*.h'))
libenv.Install('#/build/dist/inc/dps/private', libenv.Glob('#/inc/dps/private/*.h'))
srcs = ['src/bitvec.c',
'src/cbor.c',
'src/cose.c',
'src/coap.c',
'src/dps.c',
'src/pub.c',
'src/sub.c',
'src/ack.c',
'src/dbg.c',
'src/err.c',
'src/event.c',
'src/history.c',
'src/keystore.c',
'src/synchronous.c',
'src/uuid.c',
'src/linkmon.c',
'src/netmcast.c',
'src/network.c',
'src/registration.c',
'src/resolver.c',
'src/topics.c',
'src/uv_extra.c',
'src/sha2.c',
'src/gcm.c',
'src/ec.c',
'src/hkdf.c',
'src/keywrap.c',
'src/mbedtls.c']
if env['transport'] == 'udp':
srcs.append('src/udp/network.c')
elif env['transport'] == 'dtls':
srcs.append('src/dtls/network.c')
else:
srcs.append('src/tcp/network.c')
Depends(srcs, ext_libs)
objs = libenv.Object(srcs)
lib = libenv.Library('lib/dps', objs)
libenv.Install('#/build/dist/lib', lib)
shobjs = libenv.SharedObject(srcs)
if platform == 'win32':
shlib = libenv.SharedLibrary('lib/dps_shared', shobjs + ['dps_shared.def'])
else:
shlib = libenv.SharedLibrary('lib/dps_shared', shobjs)
libenv.Install('#/build/dist/lib', shlib)
ns3srcs = ['src/bitvec.c',
'src/cbor.c',
'src/gcm.c',
'src/coap.c',
'src/cose.c',
'src/dps.c',
'src/pub.c',
'src/sha2.c',
'src/sub.c',
'src/ack.c',
'src/err.c',
'src/history.c',
'src/uuid.c',
'src/topics.c']
if platform == 'posix':
ns3shobjs = libenv.SharedObject(ns3srcs)
ns3shlib = libenv.SharedLibrary('lib/dps_ns3', ns3shobjs, LIBS = ext_libs)
libenv.Install('#/build/dist/lib', ns3shlib)
swig_docs = []
if env['python']:
# Using SWIG to build the python wrapper
pyenv = libenv.Clone()
pyenv.VariantDir('swig/py', 'swig')
pyenv.Append(LIBPATH = env['PY_LIBPATH'])
pyenv.Append(CPPPATH = env['PY_CPPPATH'])
pyenv.Append(LIBS = [lib, env['UV_LIBS']])
# Documentation is only available which Doxygen is installed
try:
if pyenv.Doxygen:
pyenv.Append(SWIGFLAGS = ['-DINCLUDE_DOC'])
except AttributeError:
pass
# Python has platform specific naming conventions
pyenv['SHLIBPREFIX'] = '_'
if platform == 'win32':
pyenv['SHLIBSUFFIX'] = '.pyd'
pyenv.Append(CCFLAGS = ['/EHsc'])
# Ignore warnings in generated code
pyenv.Append(CCFLAGS = ['/wd4244'])
pyenv.Append(SWIGFLAGS = ['-python', '-c++', '-Wextra', '-Werror', '-v', '-O'], SWIGPATH = ['#/inc', './swig/py'])
pyenv.Append(CPPPATH = ['swig', 'swig/py'])
# Build python module library
pyobjs = pyenv.SharedObject(['swig/py/dps.i'])
pylib = pyenv.SharedLibrary('./py/dps', shobjs + pyobjs)
pyenv.Install('#/build/dist/py', pylib)
pyenv.InstallAs('#/build/dist/py/dps.py', './swig/py/dps.py')
# Build documentation
swig_docs += ['swig/py/dps_doc.i']
if env['nodejs'] and platform == 'posix':
# Use SWIG to build the node.js wrapper
nodeenv = libenv.Clone();
nodeenv.VariantDir('swig/js', 'swig')
nodeenv.Append(SWIGFLAGS = ['-javascript', '-node', '-c++', '-DV8_VERSION=0x04059937', '-Wextra', '-Werror', '-v', '-O'], SWIGPATH = ['#/inc', './swig/js'])
# There may be a bug with the SWIG builder - add -O to CPPFLAGS to get it passed on to the compiler
nodeenv.Append(CPPFLAGS = ['-DBUILDING_NODE_EXTENSION', '-std=c++11', '-O', '-Wno-unused-result'])
nodeenv.Append(CPPPATH = ['swig', 'swig/js'])
if env['target'] == 'yocto':
nodeenv.Append(CPPPATH = [os.getenv('SYSROOT') + '/usr/include/node'])
else:
nodeenv.Append(CPPPATH = ['/usr/include/node'])
nodeenv.Append(LIBS = [lib, env['UV_LIBS']])
nodeobjs = nodeenv.SharedObject(['swig/js/dps.i'])
nodedps = nodeenv.SharedLibrary('lib/nodedps', shobjs + nodeobjs)
nodeenv.InstallAs('#/build/dist/js/dps.node', nodedps)
# Build documentation
swig_docs += ['swig/js/dps.jsdoc']
# Unit tests
testenv = env.Clone()
if testenv['PLATFORM'] == 'win32':
testenv.Append(CPPDEFINES = ['_CRT_SECURE_NO_WARNINGS'])
testenv.Append(CPPPATH = ['src'])
testenv.Append(LIBS = [lib, env['UV_LIBS']])
testsrcs = ['test/hist_unit.c',
'test/make_mesh.c',
'test/mesh_stress.c',
'test/countvec.c',
'test/rle_compression.c',
'test/topic_match.c',
'test/pubsub.c',
'test/packtest.c',
'test/cbortest.c',
'test/cosetest.c',
'test/version.c',
'test/keystoretest.c']
Depends(testsrcs, ext_libs)
testprogs = []
for test in testsrcs:
testprogs.append(testenv.Program(test))
testprogs.append(testenv.Program(['test/node.c', 'test/keys.c']))
testenv.Install('#/build/test/bin', testprogs)
# Examples
exampleenv = env.Clone()
if exampleenv['PLATFORM'] == 'win32':
exampleenv.Append(CPPDEFINES = ['_CRT_SECURE_NO_WARNINGS'])
exampleenv.Append(LIBS = [lib, env['UV_LIBS']])
examplesrcs = ['examples/pub_many.c',
'examples/publisher.c',
'examples/reg_pubs.c',
'examples/reg_subs.c',
'examples/subscriber.c',
'examples/registry.c']
Depends(examplesrcs, ext_libs)
exampleprogs = []
for example in examplesrcs:
exampleprogs.append(exampleenv.Program([example, 'examples/keys.c']))
exampleenv.Install('#/build/dist/bin', exampleprogs)
# Tutorial examples
tutorialenv = env.Clone()
if tutorialenv['PLATFORM'] == 'win32':
tutorialenv.Append(CPPDEFINES = ['_CRT_SECURE_NO_WARNINGS'])
tutorialenv.Append(LIBS = [lib, env['UV_LIBS']])
tutorialsrcs = ['doc/tutorial/tutorial.c']
Depends(tutorialsrcs, ext_libs)
tutorialprogs = []
for tutorial in tutorialsrcs:
tutorialprogs.append(tutorialenv.Program(tutorial))
tutorialenv.Install('#/build/dist/bin', tutorialprogs)
# Documentation
try:
docs = libenv.Doxygen('doc/Doxyfile')
libenv.Doxygen('doc/Doxyfile_dev')
libenv.SwigDox(swig_docs, docs)
if env['nodejs'] and platform == 'posix':
libenv.InstallAs('#/build/dist/js/dps.jsdoc', 'swig/js/dps.jsdoc')
except:
# Doxygen may not be installed
pass