From 0e330d0042d0f073c2a0546fdbc88b3016502d2c Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Fri, 5 May 2017 00:50:27 +0200 Subject: [PATCH] setup: fallback on pkg-config for search both gstreamer and sdl2 if frameworks are not installed. Closes #4392 --- setup.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 87d7c7606..d5e9191e1 100644 --- a/setup.py +++ b/setup.py @@ -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 # -----------------------------------------------------------------------------