summaryrefslogtreecommitdiffstats
path: root/waftools/checks/custom.py
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2013-11-29 09:01:14 +0100
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2013-11-29 23:11:12 +0100
commitfa620ffc956953b39bb683abb2679bbbfc364915 (patch)
tree53814a8fb30e3a3984fafe98a198358e5b336809 /waftools/checks/custom.py
parent18345400c022ad644ff5dafe1383110c47e7d533 (diff)
downloadmpv-fa620ffc956953b39bb683abb2679bbbfc364915.tar.bz2
mpv-fa620ffc956953b39bb683abb2679bbbfc364915.tar.xz
build: reimplement the OSS checks using a more declarative approach
The OSS checks were a big mess and quite buggy. This reimplementes them using a declarative approach and clearly distinguishing between the various OSS implementations. The code should now almost be auto-documenting. We currently support the following implementations of OSS: * platform-specific (with `sys/soundcard.h`) * SunAudio (default on NetBSD and useable on OpenBSD even if we have sndio support there). * 4Front (default on FreeBSD) Since now each OSS check also checks for the appropriate soundcard header, remove the old soundcard check. Many thanks to @bugmen0t for in depth info about all the BSDs. Check #380 and #359 for more info on this commit.
Diffstat (limited to 'waftools/checks/custom.py')
-rw-r--r--waftools/checks/custom.py59
1 files changed, 14 insertions, 45 deletions
diff --git a/waftools/checks/custom.py b/waftools/checks/custom.py
index 6247d00353..fee56134b4 100644
--- a/waftools/checks/custom.py
+++ b/waftools/checks/custom.py
@@ -1,6 +1,8 @@
from waftools.checks.generic import *
+from waflib import Utils
+import os
-__all__ = ["check_pthreads", "check_iconv", "check_lua", "check_oss"]
+__all__ = ["check_pthreads", "check_iconv", "check_lua", "check_oss_4front"]
pthreads_program = load_fragment('pthreads.c')
@@ -72,56 +74,23 @@ def check_lua(ctx, dependency_identifier):
return True
return False
-# from here on there is the OSS check.. just stop reading here unless you want
-# to die inside a little
-def __fail_oss_check__(ctx):
- ctx.define('PATH_DEV_DSP', '')
- ctx.define('PATH_DEV_MIXER', '')
- return False
-
-def __get_osslibdir__():
- from waflib import Utils
+def __get_osslibdir():
cmd = ['sh', '-c', '. /etc/oss.conf && echo $OSSLIBDIR']
p = Utils.subprocess.Popen(cmd, stdin=Utils.subprocess.PIPE,
stdout=Utils.subprocess.PIPE,
stderr=Utils.subprocess.PIPE)
return p.communicate()[0].decode().rstrip()
-def __get_osscflags__():
- import os
- osscflags = ''
- osslibdir = __get_osslibdir__()
- if osslibdir:
- ossincdir = os.path.join(osslibdir, 'include')
- soundcard_h = os.path.join(ossincdir, 'sys', 'soundcard.h')
- if os.path.exists(soundcard_h):
- osscflags = '-I{0}'.format(ossincdir)
- return osscflags
-
-def __check_oss_headers__(ctx, dependency_identifier):
- fn = check_cc(fragment=load_fragment('oss_audio_header.c'),
- use='soundcard', cflags=__get_osscflags__())
- fn(ctx, dependency_identifier)
- return True
-
-def __check_oss_bsd__(ctxdependency_identifier):
- # add the oss audio library through a check
- ctx.define('PATH_DEV_DSP', '/dev/sound')
- if check_cc(lib='ossaudio')(ctx, dependency_identifier):
- return True
- else:
- return __fail_oss_check__(ctx)
+def check_oss_4front(ctx, dependency_identifier):
+ oss_libdir = __get_osslibdir()
-def check_oss(ctx, dependency_identifier):
- func = check_cc(fragment=load_fragment('oss_audio.c'), use='soundcard',
- cflags=__get_osscflags__())
- if func(ctx, dependency_identifier):
- ctx.define('PATH_DEV_DSP', '/dev/dsp')
- ctx.define('PATH_DEV_MIXER', '/dev/mixer')
+ soundcard_h = os.path.join(oss_libdir, "include/sys/soundcard.h")
+ include_dir = os.path.join(oss_libdir, "include")
- if ctx.env.DEST_OS in ['openbsd', 'netbsd']:
- return __check_oss_bsd_library__(ctx, dependency_identifier)
- else:
- return __check_oss_headers__(ctx, dependency_identifier)
+ fn = check_cc(header_name=soundcard_h,
+ defines=['PATH_DEV_DSP="/dev/dsp"',
+ 'PATH_DEV_MIXER="/dev/mixer"'],
+ cflags='-I{0}'.format(include_dir),
+ fragment=load_fragment('oss_audio.c'))
- return __fail_oss_check__(ctx)
+ return fn(ctx, dependency_identifier)