From e8677aa36333206f59fae610e9b94ad5d2c3c7e2 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 28 Nov 2013 08:36:41 +0100 Subject: build: make --disable-gl disable all the gl backends Fixes #369 --- DOCS/waf-buildsystem.rst | 5 +++++ waftools/dependencies.py | 17 +++++++++++++---- wscript | 4 ++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/DOCS/waf-buildsystem.rst b/DOCS/waf-buildsystem.rst index ca52531501..d8e4270c11 100644 --- a/DOCS/waf-buildsystem.rst +++ b/DOCS/waf-buildsystem.rst @@ -135,6 +135,11 @@ For example:: will override the value of ``func`` with ``check_pthreads_w32_static`` only if the target OS of the build is Windows. +``groups``: groups a dependency with another one. This can be used to disabled +all the grouped dependencies with one ``--disable-``. At the moment this is +only used for OpenGL backends, where you want to disable them when +``--disable-gl`` is passed to the configure. + mpv's custom build step on top of waf ===================================== diff --git a/waftools/dependencies.py b/waftools/dependencies.py index 16fd2d5f57..f83f29fc38 100644 --- a/waftools/dependencies.py +++ b/waftools/dependencies.py @@ -34,6 +34,7 @@ class Dependency(object): self.ctx.start_msg('Checking for {0}'.format(self.desc)) try: + self.check_group_disabled() self.check_disabled() self.check_any_dependencies() self.check_dependencies() @@ -49,6 +50,14 @@ class Dependency(object): self.check_autodetect_func() + def check_group_disabled(self): + if 'groups' in self.attributes: + groups = self.attributes['groups'] + disabled = (self.enabled_option(g) == False for g in groups) + if any(disabled): + self.skip() + raise DependencyError + def check_disabled(self): if self.enabled_option() == False: self.skip() @@ -89,15 +98,15 @@ the autodetection check failed.".format(self.identifier) self.fail() self.fatal_if_needed() - def enabled_option(self): + def enabled_option(self, identifier=None): try: - return getattr(self.ctx.options, self.enabled_option_repr()) + return getattr(self.ctx.options, self.enabled_option_repr(identifier)) except AttributeError: pass return None - def enabled_option_repr(self): - return "enable_{0}".format(self.identifier) + def enabled_option_repr(self, identifier): + return "enable_{0}".format(identifier or self.identifier) def success(self, depname): self.ctx.mark_satisfied(depname) diff --git a/wscript b/wscript index 19a1d438d7..17dec8d1f9 100644 --- a/wscript +++ b/wscript @@ -497,11 +497,13 @@ video_output_features = [ 'name': '--gl-cocoa', 'desc': 'OpenGL Cocoa Backend', 'deps': [ 'cocoa' ], + 'groups': [ 'gl' ], 'func': check_true } , { 'name': '--gl-x11', 'desc': 'OpenGL X11 Backend', 'deps': [ 'x11' ], + 'groups': [ 'gl' ], 'func': check_libs(['GL', 'GL Xdamage'], check_cc(fragment=load_fragment('gl_x11.c'), use=['x11', 'libdl', 'pthreads'])) @@ -509,12 +511,14 @@ video_output_features = [ 'name': '--gl-wayland', 'desc': 'OpenGL Wayland Backend', 'deps': [ 'wayland' ], + 'groups': [ 'gl' ], 'func': check_pkg_config('wayland-egl', '>= 9.0.0', 'egl', '>= 9.0.0') } , { 'name': '--gl-win32', 'desc': 'OpenGL Win32 Backend', 'deps': [ 'gdi' ], + 'groups': [ 'gl' ], 'func': check_statement('windows.h', 'wglCreateContext(0)', lib='opengl32') } , { -- cgit v1.2.3