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.
This commit is contained in:
Dylan Baker 2024-12-03 10:08:51 -08:00
parent 4cf566ba74
commit 16e9287c0c
2 changed files with 72 additions and 1 deletions

View file

@ -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

71
meson.build Normal file
View file

@ -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()},
)