Skip to content

Commit bc76a5d

Browse files
committed
add meson build system
1 parent ccfe96e commit bc76a5d

File tree

9 files changed

+352
-0
lines changed

9 files changed

+352
-0
lines changed

examples/meson.build

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
executable('io_uring-cp', 'io_uring-cp.c', include_directories : inc, link_with : liburing_static)
2+
executable('io_uring-test', 'io_uring-test.c', include_directories : inc, link_with : liburing_static)
3+
executable('link-cp', 'link-cp.c', include_directories : inc, link_with : liburing_static)
4+
5+
if has_ucontext
6+
executable('ucontext-cp', 'ucontext-cp.c', include_directories : inc, link_with : liburing_static)
7+
endif

man/meson.build

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
install_man('io_uring.7',
2+
'io_uring_enter.2',
3+
'io_uring_get_sqe.3',
4+
'io_uring_queue_exit.3',
5+
'io_uring_queue_init.3',
6+
'io_uring_register.2',
7+
'io_uring_setup.2')

meson.build

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
project('liburing', ['c','cpp'],
2+
version : '0.7',
3+
license : ['MIT', 'LGPL-2.1-only', 'GPL-2.0-only WITH Linux-syscall-note'],
4+
meson_version : '>=0.53.0',
5+
default_options : ['buildtype=debugoptimized',
6+
'c_std=c11',
7+
'cpp_std=c++11',
8+
'warning_level=3'])
9+
10+
lib_version = '2.0.0'
11+
12+
add_project_arguments('-D_GNU_SOURCE',
13+
'-D__SANE_USERSPACE_TYPES__',
14+
'-include', meson.current_build_dir() + '/config-host.h',
15+
'-Wno-unused-parameter',
16+
'-Wno-sign-compare',
17+
'-fomit-frame-pointer',
18+
language: ['c', 'cpp'])
19+
20+
thread_dep = dependency('threads')
21+
22+
cc = meson.get_compiler('c')
23+
24+
code = '''#include <linux/fs.h>
25+
int main(int argc, char **argv)
26+
{
27+
__kernel_rwf_t x;
28+
x = 0;
29+
return x;
30+
}
31+
'''
32+
has__kernel_rwf_t = cc.compiles(code, name : '__kernel_rwf_t')
33+
34+
code = '''#include <linux/time.h>
35+
#include <linux/time_types.h>
36+
int main(int argc, char **argv)
37+
{
38+
struct __kernel_timespec ts;
39+
ts.tv_sec = 0;
40+
ts.tv_nsec = 1;
41+
return 0;
42+
}
43+
'''
44+
has__kernel_timespec = cc.compiles(code, name : '__kernel_timespec')
45+
46+
code = '''#include <sys/types.h>
47+
#include <sys/stat.h>
48+
#include <fcntl.h>
49+
#include <string.h>
50+
int main(int argc, char **argv)
51+
{
52+
struct open_how how;
53+
how.flags = 0;
54+
how.mode = 0;
55+
how.resolve = 0;
56+
return 0;
57+
}
58+
'''
59+
has_open_how = cc.compiles(code, name : 'open_how')
60+
61+
code = '''#include <sys/types.h>
62+
#include <sys/stat.h>
63+
#include <unistd.h>
64+
#include <fcntl.h>
65+
#include <string.h>
66+
#include <linux/stat.h>
67+
int main(int argc, char **argv)
68+
{
69+
struct statx x;
70+
71+
return memset(&x, 0, sizeof(x)) != NULL;
72+
}
73+
'''
74+
has_statx = cc.compiles(code, name : 'statx')
75+
76+
cpp = meson.get_compiler('cpp')
77+
78+
code = '''#include <iostream>
79+
int main(int argc, char **argv)
80+
{
81+
std::cout << "Test";
82+
return 0;
83+
}
84+
'''
85+
has_cxx = cpp.compiles(code, name : 'C++')
86+
87+
code = '''#include <ucontext.h>
88+
int main(int argc, char **argv)
89+
{
90+
ucontext_t ctx;
91+
getcontext(&ctx);
92+
return 0;
93+
}
94+
'''
95+
has_ucontext = cc.compiles(code, name : 'ucontext')
96+
97+
conf_data = configuration_data()
98+
conf_data.set('CONFIG_HAVE_KERNEL_RWF_T', has__kernel_rwf_t)
99+
conf_data.set('CONFIG_HAVE_KERNEL_TIMESPEC', has__kernel_timespec)
100+
conf_data.set('CONFIG_HAVE_OPEN_HOW', has_open_how)
101+
conf_data.set('CONFIG_HAVE_STATX', has_statx)
102+
conf_data.set('CONFIG_HAVE_CXX', has_cxx)
103+
conf_data.set('CONFIG_HAVE_UCONTEXT', has_ucontext)
104+
configure_file(output : 'config-host.h',
105+
configuration : conf_data)
106+
107+
subdir('src')
108+
subdir('man')
109+
110+
if get_option('examples')
111+
subdir('examples')
112+
endif
113+
114+
if get_option('tests')
115+
subdir('test')
116+
endif
117+
118+
pkg_mod = import('pkgconfig')
119+
pkg_mod.generate(libraries : liburing,
120+
name : 'liburing',
121+
version : meson.project_version(),
122+
description : 'io_uring library',
123+
url : 'http://git.kernel.dk/cgit/liburing/')
124+
125+
summary({'bindir' : get_option('bindir'),
126+
'libdir' : get_option('libdir'),
127+
'datadir' : get_option('datadir'),
128+
}, section : 'Directories')
129+
summary({'examples': get_option('examples'),
130+
'tests' : get_option('tests')
131+
}, section : 'Configuration', bool_yn : true)

meson_options.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
option('examples', type : 'boolean', value : false, description : 'Build example programs')
2+
option('tests', type : 'boolean', value : false, description : 'Build test programs')

src/include/liburing/compat.h.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* SPDX-License-Identifier: MIT */
2+
#ifndef LIBURING_COMPAT_H
3+
#define LIBURING_COMPAT_H
4+
@__kernel_rwf_t_compat@
5+
@__kernel_timespec_compat@
6+
@open_how_compat@
7+
#endif

src/include/liburing/meson.build

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
if has__kernel_rwf_t
2+
__kernel_rwf_t_compat = ''
3+
else
4+
__kernel_rwf_t_compat = '''typedef int __kernel_rwf_t;
5+
'''
6+
endif
7+
8+
if has__kernel_timespec
9+
__kernel_timespec_compat = '''#include <linux/time_types.h>
10+
'''
11+
else
12+
__kernel_timespec_compat = '''#include <stdint.h>
13+
14+
struct __kernel_timespec {
15+
int64_t tv_sec;
16+
long long tv_nsec;
17+
};
18+
'''
19+
endif
20+
21+
if has_open_how
22+
open_how_compat = ''
23+
else
24+
open_how_compat = '''#include <inttypes.h>
25+
26+
struct open_how {
27+
uint64_t flags;
28+
uint64_t mode;
29+
uint64_t resolve;
30+
};
31+
'''
32+
endif
33+
34+
conf_data = configuration_data()
35+
conf_data.set('__kernel_rwf_t_compat', __kernel_rwf_t_compat)
36+
conf_data.set('__kernel_timespec_compat', __kernel_timespec_compat)
37+
conf_data.set('open_how_compat', open_how_compat)
38+
configure_file(input : 'compat.h.in',
39+
output : 'compat.h',
40+
configuration : conf_data,
41+
install : true,
42+
install_dir : get_option('includedir') / 'liburing')
43+
44+
install_headers('barrier.h', 'io_uring.h', subdir : 'liburing')

src/include/meson.build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
install_headers('liburing.h')
2+
3+
subdir('liburing')

src/meson.build

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
subdir('include')
2+
3+
inc = include_directories(['include', '.'])
4+
5+
liburing_src = files('queue.c',
6+
'register.c',
7+
'setup.c',
8+
'syscall.c')
9+
10+
liburing = shared_library('uring',
11+
liburing_src,
12+
include_directories : inc,
13+
version : lib_version,
14+
link_args: '-Wl,--version-script=' + meson.current_source_dir() + '/liburing.map',
15+
install : true)
16+
17+
uring = declare_dependency(link_with: liburing,
18+
include_directories: inc)
19+
20+
liburing_static = static_library('uring',
21+
liburing_src,
22+
include_directories : inc,
23+
install : true)

test/meson.build

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
all_tests = [['232c93d07b74-test', 'c', thread_dep],
2+
['35fa71a030ca-test', 'c', thread_dep],
3+
['500f9fbadef8-test', 'c', []],
4+
['7ad0e4b2f83c-test', 'c', []],
5+
['8a9973408177-test', 'c', []],
6+
['917257daa0fe-test', 'c', []],
7+
['a0908ae19763-test', 'c', []],
8+
['a4c0b3decb33-test', 'c', []],
9+
['accept', 'c', []],
10+
['accept-link', 'c', thread_dep],
11+
['accept-reuse', 'c', []],
12+
['accept-test', 'c', []],
13+
['across-fork', 'c', thread_dep],
14+
['splice', 'c', []],
15+
['b19062a56726-test', 'c', []],
16+
['b5837bd5311d-test', 'c', []],
17+
['ce593a6c480a-test', 'c', thread_dep],
18+
['close-opath', 'c', []],
19+
['connect', 'c', []],
20+
['cq-full', 'c', []],
21+
['cq-overflow', 'c', []],
22+
['cq-overflow-peek', 'c', []],
23+
['cq-peek-batch', 'c', []],
24+
['cq-ready', 'c', []],
25+
['cq-size', 'c', []],
26+
['d4ae271dfaae-test', 'c', []],
27+
['d77a67ed5f27-test', 'c', []],
28+
['defer', 'c', []],
29+
['double-poll-crash', 'c', []],
30+
['eeed8b54e0df-test', 'c', []],
31+
['eventfd', 'c', []],
32+
['eventfd-disable', 'c', []],
33+
['eventfd-ring', 'c', []],
34+
['fadvise', 'c', []],
35+
['fallocate', 'c', []],
36+
['fc2a85cb02ef-test', 'c', []],
37+
['file-register', 'c', []],
38+
['file-update', 'c', []],
39+
['files-exit-hang-poll', 'c', []],
40+
['files-exit-hang-timeout', 'c', []],
41+
['fixed-link', 'c', []],
42+
['fsync', 'c', []],
43+
['io-cancel', 'c', []],
44+
['io_uring_enter', 'c', []],
45+
['io_uring_register', 'c', []],
46+
['io_uring_setup', 'c', []],
47+
['iopoll', 'c', []],
48+
['lfs-openat', 'c', []],
49+
['lfs-openat-write', 'c', []],
50+
['link', 'c', []],
51+
['link-timeout', 'c', []],
52+
['link_drain', 'c', []],
53+
['madvise', 'c', []],
54+
['nop', 'c', []],
55+
['nop-all-sizes', 'c', []],
56+
['open-close', 'c', []],
57+
['openat2', 'c', []],
58+
['personality', 'c', []],
59+
['pipe-eof', 'c', thread_dep],
60+
['pipe-reuse', 'c', []],
61+
['poll', 'c', []],
62+
['poll-cancel', 'c', []],
63+
['poll-cancel-ton', 'c', []],
64+
['poll-link', 'c', thread_dep],
65+
['poll-many', 'c', []],
66+
['poll-ring', 'c', []],
67+
['poll-v-poll', 'c', thread_dep],
68+
['probe', 'c', []],
69+
['read-write', 'c', []],
70+
['register-restrictions', 'c', []],
71+
['rename', 'c', []],
72+
['ring-leak', 'c', []],
73+
['ring-leak2', 'c', thread_dep],
74+
['self', 'c', []],
75+
['send_recv', 'c', thread_dep],
76+
['send_recvmsg', 'c', thread_dep],
77+
['shared-wq', 'c', []],
78+
['short-read', 'c', []],
79+
['shutdown', 'c', []],
80+
['sigfd-deadlock', 'c', []],
81+
['socket-rw', 'c', []],
82+
['socket-rw-eagain', 'c', []],
83+
['sq-full', 'c', []],
84+
['sq-poll-dup', 'c', []],
85+
['sq-poll-kthread', 'c', []],
86+
['sq-poll-share', 'c', []],
87+
['sqpoll-sleep', 'c', []],
88+
['sq-space_left', 'c', []],
89+
['stdout', 'c', []],
90+
['submit-reuse', 'c', thread_dep],
91+
['teardowns', 'c', []],
92+
['thread-exit', 'c', thread_dep],
93+
['timeout', 'c', []],
94+
['timeout-new', 'c', thread_dep],
95+
['timeout-overflow', 'c', []],
96+
['unlink', 'c', []],
97+
['wakeup-hang', 'c', thread_dep]]
98+
99+
if has_statx
100+
all_tests += [['statx', 'c', []]]
101+
endif
102+
103+
if has_statx
104+
all_tests += [['sq-full-cpp', 'cc', []]]
105+
endif
106+
107+
runtests_sh = find_program('runtests.sh')
108+
runtests_loop_sh = find_program('runtests-loop.sh')
109+
110+
foreach t : all_tests
111+
executable(t[0], t[0] + '.' + t[1],
112+
include_directories : inc,
113+
link_with : liburing_static,
114+
dependencies : t[2],
115+
install : true,
116+
install_dir : get_option('datadir') / 'liburing-test')
117+
118+
test(t[0], runtests_sh, args : t[0], workdir : meson.current_build_dir(), suite : 'once')
119+
test(t[0] + '_loop', runtests_loop_sh, args : t[0], workdir : meson.current_build_dir(), suite : 'loop')
120+
endforeach
121+
122+
configure_file(input : 'runtests.sh', output: 'runtests.sh', copy : true)
123+
configure_file(input : 'runtests-loop.sh', output: 'runtests-loop.sh', copy : true)
124+
configure_file(input : 'config', output: 'config.local', copy : true)
125+
126+
install_data('runtests.sh', 'runtests-loop.sh',
127+
install_dir : get_option('datadir') / 'liburing-test',
128+
install_mode : 'rwxr-xr-x')

0 commit comments

Comments
 (0)