Skip to content

Commit

Permalink
meson: Add a Wrap subproject for xcb-keysyms
Browse files Browse the repository at this point in the history
Add a Wrap subproject definition for the xcb-keysyms dependency. It is
a very simple library with a single C source file, so it is easy to make
Meson build definitions for it that get added on top of the tarball
release fetched by Meson if xcb-keysyms is not available. This way it is
guaranteed that there will be at least some support for keyboard input
if the XKB extension is not available in the X server, or not enabled at
build time.
  • Loading branch information
aperezdc committed Nov 30, 2023
1 parent 6c79372 commit e00ce6e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/subprojects/packagecache/
/subprojects/xcb-util-keysyms-0.4.1/
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project('cog', 'c',
meson_version: '>=0.53.2',
meson_version: '>=0.55',
default_options: [
'buildtype=debugoptimized',
'b_ndebug=if-release',
Expand Down
6 changes: 5 additions & 1 deletion platform/x11/cog-platform-x11.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
#include <xcb/xcb_cursor.h>

#ifdef COG_X11_USE_XCB_KEYSYMS
# include <xcb/xcb_keysyms.h>
# if __has_include(<xcb/xcb_keysyms.h>)
# include <xcb/xcb_keysyms.h>
# else
# include <xcb_keysyms.h>
# endif
#endif /* COG_X11_USE_XCB_KEYSYMS */

#ifdef COG_X11_USE_XKB
Expand Down
24 changes: 24 additions & 0 deletions subprojects/packagefiles/xcb-util-keysyms-0.4.1/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
project('xcb-util-keysyms', 'c',
version: '0.4.1',
default_options: [
],
)

xcb_dep = dependency('xcb', version: '>=1.4')
xcb_util_keysyms_dependencies = [xcb_dep, dependency('xproto', version: '>=7.0.8')]

xcb_proto_version = xcb_dep.get_variable('xcbproto_version')
assert(xcb_proto_version.version_compare('>=1.6'),
'libxcb was compiled against xcb-proto @0@, it needs to be compiled against 1.6 or newer'.format(xcb_proto_version))

xcb_util_keysyms_lib = static_library('xcb-util-keysyms',
'keysyms/keysyms.c',
dependencies: xcb_util_keysyms_dependencies,
pic: true,
)

xcb_util_keysyms_dep = declare_dependency(
link_with: xcb_util_keysyms_lib,
dependencies: xcb_util_keysyms_dependencies,
include_directories: include_directories('keysyms'),
)
9 changes: 9 additions & 0 deletions subprojects/xcb-keysyms.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[wrap-file]
directory = xcb-util-keysyms-0.4.1
source_url = https://xcb.freedesktop.org/dist/xcb-util-keysyms-0.4.1.tar.xz
source_filename = xcb-util-keysyms-0.4.1.tar.xz
source_hash = 7c260a5294412aed429df1da2f8afd3bd07b7cba3fec772fba15a613a6d5c638
patch_directory = xcb-util-keysyms-0.4.1

[provide]
xcb-keysyms = xcb_util_keysyms_dep

0 comments on commit e00ce6e

Please sign in to comment.