setup: fallback on pkg-config for search both gstreamer and sdl2 if frameworks are not installed. Closes #4392

This commit is contained in:
Mathieu Virbel 2017-05-05 00:50:27 +02:00
parent 7fd05aaa60
commit 0e330d0042
1 changed files with 16 additions and 4 deletions

View File

@ -402,13 +402,16 @@ elif platform == 'darwin':
# works if we forced the options or in autodetection
if platform not in ('ios', 'android') and (c_options['use_gstreamer']
in (None, True)):
gstreamer_valid = False
if c_options['use_osx_frameworks'] and platform == 'darwin':
# check the existence of frameworks
f_path = '/Library/Frameworks/GStreamer.framework'
if not exists(f_path):
c_options['use_gstreamer'] = False
print('Missing GStreamer framework {}'.format(f_path))
print('GStreamer framework not found, fallback on pkg-config')
else:
print('GStreamer framework found')
gstreamer_valid = True
c_options['use_gstreamer'] = True
gst_flags = {
'extra_link_args': [
@ -420,11 +423,15 @@ if platform not in ('ios', 'android') and (c_options['use_gstreamer']
'-framework', 'GStreamer'],
'include_dirs': [join(f_path, 'Headers')]}
else:
if not gstreamer_valid:
# use pkg-config approach instead
gst_flags = pkgconfig('gstreamer-1.0')
if 'libraries' in gst_flags:
print('GStreamer found via pkg-config')
c_options['use_gstreamer'] = True
else:
print('GStreamer not found via pkg-config, disabling.')
c_options['use_gstreamer'] = False
# detect SDL2, only on desktop and iOS, or android if explicitly enabled
@ -433,6 +440,7 @@ sdl2_flags = {}
if c_options['use_sdl2'] or (
platform not in ('android',) and c_options['use_sdl2'] is None):
sdl2_valid = False
if c_options['use_osx_frameworks'] and platform == 'darwin':
# check the existence of frameworks
sdl2_valid = True
@ -460,16 +468,20 @@ if c_options['use_sdl2'] or (
if not sdl2_valid:
c_options['use_sdl2'] = False
print('Deactivate SDL2 compilation due to missing frameworks')
print('SDL2 frameworks not found, fallback on pkg-config')
else:
c_options['use_sdl2'] = True
print('Activate SDL2 compilation')
elif platform != "ios":
if not sdl2_valid and platform != "ios":
# use pkg-config approach instead
sdl2_flags = pkgconfig('sdl2', 'SDL2_ttf', 'SDL2_image', 'SDL2_mixer')
if 'libraries' in sdl2_flags:
print('SDL2 found via pkg-config')
c_options['use_sdl2'] = True
else:
print('SDL2 not found via pkg-config, disabling.')
c_options['use_sdl2'] = False
# -----------------------------------------------------------------------------