Final fixes needed for wayland building

kitty now runs under wayland again
This commit is contained in:
Kovid Goyal 2017-11-21 06:46:30 +05:30
parent 47dec2c2e9
commit 982a9320c5
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 19 additions and 9 deletions

2
.gitignore vendored
View File

@ -11,4 +11,4 @@ asan-launcher
kitty-profile kitty-profile
dev dev
__pycache__ __pycache__
glfw/wayland-*-client-protocol.h glfw/wayland-*-client-protocol.[ch]

View File

@ -13,6 +13,11 @@ is_macos = 'darwin' in _plat
base = os.path.dirname(os.path.abspath(__file__)) base = os.path.dirname(os.path.abspath(__file__))
def wayland_protocol_file_name(base, ext='c'):
base = os.path.basename(base).rpartition('.')[0]
return 'wayland-{}-client-protocol.{}'.format(base, ext)
def init_env(env, pkg_config, at_least_version, module='x11'): def init_env(env, pkg_config, at_least_version, module='x11'):
ans = env.copy() ans = env.copy()
ans.cflags = [ ans.cflags = [
@ -34,6 +39,8 @@ def init_env(env, pkg_config, at_least_version, module='x11'):
else: else:
ans.ldpaths.extend('-lrt -lm -ldl'.split()) ans.ldpaths.extend('-lrt -lm -ldl'.split())
sinfo = json.load(open(os.path.join(base, 'source-info.json'))) sinfo = json.load(open(os.path.join(base, 'source-info.json')))
ans.sources = sinfo['common']['sources'] + sinfo[module]['sources']
ans.all_headers = [x for x in os.listdir(base) if x.endswith('.h')]
if module == 'x11': if module == 'x11':
for dep in 'x11 xrandr xinerama xcursor xkbcommon xkbcommon-x11'.split(): for dep in 'x11 xrandr xinerama xcursor xkbcommon xkbcommon-x11'.split():
@ -49,22 +56,25 @@ def init_env(env, pkg_config, at_least_version, module='x11'):
ans.wayland_packagedir = os.path.abspath(pkg_config('wayland-protocols', '--variable=pkgdatadir')[0]) ans.wayland_packagedir = os.path.abspath(pkg_config('wayland-protocols', '--variable=pkgdatadir')[0])
ans.wayland_scanner = os.path.abspath(pkg_config('wayland-scanner', '--variable=wayland_scanner')[0]) ans.wayland_scanner = os.path.abspath(pkg_config('wayland-scanner', '--variable=wayland_scanner')[0])
ans.wayland_protocols = tuple(sinfo[module]['protocols']) ans.wayland_protocols = tuple(sinfo[module]['protocols'])
for dep in 'wayland-egl wayland-client wayland-scanner xkbcommon'.split(): for p in ans.wayland_protocols:
ans.sources.append(wayland_protocol_file_name(p))
ans.all_headers.append(wayland_protocol_file_name(p, 'h'))
for dep in 'wayland-egl wayland-client wayland-cursor xkbcommon'.split():
ans.cflags.extend(pkg_config(dep, '--cflags-only-I')) ans.cflags.extend(pkg_config(dep, '--cflags-only-I'))
ans.ldpaths.extend(pkg_config(dep, '--libs')) ans.ldpaths.extend(pkg_config(dep, '--libs'))
ans.sources = sinfo['common']['sources'] + sinfo[module]['sources']
ans.all_headers = [x for x in os.listdir(base) if x.endswith('.h')]
return ans return ans
def build_wayland_protocols(env, run_tool, emphasis, newer, dest_dir): def build_wayland_protocols(env, run_tool, emphasis, newer, dest_dir):
for protocol in env.wayland_protocols: for protocol in env.wayland_protocols:
src = os.path.join(env.wayland_packagedir, protocol) src = os.path.join(env.wayland_packagedir, protocol)
dest = os.path.basename(src).rpartition('.')[0] + '-client-protocol.h' for ext in 'hc':
dest = os.path.join(dest_dir, 'wayland-' + dest) dest = wayland_protocol_file_name(src, ext)
dest = os.path.join(dest_dir, dest)
if newer(dest, src): if newer(dest, src):
run_tool([env.wayland_scanner, 'client-header', src, dest], q = 'client-header' if ext == 'h' else 'code'
run_tool([env.wayland_scanner, q, src, dest],
desc='Generating {} ...'.format(emphasis(os.path.basename(dest)))) desc='Generating {} ...'.format(emphasis(os.path.basename(dest))))