-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmeson.build
309 lines (263 loc) · 8.94 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
project('vxgcloudagent', ['c', 'cpp'], version : '1.2.44',
meson_version : '>= 0.56.0',
default_options : [ 'warning_level=1',
'buildtype=debug',
'auto_features=disabled',
'default_library=static',
'cpp_std=c++11', 'cpp_link_args=-static-libstdc++' ])
if not meson.is_subproject()
# Install the git pre-commit hook if we are in standalone build
git_hook = run_command(join_paths(meson.source_root(),
'scripts/pre-commit-hook'), 'check-installed')
if git_hook.returncode() == 0
message('Git pre-commit hook installed')
else
message('Installing Git pre-commit hook')
run_command(join_paths(meson.source_root(),
'scripts/pre-commit-hook'), 'install')
endif
endif
vxgcloudagent_version = meson.project_version()
if meson.is_cross_build()
native = false
else
native = true
endif
have_cc = add_languages('c', required : true, native: native)
cc = meson.get_compiler('c', native: native)
have_cxx = add_languages('cpp', required : true, native: native)
cxx = meson.get_compiler('cpp', native: native)
# config.h generation, dlfcn.h and asinh() just as an example
cdata = configuration_data()
check_headers = [
['HAVE_DLFCN_H', 'dlfcn.h']
]
foreach h : check_headers
if cc.has_header(h.get(1))
cdata.set(h.get(0), 1)
else
cdata.set(h.get(0), 0)
endif
endforeach
bt_lib = ''
if cc.has_header('execinfo.h')
message('C compiler has execinfo.h')
elif get_option('backtrace_lib') != ''
bt_lib = get_option('backtrace_lib')
message('C compiler has no execinfo.h, external implementation ' + bt_lib +
' will be used')
else
message('backtrace() will not be used')
cdata.set('LOGURU_STACKTRACES', 0)
endif
check_functions = [
['HAVE_ASINH', 'asinh', '#include<math.h>'],
]
libm = cc.find_library('m', required : false)
foreach f : check_functions
if cc.has_function(f.get(1), prefix : f.get(2), dependencies : libm)
cdata.set(f.get(0), 1)
endif
endforeach
# Corelib version
cdata.set_quoted('VXGCLOUDAGENT_LIB_VERSION', vxgcloudagent_version)
# Access token fields default values
cdata.set_quoted('DEFAULT_CLOUD_TOKEN_API', get_option('DEFAULT_CLOUD_TOKEN_API'))
cdata.set('DEFAULT_CLOUD_TOKEN_API_P', get_option('DEFAULT_CLOUD_TOKEN_API_P'))
cdata.set('DEFAULT_CLOUD_TOKEN_API_SP', get_option('DEFAULT_CLOUD_TOKEN_API_SP'))
cdata.set_quoted('DEFAULT_CLOUD_TOKEN_CAM', get_option('DEFAULT_CLOUD_TOKEN_CAM'))
cdata.set('DEFAULT_CLOUD_TOKEN_CAM_P', get_option('DEFAULT_CLOUD_TOKEN_CAM_P'))
cdata.set('DEFAULT_CLOUD_TOKEN_CAM_SP', get_option('DEFAULT_CLOUD_TOKEN_CAM_SP'))
# SSL related settings
cdata.set_quoted('OPENSSL_CIPHERS_LIST', get_option('OPENSSL_CIPHERS_LIST'))
if get_option('SSL_ALLOW_INSECURE_CERTS')
cdata.set('SSL_ALLOW_INSECURE_CERTS', 1)
else
cdata.set('SSL_ALLOW_INSECURE_CERTS', 0)
endif
props_file = get_option('props_file_path')
message('Properties file option set to ' + props_file)
cdata.set_quoted('PROPS_FILE_PATH', props_file)
if get_option('librtmp').enabled()
cdata.set('RTMP_SOCKS4', 1)
else
cdata.set('RTMP_SOCKS4', 0)
endif
cdata.set('HAVE_CPP_LIB_FILESYSTEM', cc.find_library('stdc++fs', required : false).found())
if get_option('SSL_CERTS_BUNDLE_FILE') != ''
cdata.set_quoted('SSL_CERTS_BUNDLE_FILE', get_option('SSL_CERTS_BUNDLE_FILE'))
endif
configure_file(output : 'config.h', configuration : cdata)
# Warnings
warning_flags = [
'-Wmissing-declarations',
'-Wredundant-decls',
'-Wwrite-strings',
'-Winit-self',
'-Wmissing-include-dirs',
'-Wno-multichar',
'-Wvla',
'-Wpointer-arith',
# FIXME:
'-Wno-reorder',
'-Wno-write-strings',
'-Wno-unused-function',
'-Wno-missing-include-dirs',
'-Wno-unused-function',
'-Wno-psabi',
'-Wno-missing-declarations',
'-Wno-unused-function'
]
warning_c_flags = [
'-Wmissing-prototypes',
'-Wdeclaration-after-statement',
'-Wold-style-definition',
'-Waggregate-return',
]
foreach extra_arg : warning_flags
if cc.has_argument (extra_arg)
add_project_arguments([extra_arg], language: 'c')
endif
if have_cxx and 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
# Disables usage of g++5.0+ locale facets in the date library
# We use date.h header so we need to define this flag globally
if cxx.version().version_compare('< 5')
add_project_arguments(['-DONLY_C_LOCALE=1'], language: 'cpp')
endif
core_srcs = [
'src/agent-proto/command/command.cc',
'src/agent-proto/command-handler.cc',
'src/agent/manager.cc',
'src/utils/packbits.c',
'src/utils/loguru.cc',
'src/utils/logging.cc',
'src/utils/utils.cc',
'src/utils/base64.cc',
'src/utils/properties.cc',
'src/net/websockets.cc',
'src/net/http.cc',
'src/streamer/multifrag_sink.cc',
'src/streamer/stats.c'
]
subdir('src')
websockets = dependency('libwebsockets',
fallback: ['libwebsockets', 'libwebsockets_dep'], required: true)
if get_option('LWS_WITH_SSHD') and websockets.type_name() == 'internal'
core_srcs += [
'src/net/sshd.cc',
'src/net/lws-sshd.c'
]
endif
spdlog = dependency('spdlog',
fallback: ['spdlog', 'spdlog_dep'], required: true)
threads = dependency('threads', required: true)
json = dependency('nlohmann_json',
fallback: ['nlohmann_json', 'nlohmann_json_dep'], required: true)
date_opts = []
if cc.version().version_compare('< 5')
date_opts += ['ONLY_C_LOCALE=enabled']
endif
date = dependency('date',
fallback: ['date', 'date_dep'], required: true, default_options: date_opts)
dl = cc.find_library('dl', required : false)
cpp11fs = cc.find_library('stdc++fs', required : false)
args = dependency('args')
deps = [ websockets, spdlog, threads, json, date, args, cpp11fs, dl ]
if get_option('ffmpeg').enabled()
core_srcs += [
'src/streamer/ffmpeg_sink.cc',
'src/streamer/ffmpeg_source.cc',
'src/streamer/ffmpeg_common.cc'
]
ffmpeg = [
dependency('libavformat',
fallback : ['ffmpeg', 'libavformat_dep'], static: true),
dependency('libavcodec',
fallback : ['ffmpeg', 'libavcodec_dep'],static: true),
dependency('libavutil',
fallback : ['ffmpeg', 'libavutil_dep'],static: true),
]
deps += ffmpeg
endif
if get_option('librtmp').enabled()
librtmp = dependency('librtmp',
fallback: ['librtmp', 'librtmp_dep'], required: true)
deps += librtmp
endif
if meson.is_cross_build() and bt_lib != ''
deps += dependency(bt_lib)
message('Using backtrace lib @0@'.format(bt_lib))
endif
vxgcloudagent_includes = include_directories(['.', 'src/'])
vxgcloudagent = library('vxgcloudagent',
core_srcs,
dependencies: deps,
include_directories: [vxgcloudagent_includes],
install: true)
vxgcloudagent_dep = declare_dependency(
include_directories: [vxgcloudagent_includes],
link_with: vxgcloudagent,
dependencies: deps)
if not meson.is_subproject()
pkg = import('pkgconfig')
pkg.generate(vxgcloudagent)
endif
#
# tests
#
if meson.is_cross_build() == false and not meson.is_subproject()
subdir('src/tests')
endif
if not meson.is_subproject()
args = dependency('args')
# //! [meson-example-target]
executable('cloud-agent-minimal',
sources: [ 'examples/app/src/cloud-agent-minimal.cc' ],
dependencies : [vxgcloudagent_dep, args],
install: true
)
# //! [meson-example-target]
executable('cloud-agent',
sources: [ 'examples/app/src/cloud-agent.cc' ],
dependencies : [vxgcloudagent_dep, args],
install: true
)
if get_option('streamer_test').enabled() and get_option('ffmpeg').enabled()
streamer_test_src = ['examples/streaming/ffmpeg.cc']
executable('ffmpeg_restreamer', sources: streamer_test_src,
dependencies : [ vxgcloudagent_dep ],
include_directories: include_directories('src/'),
)
streamer_test_src = ['examples/streaming/ffmpeg_multipart_record.cc']
executable('ffmpeg_record', sources: streamer_test_src,
dependencies : [ vxgcloudagent_dep ],
include_directories: include_directories('src/'),
)
streamer_test_src = ['examples/streaming/ffmpeg_rtmp2fake.cc']
executable('rtmp2http', sources: streamer_test_src,
dependencies : [ vxgcloudagent_dep, ffmpeg ],
include_directories: include_directories('src/'),
)
streamer_test_src = ['examples/streaming/rtsp2rtmp.cc']
executable('rtsp2rtmp', sources: streamer_test_src,
dependencies : [ vxgcloudagent_dep, ffmpeg ],
include_directories: include_directories('src/'),
)
remux_test_src = ['examples/streaming/remux.cc']
executable('ffmpeg_remux', sources: remux_test_src,
dependencies : [ vxgcloudagent_dep, ffmpeg ],
include_directories: include_directories('src/'),
)
endif
endif
if get_option('documentation')
subdir('doc/')
endif