From 16e9287c0c53738ddeb83002aff5845767ee6160 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 3 Dec 2024 10:08:51 -0800 Subject: [PATCH] wip: Add meson build This adds support to build with Meson. There are a few missing things here: - Doesn't have the same level of warnings - Doesn't handle exports, this requires a move to using gnu symbol visibility instead of using libtool. --- Makefile.am | 2 +- meson.build | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 meson.build diff --git a/Makefile.am b/Makefile.am index 8e2a869..3609f05 100644 --- a/Makefile.am +++ b/Makefile.am @@ -12,7 +12,7 @@ ChangeLog: dist-hook: ChangeLog INSTALL -EXTRA_DIST = autogen.sh xcb-errors.pc.in src/errors.h src/extensions.py README.md +EXTRA_DIST = autogen.sh xcb-errors.pc.in src/errors.h src/extensions.py README.md meson.build lib_LTLIBRARIES = libxcb-errors.la diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..55cb2f3 --- /dev/null +++ b/meson.build @@ -0,0 +1,71 @@ +# SPDX-License-Identifier: MIT +# Copyright © 2024 Dylan Baker + +project( + 'libxcb-errors', + 'c', + version : '1.0.1', + meson_version : '>= 1.0', # arbitrary + default_options : ['warning_level=1'] +) + +dep_xcb = dependency('xcb', version : '>= 1.4') +if dep_xcb.get_variable(pkgconfig : 'xcbproto_version').version_compare('< 1.6') + error('libxcb was compiled against xcb-proto < 1.6, which is the minimum supported version') +endif + +dep_xcb_proto = dependency('xcb-proto', version : '>= 1.6') + +extensions_c = custom_target( + 'extensions.c', + command : [ + find_program('python', version : '>= 3.9'), + '@INPUT0@', + '@OUTPUT@', + dep_xcb_proto.get_variable(pkgconfig : 'xcbincludedir'), + ], + input : ['src/extensions.py'], + output : ['@PLAINNAME@.c', '@PLAINNAME@.checksums'], + # This is marked always stale because it does globbing. There's just no way to + # know if the inputs have changed. + build_always_stale : true, +) + +inc_src = include_directories('src') + +libxcb_errors = library( + 'xcb-errors', + 'src/xcb_errors.c', + extensions_c, + include_directories: inc_src, + dependencies : [dep_xcb], + version : '0.0.0', + install : true, +) + +dep_xcb_errors = declare_dependency( + link_with : libxcb_errors, + dependencies: [dep_xcb], + include_directories : inc_src, +) + +test( + 'xcb-errors-test', + executable( + 'xcb-errors-test', + 'tests/test.c', + dependencies : dep_xcb_errors, + ) +) + +install_headers('src/xcb_errors.h', subdir : 'xcb') + +pkg = import('pkgconfig') + +pkg.generate( + libxcb_errors, + filebase: 'xcb-errors', + name : 'XCB errors library', + description : 'XCB errors utility library', + variables : {'xcbproto_version': dep_xcb_proto.version()}, +)