mirrored from git://anongit.freedesktop.org/gstreamer/gst-libav
-
Notifications
You must be signed in to change notification settings - Fork 31
/
meson.build
217 lines (187 loc) · 7.28 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
project('gst-libav', 'c', 'cpp',
version : '1.19.2',
meson_version : '>= 0.54',
default_options : [ 'warning_level=1',
'buildtype=debugoptimized' ])
gst_version = meson.project_version()
version_arr = gst_version.split('.')
gst_version_major = version_arr[0].to_int()
gst_version_minor = version_arr[1].to_int()
gst_version_micro = version_arr[2].to_int()
if version_arr.length() == 4
gst_version_nano = version_arr[3].to_int()
else
gst_version_nano = 0
endif
api_version = '1.0'
libavfilter_dep = dependency('libavfilter', version: '>= 7.16.100',
fallback: ['FFmpeg', 'libavfilter_dep'])
libavformat_dep = dependency('libavformat', version: '>= 58.12.100',
fallback: ['FFmpeg', 'libavformat_dep'])
libavcodec_dep = dependency('libavcodec', version: '>= 58.18.100',
fallback: ['FFmpeg', 'libavcodec_dep'])
libavutil_dep = dependency('libavutil', version: '>= 56.14.100',
fallback: ['FFmpeg', 'libavutil_dep'])
libav_deps = [libavfilter_dep, libavformat_dep, libavcodec_dep, libavutil_dep]
cc = meson.get_compiler('c')
check_ffmpeg_src = '''#include <libavcodec/avcodec.h>
#if LIBAVCODEC_VERSION_MICRO >= 100
/* FFmpeg uses 100+ as its micro version */
#else
#error libav provider should be FFmpeg
#endif'''
libav_deps_type_name = ''
foreach dep: libav_deps
if libav_deps_type_name != '' and dep.type_name() != libav_deps_type_name
error('Libav deps must be either all internal or all external')
endif
libav_deps_type_name = dep.type_name()
endforeach
if dep.type_name() != 'internal'
if not cc.compiles(check_ffmpeg_src, dependencies : libav_deps, name : 'libav is provided by FFmpeg')
error('Uncompatible libavcodec found')
endif
endif
cdata = configuration_data()
cdata.set('LIBAV_SOURCE', '"system install"')
cdata.set('PACKAGE_VERSION', '"@0@"'.format(gst_version))
cdata.set('PACKAGE', '"gst-libav"')
# GStreamer package name and origin url
gst_package_name = get_option('package-name')
if gst_package_name == ''
if gst_version_nano == 0
gst_package_name = 'GStreamer FFMPEG Plug-ins source release'
elif gst_version_nano == 1
gst_package_name = 'GStreamer FFMPEG Plug-ins git'
else
gst_package_name = 'GStreamer FFMPEG Plug-ins prerelease'
endif
endif
cdata.set_quoted('GST_PACKAGE_NAME', gst_package_name)
cdata.set_quoted('GST_PACKAGE_ORIGIN', get_option('package-origin'))
check_headers = [['unistd.h', 'HAVE_UNISTD_H']]
foreach h : check_headers
if cc.has_header(h.get(0))
cdata.set(h.get(1), 1)
endif
endforeach
gst_req = '>= @0@.@[email protected]'.format(gst_version_major, gst_version_minor)
gst_dep = dependency('gstreamer-1.0', version : gst_req,
fallback : ['gstreamer', 'gst_dep'])
gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
fallback : ['gstreamer', 'gst_base_dep'])
gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
required : get_option('tests'),
fallback : ['gstreamer', 'gst_check_dep'])
gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
fallback : ['gst-plugins-base', 'video_dep'])
gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req,
fallback : ['gst-plugins-base', 'audio_dep'])
gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
fallback : ['gst-plugins-base', 'pbutils_dep'])
libm = cc.find_library('m', required : false)
gst_libav_args = ['-DHAVE_CONFIG_H']
if cc.get_id() == 'msvc'
msvc_args = [
# Ignore several spurious warnings for things gstreamer does very commonly
# If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
# If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
# NOTE: Only add warnings here if you are sure they're spurious
'/wd4018', # implicit signed/unsigned conversion
'/wd4146', # unary minus on unsigned (beware INT_MIN)
'/wd4244', # lossy type conversion (e.g. double -> int)
'/wd4305', # truncating type conversion (e.g. double -> float)
cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8
# Enable some warnings on MSVC to match GCC/Clang behaviour
'/w14062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled
'/w14101', # 'identifier' : unreferenced local variable
'/w14189', # 'identifier' : local variable is initialized but not referenced
]
add_project_arguments(msvc_args, language: ['c', 'cpp'])
endif
# Symbol visibility
if cc.has_argument('-fvisibility=hidden')
add_project_arguments('-fvisibility=hidden', language: 'c')
endif
# Don't export any symbols from static ffmpeg libraries
if cc.has_link_argument('-Wl,--exclude-libs=ALL')
add_project_link_arguments('-Wl,--exclude-libs=ALL', language: 'c')
endif
# Disable strict aliasing
if cc.has_argument('-fno-strict-aliasing')
add_project_arguments('-fno-strict-aliasing', language: 'c')
endif
if gst_dep.type_name() == 'internal'
gst_proj = subproject('gstreamer')
if not gst_proj.get_variable('gst_debug')
message('GStreamer debug system is disabled')
add_project_arguments('-Wno-unused', language: 'c')
else
message('GStreamer debug system is enabled')
endif
else
# We can't check that in the case of subprojects as we won't
# be able to build against an internal dependency (which is not built yet)
if not cc.compiles('''
#include <gst/gstconfig.h>
#ifdef GST_DISABLE_GST_DEBUG
#error "debugging disabled, make compiler fail"
#endif''' , dependencies: gst_dep)
message('GStreamer debug system is disabled')
add_project_arguments('-Wno-unused', language: 'c')
else
message('GStreamer debug system is enabled')
endif
endif
warning_flags = [
'-Wmissing-declarations',
'-Wmissing-prototypes',
'-Wold-style-definition',
'-Wredundant-decls',
'-Wundef',
'-Wwrite-strings',
'-Wformat',
'-Wformat-nonliteral',
'-Wformat-security',
'-Winit-self',
'-Wmissing-include-dirs',
'-Waddress',
'-Wno-multichar',
'-Waggregate-return',
'-Wdeclaration-after-statement',
'-Wvla',
'-Wpointer-arith',
]
foreach extra_arg : warning_flags
if cc.has_argument (extra_arg)
add_project_arguments([extra_arg], language: 'c')
endif
endforeach
configinc = include_directories('.')
plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
pkgconfig = import('pkgconfig')
plugins_pkgconfig_install_dir = join_paths(plugins_install_dir, 'pkgconfig')
if get_option('default_library') == 'shared'
# If we don't build static plugins there is no need to generate pc files
plugins_pkgconfig_install_dir = disabler()
endif
plugins = []
subdir('ext/libav')
subdir('docs')
subdir('tests')
# Set release date
if gst_version_nano == 0
extract_release_date = find_program('scripts/extract-release-date-from-doap-file.py')
run_result = run_command(extract_release_date, gst_version, files('gst-libav.doap'))
if run_result.returncode() == 0
release_date = run_result.stdout().strip()
cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
message('Package release date: ' + release_date)
else
# Error out if our release can't be found in the .doap file
error(run_result.stderr())
endif
endif
configure_file(output: 'config.h', configuration: cdata)
python3 = import('python').find_installation()
run_command(python3, '-c', 'import shutil; shutil.copy("hooks/pre-commit.hook", ".git/hooks/pre-commit")')