From 727b1bff57389774b067f0af662455e64d6109bb Mon Sep 17 00:00:00 2001 From: Jan Palus Date: Sat, 18 Apr 2020 20:38:52 +0200 Subject: build: link against single EGL provider when building with rpi EGL is provided by librcmegl library and libEGL should not be linked then --- waftools/checks/custom.py | 29 ++++++++++++++++++++++++++++- wscript | 19 +++++++++---------- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/waftools/checks/custom.py b/waftools/checks/custom.py index 7ca8f8655c..36c1d85d06 100644 --- a/waftools/checks/custom.py +++ b/waftools/checks/custom.py @@ -5,7 +5,8 @@ from distutils.version import StrictVersion import os __all__ = ["check_pthreads", "check_iconv", "check_lua", - "check_cocoa", "check_wl_protocols", "check_swift"] + "check_cocoa", "check_wl_protocols", "check_swift", + "check_egl_provider"] pthreads_program = load_fragment('pthreads.c') @@ -124,3 +125,29 @@ def check_swift(ctx, dependency_identifier): "'swift >= " + str(minVer) + "' not found, found " + str(ctx.env.SWIFT_VERSION or None)) return False + +def check_egl_provider(minVersion=None, name='egl', check=None): + def fn(ctx, dependency_identifier, **kw): + if not hasattr(ctx, 'egl_provider'): + egl_provider_check = check or check_pkg_config(name) + if egl_provider_check(ctx, dependency_identifier): + ctx.egl_provider = name + for ver in ['1.5', '1.4', '1.3', '1.2', '1.1', '1.0']: + stmt = 'int x[EGL_VERSION_{0}]'.format(ver.replace('.','_')) + check_stmt = check_statement(['EGL/egl.h'], stmt) + if check_stmt(ctx, dependency_identifier): + ctx.egl_provider_version = StrictVersion(ver) + break + return True + else: + return False + else: + minVersionSV = minVersion and StrictVersion(minVersion) + if not minVersionSV or ctx.egl_provider_version and \ + ctx.egl_provider_version >= minVersionSV: + defkey = inflector.define_key(dependency_identifier) + ctx.define(defkey, 1) + return True + else: + return False + return fn diff --git a/wscript b/wscript index 5132a763ed..d0a5833dd9 100644 --- a/wscript +++ b/wscript @@ -548,14 +548,19 @@ video_output_features = [ 'func': check_libs(['GL', 'GL Xdamage'], check_cc(fragment=load_fragment('gl_x11.c'), use=['x11', 'libdl', 'pthreads'])) + }, { + 'name': '--rpi', + 'desc': 'Raspberry Pi support', + 'func': check_egl_provider(name='brcmegl', check=any_check( + check_pkg_config('brcmegl'), + check_pkg_config('/opt/vc/lib/pkgconfig/brcmegl.pc') + )), + 'default': 'disable', } , { 'name': '--egl', 'desc': 'EGL 1.4', 'groups': [ 'gl' ], - 'func': compose_checks( - check_pkg_config('egl'), - check_statement(['EGL/egl.h'], 'int x[EGL_VERSION_1_4]') - ), + 'func': check_egl_provider('1.4') } , { 'name': '--egl-x11', 'desc': 'OpenGL X11 EGL Backend', @@ -708,12 +713,6 @@ video_output_features = [ 'desc': 'Direct3D 11 video output', 'deps': 'win32-desktop && shaderc && spirv-cross', 'func': check_cc(header_name=['d3d11_1.h', 'dxgi1_6.h']), - }, { - 'name': '--rpi', - 'desc': 'Raspberry Pi support', - 'func': any_check(check_pkg_config('brcmegl'), - check_pkg_config('/opt/vc/lib/pkgconfig/brcmegl.pc')), - 'default': 'disable', } , { 'name': '--ios-gl', 'desc': 'iOS OpenGL ES hardware decoding interop support', -- cgit v1.2.3