From e00ce6efd0e98fc7aaaf568274ed8cc1c1f7f4ae Mon Sep 17 00:00:00 2001 From: Adrian Perez de Castro Date: Thu, 30 Nov 2023 14:46:20 +0200 Subject: [PATCH] meson: Add a Wrap subproject for xcb-keysyms 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. --- .gitignore | 2 ++ meson.build | 2 +- platform/x11/cog-platform-x11.c | 6 ++++- .../xcb-util-keysyms-0.4.1/meson.build | 24 +++++++++++++++++++ subprojects/xcb-keysyms.wrap | 9 +++++++ 5 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 subprojects/packagefiles/xcb-util-keysyms-0.4.1/meson.build create mode 100644 subprojects/xcb-keysyms.wrap diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..f80b8690 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/subprojects/packagecache/ +/subprojects/xcb-util-keysyms-0.4.1/ diff --git a/meson.build b/meson.build index d89346fe..5097173e 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('cog', 'c', - meson_version: '>=0.53.2', + meson_version: '>=0.55', default_options: [ 'buildtype=debugoptimized', 'b_ndebug=if-release', diff --git a/platform/x11/cog-platform-x11.c b/platform/x11/cog-platform-x11.c index ac42b6ae..9db380db 100644 --- a/platform/x11/cog-platform-x11.c +++ b/platform/x11/cog-platform-x11.c @@ -20,7 +20,11 @@ #include #ifdef COG_X11_USE_XCB_KEYSYMS -# include +# if __has_include() +# include +# else +# include +# endif #endif /* COG_X11_USE_XCB_KEYSYMS */ #ifdef COG_X11_USE_XKB diff --git a/subprojects/packagefiles/xcb-util-keysyms-0.4.1/meson.build b/subprojects/packagefiles/xcb-util-keysyms-0.4.1/meson.build new file mode 100644 index 00000000..60469c36 --- /dev/null +++ b/subprojects/packagefiles/xcb-util-keysyms-0.4.1/meson.build @@ -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'), +) diff --git a/subprojects/xcb-keysyms.wrap b/subprojects/xcb-keysyms.wrap new file mode 100644 index 00000000..8b78d33f --- /dev/null +++ b/subprojects/xcb-keysyms.wrap @@ -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