forked from nnstreamer/nnstreamer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
334 lines (282 loc) · 10.9 KB
/
meson.build
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# If you are using Ubuntu/Xenial, Do "force-version" on meson to get the required version.
# If you are using Tizen 5.0+ or Ubuntu/Bionix+, you don't need to mind meson version.
project('nnstreamer', 'c', 'cpp',
version: '1.5.1',
license: ['LGPL'],
meson_version: '>=0.50.0',
default_options: [
'werror=true',
'warning_level=1',
'c_std=gnu89',
'cpp_std=c++14'
]
)
add_project_arguments('-DVERSION="' + meson.project_version() + '"', language: ['c', 'cpp'])
cc = meson.get_compiler('c')
cxx = meson.get_compiler('cpp')
build_platform = ''
if get_option('enable-tizen')
# Pass __TIZEN__ to the compiler
add_project_arguments('-D__TIZEN__=1', language: ['c', 'cpp'])
build_platform = 'tizen'
elif not meson.is_cross_build()
if cc.get_id() == 'clang' and cxx.get_id() == 'clang'
if build_machine.system() == 'darwin'
# Pass __MACOS__ to the compiler
add_project_arguments('-D__MACOS__=1', language: ['c', 'cpp'])
build_platform = 'macos'
endif
endif
endif
warning_flags = [
'-Wredundant-decls',
'-Wwrite-strings',
'-Wformat',
'-Wformat-nonliteral',
'-Wformat-security',
'-Winit-self',
'-Waddress',
'-Wno-multichar',
'-Wvla',
'-Wpointer-arith'
]
warning_c_flags = [
'-Wmissing-declarations',
'-Wmissing-include-dirs',
'-Wmissing-prototypes',
'-Wnested-externs',
'-Waggregate-return',
'-Wold-style-definition',
'-Wdeclaration-after-statement'
]
foreach extra_arg : warning_flags
if cc.has_argument (extra_arg)
add_project_arguments([extra_arg], language: 'c')
endif
if cxx.has_argument (extra_arg)
add_project_arguments([extra_arg], language: 'cpp')
endif
endforeach
foreach extra_arg : warning_c_flags
if cc.has_argument (extra_arg)
add_project_arguments([extra_arg], language: 'c')
endif
endforeach
gst_api_verision = '1.0'
# Set install path
nnstreamer_prefix = get_option('prefix')
nnstreamer_libdir = join_paths(nnstreamer_prefix, get_option('libdir'))
nnstreamer_bindir = join_paths(nnstreamer_prefix, get_option('bindir'))
nnstreamer_includedir = join_paths(nnstreamer_prefix, get_option('includedir'))
nnstreamer_inidir = get_option('sysconfdir')
# nnstreamer plugins path
plugins_install_dir = join_paths(nnstreamer_libdir, 'gstreamer-' + gst_api_verision)
# nnstreamer sub-plugins path
subplugin_install_prefix = join_paths(nnstreamer_prefix, 'lib', 'nnstreamer')
filter_subplugin_install_dir = join_paths(subplugin_install_prefix, 'filters')
decoder_subplugin_install_dir = join_paths(subplugin_install_prefix, 'decoders')
customfilter_install_dir = join_paths(subplugin_install_prefix, 'customfilters')
unittest_install_dir = join_paths(subplugin_install_prefix, 'unittest')
# Set default configuration
nnstreamer_conf = configuration_data()
nnstreamer_conf.set('VERSION', meson.project_version())
nnstreamer_conf.set('PREFIX', nnstreamer_prefix)
nnstreamer_conf.set('EXEC_PREFIX', nnstreamer_bindir)
nnstreamer_conf.set('LIB_INSTALL_DIR', nnstreamer_libdir)
nnstreamer_conf.set('GST_INSTALL_DIR', plugins_install_dir)
nnstreamer_conf.set('INCLUDE_INSTALL_DIR', nnstreamer_includedir)
nnstreamer_conf.set('SUBPLUGIN_INSTALL_PREFIX', subplugin_install_prefix)
# Define default conf file
add_project_arguments('-DNNSTREAMER_CONF_FILE="' + join_paths(nnstreamer_inidir, 'nnstreamer.ini') + '"', language: 'c')
# Dependencies
glib_dep = dependency('glib-2.0')
gobject_dep = dependency('gobject-2.0')
gmodule_dep = dependency('gmodule-2.0')
gst_dep = dependency('gstreamer-' + gst_api_verision)
gst_base_dep = dependency('gstreamer-base-' + gst_api_verision)
gst_controller_dep = dependency('gstreamer-controller-' + gst_api_verision)
gst_video_dep = dependency('gstreamer-video-' + gst_api_verision)
gst_audio_dep = dependency('gstreamer-audio-' + gst_api_verision)
gst_app_dep = dependency('gstreamer-app-' + gst_api_verision)
gst_check_dep = dependency('gstreamer-check-' + gst_api_verision)
libm_dep = cc.find_library('m') # cmath library
libdl_dep = cc.find_library('dl') # DL library
thread_dep = dependency('threads') # pthread for tensorflow-lite
# Protobuf
protobuf_dep = dependency('protobuf', version: '>= 3.6.1', required: false)
# Orc
have_orcc = false
if get_option('enable-orc')
orc_dep = dependency('orc-0.4', version: '>= 0.4.17', required: true)
orcc = find_program('orcc', required: true)
if orc_dep.found() and orcc.found()
have_orcc = true
orcc_args = [orcc, '--include', 'glib.h']
add_project_arguments('-DHAVE_ORC=1', language: ['c', 'cpp'])
else
error('Cannot find orc library')
endif
else
add_project_arguments('-DDISABLE_ORC=1', language: ['c', 'cpp'])
endif
# NO Video support
if get_option('disable-video-support')
add_project_arguments('-DNO_VIDEO=1', language: ['c', 'cpp'])
message('Disable Video Type Support')
endif
# NO Audio support
if get_option('disable-audio-support')
add_project_arguments('-DNO_AUDIO=1', language: ['c', 'cpp'])
message('Disable Audio Type Support')
endif
# Tensorflow
if get_option('enable-tensorflow')
tf_dep = dependency('tensorflow', required: true)
if tf_dep.found() and protobuf_dep.found()
add_project_arguments('-DENABLE_TENSORFLOW=1', language: ['c', 'cpp'])
else
error('Cannot find tensorflow')
endif
endif
# Tensorflow-lite
if get_option('enable-tensorflow-lite')
tflite_dep = dependency('tensorflow-lite', required: true)
if tflite_dep.found()
add_project_arguments('-DENABLE_TENSORFLOW_LITE=1', language: ['c', 'cpp'])
else
error('Cannot find tensorflow-lite')
endif
endif
# PyTorch
if get_option('enable-pytorch')
torch_dep = dependency('pytorch', required: true)
if torch_dep.found()
add_project_arguments('-DENABLE_PYTORCH=1', language: ['c', 'cpp'])
else
error('Cannot find pytorch')
endif
endif
# Caffe2
if get_option('enable-caffe2')
caffe2_dep = dependency('caffe2', required: true)
if caffe2_dep.found() and protobuf_dep.found()
add_project_arguments('-DENABLE_CAFFE2=1', language: ['c', 'cpp'])
else
error('Cannot find caffe2')
endif
endif
# Python
have_python2 = false
have_python3 = false
if get_option('enable-python')
pg_pkgconfig = find_program('pkg-config')
# Check python 2.7
python2_dep = dependency('python-2.7', required: false)
if python2_dep.found()
python2_incs = []
python2_incs += run_command(pg_pkgconfig, ['python-2.7', '--cflags']).stdout().strip().split()
python2_incs += run_command('python2.7', ['-c', 'import site\nfor i in site.getsitepackages(): print("-I" + i + "/numpy/core/include")']).stdout().strip().split()
python2_incs += '-I' + run_command('python2.7', ['-m', 'site', '--user-site']).stdout().strip() + '/numpy/core/include'
if cc.has_header('numpy/arrayobject.h', args: python2_incs)
have_python2 = true
else
warning('Found python2.7, but failed to find numpy.')
warning('Disable nnstreamer-python2.')
endif
endif
# Check python 3.x
python3_dep = dependency('python3', required: false)
if python3_dep.found()
python3_incs = []
python3_incs += run_command(pg_pkgconfig, ['python3', '--cflags']).stdout().strip().split()
python3_incs += run_command('python3', ['-c', 'import site\nfor i in site.getsitepackages(): print("-I" + i + "/numpy/core/include")']).stdout().strip().split()
python3_incs += '-I' + run_command('python3', ['-m', 'site', '--user-site']).stdout().strip() + '/numpy/core/include'
if cc.has_header('numpy/arrayobject.h', args: python3_incs)
have_python3 = true
else
warning('Found python3, but failed to find numpy.')
warning('Disable nnstreamer-python3.')
endif
endif
endif
# nnfw-runtime ( details in https://review.tizen.org/gerrit/p/platform/core/ml/nnfw )
if get_option('enable-nnfw-runtime')
add_project_arguments('-DENABLE_NNFW_RUNTIME=1', language: ['c', 'cpp'])
# This enables nnfw as a subplugin for Tizen.
endif
# nnfw-runtime ( details in https://review.tizen.org/gerrit/p/platform/core/ml/nnfw )
if get_option('enable-tflite-nnapi-delegation')
add_project_arguments('-DENABLE_TFLITE_NNAPI_DELEGATION=1', language: ['c', 'cpp'])
# For tf-lite/nnapi, enable-nnfw allows to use nnfw::tflite::nnapi as a backend.
endif
# ArmNN
if get_option('enable-armnn')
armnn_dep = dependency('armnn', required: true)
add_project_arguments('-DENABLE_ARMNN=1', language: ['c', 'cpp'])
endif
# Movidius NCSDK2
have_movidius_ncsdk2 = false
if get_option('enable-movidius-ncsdk2')
# Explicitly checks mvnc.h in the ncsdk2 directory
nns_mvncsdk2_dep = cc.find_library('mvnc', required: false)
if not nns_mvncsdk2_dep.found()
warning('Failed to find \'libmvnc.so\' despite setting enable-movidius-ncsdk2. This option be ignored.')
elif not cc.check_header('mvnc2/mvnc.h')
warning('Failed to find \'mvnc2/mvnc.h\' despite setting enable-movidius-ncsdk2. This option be ignored.')
else
have_movidius_ncsdk2 = true
add_project_arguments('-DENABLE_MOVIDIUS_NCSDK2=1', language: ['c', 'cpp'])
endif
endif
# Set configuration to install .ini
nnstreamer_install_conf = configuration_data()
nnstreamer_install_conf.merge_from(nnstreamer_conf)
nnstreamer_install_conf.set('ENABLE_ENV_VAR', get_option('enable-env-var'))
nnstreamer_install_conf.set('ENABLE_SYMBOLIC_LINK', get_option('enable-symbolic-link'))
nnstreamer_install_conf.set('TORCH_USE_GPU', get_option('enable-pytorch-use-gpu'))
nnstreamer_install_conf.set('NNFW_RUNTIME_PRIORITIZE', get_option('nnfw-runtime-prioritize'))
# Element restriction
restriction_config = ''
if get_option('enable-element-restriction')
restriction_config = '''[element-restriction]
enable_element_restriction=True
restricted_elements=''' + get_option('restricted-elements')
endif
nnstreamer_install_conf.set('ELEMENT_RESTRICTION_CONFIG', restriction_config)
# Install .ini
configure_file(input: 'nnstreamer.ini.in', output: 'nnstreamer.ini',
install_dir: nnstreamer_inidir,
configuration: nnstreamer_install_conf
)
# Install .pc
configure_file(input: 'nnstreamer.pc.in', output: 'nnstreamer.pc',
install_dir: join_paths(nnstreamer_libdir, 'pkgconfig'),
configuration: nnstreamer_install_conf
)
# Build nnstreamer (common, plugins)
subdir('gst')
# Build ext subplugins
subdir('ext')
# Build API
subdir('api')
# Build nnstreamer examples
if get_option('enable-test') or get_option('install-example')
subdir('nnstreamer_example')
endif
# Build unittests
if get_option('enable-test')
subdir('tests')
# temporary ini file for test, enable env variables.
nnstreamer_test_conf = configuration_data()
nnstreamer_test_conf.merge_from(nnstreamer_conf)
nnstreamer_test_conf.set('ENABLE_ENV_VAR', true)
nnstreamer_test_conf.set('ENABLE_SYMBOLIC_LINK', false)
nnstreamer_test_conf.set('TORCH_USE_GPU', false)
nnstreamer_test_conf.set('ELEMENT_RESTRICTION_CONFIG', '')
nnstreamer_test_conf.set('NNFW_RUNTIME_PRIORITIZE', false)
configure_file(input: 'nnstreamer.ini.in', output: 'nnstreamer-test.ini',
install: get_option('install-test'),
install_dir: unittest_install_dir,
configuration: nnstreamer_test_conf
)
endif