2015-07-26 13:00:47 +00:00
|
|
|
from waftools import inflector
|
2013-07-16 11:28:28 +00:00
|
|
|
from waftools.checks.generic import *
|
2013-11-29 08:01:14 +00:00
|
|
|
from waflib import Utils
|
|
|
|
import os
|
2013-07-16 11:28:28 +00:00
|
|
|
|
2017-06-22 08:30:11 +00:00
|
|
|
__all__ = ["check_pthreads", "check_iconv", "check_lua",
|
2017-10-01 20:16:49 +00:00
|
|
|
"check_cocoa", "check_openal", "check_wl_protocols"]
|
2013-07-16 11:28:28 +00:00
|
|
|
|
|
|
|
pthreads_program = load_fragment('pthreads.c')
|
|
|
|
|
2014-04-27 07:05:07 +00:00
|
|
|
def check_pthread_flag(ctx, dependency_identifier):
|
|
|
|
checks = [
|
|
|
|
check_cc(fragment = pthreads_program, cflags = '-pthread'),
|
|
|
|
check_cc(fragment = pthreads_program, cflags = '-pthread',
|
|
|
|
linkflags = '-pthread') ]
|
|
|
|
|
|
|
|
for fn in checks:
|
|
|
|
if fn(ctx, dependency_identifier):
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2013-07-16 11:28:28 +00:00
|
|
|
def check_pthreads(ctx, dependency_identifier):
|
2015-01-01 14:10:42 +00:00
|
|
|
if ctx.dependency_satisfied('win32-internal-pthreads'):
|
|
|
|
h = ctx.path.find_node('osdep/win32/include').abspath()
|
|
|
|
# define IN_WINPTHREAD to workaround mingw stupidity (we never want it
|
|
|
|
# to define features specific to its own pthread stuff)
|
2015-01-07 20:33:14 +00:00
|
|
|
ctx.env.CFLAGS += ['-isystem', h, '-I', h, '-DIN_WINPTHREAD']
|
2015-01-01 14:10:42 +00:00
|
|
|
return True
|
2014-04-27 07:05:07 +00:00
|
|
|
if check_pthread_flag(ctx, dependency_identifier):
|
|
|
|
return True
|
2013-07-16 11:28:28 +00:00
|
|
|
platform_cflags = {
|
|
|
|
'linux': '-D_REENTRANT',
|
|
|
|
'freebsd': '-D_THREAD_SAFE',
|
|
|
|
'netbsd': '-D_THREAD_SAFE',
|
|
|
|
'openbsd': '-D_THREAD_SAFE',
|
|
|
|
}.get(ctx.env.DEST_OS, '')
|
|
|
|
libs = ['pthreadGC2', 'pthread']
|
|
|
|
checkfn = check_cc(fragment=pthreads_program, cflags=platform_cflags)
|
2013-11-26 13:16:29 +00:00
|
|
|
checkfn_nocflags = check_cc(fragment=pthreads_program)
|
|
|
|
for fn in [checkfn, checkfn_nocflags]:
|
|
|
|
if check_libs(libs, fn)(ctx, dependency_identifier):
|
|
|
|
return True
|
|
|
|
return False
|
2013-07-16 11:28:28 +00:00
|
|
|
|
|
|
|
def check_iconv(ctx, dependency_identifier):
|
|
|
|
iconv_program = load_fragment('iconv.c')
|
|
|
|
libdliconv = " ".join(ctx.env.LIB_LIBDL + ['iconv'])
|
|
|
|
libs = ['iconv', libdliconv]
|
2016-02-01 17:30:22 +00:00
|
|
|
args = {'fragment': iconv_program}
|
2016-05-10 21:00:01 +00:00
|
|
|
if ctx.env.DEST_OS == 'openbsd' or ctx.env.DEST_OS == 'freebsd':
|
2016-02-01 17:30:22 +00:00
|
|
|
args['cflags'] = '-I/usr/local/include'
|
|
|
|
args['linkflags'] = '-L/usr/local/lib'
|
2017-01-28 10:31:28 +00:00
|
|
|
elif ctx.env.DEST_OS == 'win32':
|
|
|
|
args['linkflags'] = " ".join(['-L' + x for x in ctx.env.LIBRARY_PATH])
|
2016-02-01 17:30:22 +00:00
|
|
|
checkfn = check_cc(**args)
|
2013-07-16 11:28:28 +00:00
|
|
|
return check_libs(libs, checkfn)(ctx, dependency_identifier)
|
|
|
|
|
|
|
|
def check_lua(ctx, dependency_identifier):
|
|
|
|
lua_versions = [
|
|
|
|
( '51', 'lua >= 5.1.0 lua < 5.2.0'),
|
2016-01-11 02:57:08 +00:00
|
|
|
( '51obsd', 'lua51 >= 5.1.0'), # OpenBSD
|
2013-07-16 11:28:28 +00:00
|
|
|
( '51deb', 'lua5.1 >= 5.1.0'), # debian
|
2014-01-14 22:49:26 +00:00
|
|
|
( '51fbsd', 'lua-5.1 >= 5.1.0'), # FreeBSD
|
2015-04-01 21:59:09 +00:00
|
|
|
( '52', 'lua >= 5.2.0 lua < 5.3.0' ),
|
2015-05-13 12:54:58 +00:00
|
|
|
( '52arch', 'lua52 >= 5.2.0'), # Arch
|
2013-07-16 11:28:28 +00:00
|
|
|
( '52deb', 'lua5.2 >= 5.2.0'), # debian
|
2014-01-14 22:49:26 +00:00
|
|
|
( '52fbsd', 'lua-5.2 >= 5.2.0'), # FreeBSD
|
2014-12-02 21:09:29 +00:00
|
|
|
( 'luajit', 'luajit >= 2.0.0' ),
|
2013-07-16 11:28:28 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
if ctx.options.LUA_VER:
|
|
|
|
lua_versions = \
|
|
|
|
[lv for lv in lua_versions if lv[0] == ctx.options.LUA_VER]
|
|
|
|
|
|
|
|
for lua_version, pkgconfig_query in lua_versions:
|
2014-10-25 18:07:44 +00:00
|
|
|
if check_pkg_config(pkgconfig_query, uselib_store=lua_version) \
|
|
|
|
(ctx, dependency_identifier):
|
2013-07-16 11:28:28 +00:00
|
|
|
# XXX: this is a bit of a hack, ask waf developers if I can copy
|
|
|
|
# the uselib_store to 'lua'
|
|
|
|
ctx.mark_satisfied(lua_version)
|
|
|
|
ctx.add_optional_message(dependency_identifier,
|
|
|
|
'version found: ' + lua_version)
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2017-10-01 20:16:49 +00:00
|
|
|
def check_wl_protocols(ctx, dependency_identifier):
|
|
|
|
def fn(ctx, dependency_identifier):
|
|
|
|
ret = check_pkg_config_datadir("wayland-protocols")
|
|
|
|
ret = ret(ctx, dependency_identifier)
|
|
|
|
if ret != None:
|
|
|
|
ctx.env.WL_PROTO_DIR = ret.split()[0]
|
|
|
|
return ret
|
|
|
|
return fn(ctx, dependency_identifier)
|
|
|
|
|
2014-01-02 19:34:14 +00:00
|
|
|
def check_cocoa(ctx, dependency_identifier):
|
|
|
|
fn = check_cc(
|
|
|
|
fragment = load_fragment('cocoa.m'),
|
|
|
|
compile_filename = 'test.m',
|
2015-02-25 21:13:07 +00:00
|
|
|
framework_name = ['Cocoa', 'IOKit', 'OpenGL', 'QuartzCore'],
|
2014-01-02 19:34:14 +00:00
|
|
|
includes = ctx.srcnode.abspath(),
|
|
|
|
linkflags = '-fobjc-arc')
|
|
|
|
|
2018-01-31 22:30:10 +00:00
|
|
|
res = fn(ctx, dependency_identifier)
|
|
|
|
# on macOS we explicitly need to set the SDK path, otherwise it can lead to
|
|
|
|
# linking warnings or errors
|
|
|
|
if res:
|
|
|
|
ctx.env.append_value('LINKFLAGS', [
|
cocoa-cb: initial implementation via opengl-cb API
this is meant to replace the old and not properly working vo_gpu/opengl
cocoa backend in the future. the problems are various shortcomings of
Apple's opengl implementation and buggy behaviour in certain
circumstances that couldn't be properly worked around. there are also
certain regressions on newer macOS versions from 10.11 onwards.
- awful opengl performance with a none layer backed context
- huge amount of dropped frames with an early context flush
- flickering of system elements like the dock or volume indicator
- double buffering not properly working with a none layer backed context
- bad performance in fullscreen because of system optimisations
all the problems were caused by using a normal opengl context, that
seems somewhat abandoned by apple, and are fixed by using a layer backed
opengl context instead. problems that couldn't be fixed could be
properly worked around.
this has all features our old backend has sans the wid embedding,
the possibility to disable the automatic GPU switching and taking
screenshots of the window content. the first was deemed unnecessary by
me for now, since i just use the libmpv API that others can use anyway.
second is technically not possible atm because we have to pre-allocate
our opengl context at a time the config isn't read yet, so we can't get
the needed property. third one is a bit tricky because of deadlocking
and it needed to be in sync, hopefully i can work around that in the
future.
this also has at least one additional feature or eye-candy. a properly
working fullscreen animation with the native fs. also since this is a
direct port of the old backend of the parts that could be used, though
with adaptions and improvements, this looks a lot cleaner and easier to
understand.
some credit goes to @pigoz for the initial swift build support which
i could improve upon.
Fixes: #5478, #5393, #5152, #5151, #4615, #4476, #3978, #3746, #3739,
#2392, #2217
2018-02-12 11:28:19 +00:00
|
|
|
'-isysroot', ctx.env.MACOS_SDK
|
2018-01-31 22:30:10 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
return res
|
2016-08-21 21:59:08 +00:00
|
|
|
|
|
|
|
def check_openal(ctx, dependency_identifier):
|
|
|
|
checks = [
|
|
|
|
check_pkg_config('openal', '>= 1.13'),
|
|
|
|
check_statement(['OpenAL/AL.h'], 'int i = AL_VERSION', framework='OpenAL')
|
|
|
|
]
|
|
|
|
|
|
|
|
for fn in checks:
|
|
|
|
if fn(ctx, dependency_identifier):
|
|
|
|
return True
|
|
|
|
return False
|