• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1project('gst-libav', 'c',
2  version : '1.20.3',
3  meson_version : '>= 0.59',
4  default_options : [ 'warning_level=1',
5                      'buildtype=debugoptimized' ])
6
7gst_version = meson.project_version()
8version_arr = gst_version.split('.')
9gst_version_major = version_arr[0].to_int()
10gst_version_minor = version_arr[1].to_int()
11gst_version_micro = version_arr[2].to_int()
12 if version_arr.length() == 4
13  gst_version_nano = version_arr[3].to_int()
14else
15  gst_version_nano = 0
16endif
17gst_version_is_stable = gst_version_minor.is_even()
18gst_version_is_dev = gst_version_minor.is_odd() and gst_version_micro < 90
19
20api_version = '1.0'
21libavfilter_dep = dependency('libavfilter', version: '>= 7.16.100',
22  fallback: ['FFmpeg', 'libavfilter_dep'])
23libavformat_dep = dependency('libavformat', version: '>= 58.12.100',
24  fallback: ['FFmpeg', 'libavformat_dep'])
25libavcodec_dep = dependency('libavcodec', version: '>= 58.18.100',
26  fallback: ['FFmpeg', 'libavcodec_dep'])
27libavutil_dep = dependency('libavutil', version: '>= 56.14.100',
28  fallback: ['FFmpeg', 'libavutil_dep'])
29
30libav_deps = [libavfilter_dep, libavformat_dep, libavcodec_dep, libavutil_dep]
31
32cc = meson.get_compiler('c')
33
34check_ffmpeg_src = '''#include <libavcodec/avcodec.h>
35#if LIBAVCODEC_VERSION_MICRO >= 100
36/* FFmpeg uses 100+ as its micro version */
37#else
38#error libav provider should be FFmpeg
39#endif'''
40
41libav_deps_type_name = ''
42
43foreach dep: libav_deps
44  if libav_deps_type_name != '' and dep.type_name() != libav_deps_type_name
45    error('Libav deps must be either all internal or all external')
46  endif
47  libav_deps_type_name = dep.type_name()
48endforeach
49
50if dep.type_name() != 'internal'
51  if not cc.compiles(check_ffmpeg_src, dependencies : libav_deps, name : 'libav is provided by FFmpeg')
52    error('Uncompatible libavcodec found')
53  endif
54endif
55
56cdata = configuration_data()
57cdata.set('LIBAV_SOURCE', '"system install"')
58cdata.set('PACKAGE_VERSION', '"@0@"'.format(gst_version))
59cdata.set('PACKAGE', '"gst-libav"')
60
61# GStreamer package name and origin url
62gst_package_name = get_option('package-name')
63if gst_package_name == ''
64  if gst_version_nano == 0
65    gst_package_name = 'GStreamer FFMPEG Plug-ins source release'
66  elif gst_version_nano == 1
67    gst_package_name = 'GStreamer FFMPEG Plug-ins git'
68  else
69    gst_package_name = 'GStreamer FFMPEG Plug-ins prerelease'
70  endif
71endif
72cdata.set_quoted('GST_PACKAGE_NAME', gst_package_name)
73cdata.set_quoted('GST_PACKAGE_ORIGIN', get_option('package-origin'))
74
75
76check_headers = [['unistd.h', 'HAVE_UNISTD_H']]
77
78foreach h : check_headers
79  if cc.has_header(h.get(0))
80    cdata.set(h.get(1), 1)
81  endif
82endforeach
83
84if gst_version_is_stable
85  gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
86else
87  gst_req = '>= ' + gst_version
88endif
89
90gst_dep = dependency('gstreamer-1.0', version : gst_req,
91  fallback : ['gstreamer', 'gst_dep'])
92gstbase_dep = dependency('gstreamer-base-1.0', version : gst_req,
93  fallback : ['gstreamer', 'gst_base_dep'])
94gstcheck_dep = dependency('gstreamer-check-1.0', version : gst_req,
95  required : get_option('tests'),
96  fallback : ['gstreamer', 'gst_check_dep'])
97
98gstvideo_dep = dependency('gstreamer-video-1.0', version : gst_req,
99    fallback : ['gst-plugins-base', 'video_dep'])
100gstaudio_dep = dependency('gstreamer-audio-1.0', version : gst_req,
101    fallback : ['gst-plugins-base', 'audio_dep'])
102gstpbutils_dep = dependency('gstreamer-pbutils-1.0', version : gst_req,
103    fallback : ['gst-plugins-base', 'pbutils_dep'])
104libm = cc.find_library('m', required : false)
105
106gst_libav_args = ['-DHAVE_CONFIG_H']
107if cc.get_id() == 'msvc'
108  msvc_args = [
109      # Ignore several spurious warnings for things gstreamer does very commonly
110      # If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
111      # If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
112      # NOTE: Only add warnings here if you are sure they're spurious
113      '/wd4018', # implicit signed/unsigned conversion
114      '/wd4146', # unary minus on unsigned (beware INT_MIN)
115      '/wd4244', # lossy type conversion (e.g. double -> int)
116      '/wd4305', # truncating type conversion (e.g. double -> float)
117      cc.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8
118
119      # Enable some warnings on MSVC to match GCC/Clang behaviour
120      '/w14062', # enumerator 'identifier' in switch of enum 'enumeration' is not handled
121      '/w14101', # 'identifier' : unreferenced local variable
122      '/w14189', # 'identifier' : local variable is initialized but not referenced
123  ]
124  add_project_arguments(msvc_args, language: ['c', 'cpp'])
125endif
126
127# Symbol visibility
128if cc.has_argument('-fvisibility=hidden')
129  add_project_arguments('-fvisibility=hidden', language: 'c')
130endif
131
132# Don't export any symbols from static ffmpeg libraries
133if cc.has_link_argument('-Wl,--exclude-libs=ALL')
134  add_project_link_arguments('-Wl,--exclude-libs=ALL', language: 'c')
135endif
136
137# Disable strict aliasing
138if cc.has_argument('-fno-strict-aliasing')
139  add_project_arguments('-fno-strict-aliasing', language: 'c')
140endif
141
142if gst_dep.type_name() == 'internal'
143    gst_proj = subproject('gstreamer')
144
145    if not gst_proj.get_variable('gst_debug')
146        message('GStreamer debug system is disabled')
147        add_project_arguments('-Wno-unused', language: 'c')
148    else
149        message('GStreamer debug system is enabled')
150    endif
151else
152    # We can't check that in the case of subprojects as we won't
153    # be able to build against an internal dependency (which is not built yet)
154    if not cc.compiles('''
155#include <gst/gstconfig.h>
156#ifdef GST_DISABLE_GST_DEBUG
157#error "debugging disabled, make compiler fail"
158#endif''' , dependencies: gst_dep)
159        message('GStreamer debug system is disabled')
160        add_project_arguments('-Wno-unused', language: 'c')
161    else
162        message('GStreamer debug system is enabled')
163    endif
164endif
165
166warning_flags = [
167  '-Wmissing-declarations',
168  '-Wmissing-prototypes',
169  '-Wold-style-definition',
170  '-Wredundant-decls',
171  '-Wundef',
172  '-Wwrite-strings',
173  '-Wformat',
174  '-Wformat-nonliteral',
175  '-Wformat-security',
176  '-Winit-self',
177  '-Wmissing-include-dirs',
178  '-Waddress',
179  '-Wno-multichar',
180  '-Waggregate-return',
181  '-Wdeclaration-after-statement',
182  '-Wvla',
183  '-Wpointer-arith',
184]
185
186foreach extra_arg : warning_flags
187  if cc.has_argument (extra_arg)
188    add_project_arguments([extra_arg], language: 'c')
189  endif
190endforeach
191
192configinc = include_directories('.')
193plugins_install_dir = '@0@/gstreamer-1.0'.format(get_option('libdir'))
194
195pkgconfig = import('pkgconfig')
196plugins_pkgconfig_install_dir = join_paths(plugins_install_dir, 'pkgconfig')
197if get_option('default_library') == 'shared'
198  # If we don't build static plugins there is no need to generate pc files
199  plugins_pkgconfig_install_dir = disabler()
200endif
201
202plugins = []
203subdir('ext/libav')
204subdir('docs')
205subdir('tests')
206
207# Set release date
208if gst_version_nano == 0
209  extract_release_date = find_program('scripts/extract-release-date-from-doap-file.py')
210  run_result = run_command(extract_release_date, gst_version, files('gst-libav.doap'), check: true)
211  release_date = run_result.stdout().strip()
212  cdata.set_quoted('GST_PACKAGE_RELEASE_DATETIME', release_date)
213  message('Package release date: ' + release_date)
214endif
215
216configure_file(output: 'config.h', configuration: cdata)
217