-
Notifications
You must be signed in to change notification settings - Fork 511
add meson build system #297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,3 +123,5 @@ config-host.mak | |
| config.log | ||
|
|
||
| liburing.pc | ||
|
|
||
| /build/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| executable('io_uring-cp', | ||
| 'io_uring-cp.c', | ||
| include_directories : inc, | ||
| link_with : liburing) | ||
|
|
||
| executable('io_uring-test', | ||
| 'io_uring-test.c', | ||
| include_directories : inc, | ||
| link_with : liburing) | ||
|
|
||
| executable('link-cp', | ||
| 'link-cp.c', | ||
| include_directories : inc, | ||
| link_with : liburing) | ||
|
|
||
| if has_ucontext | ||
| executable('ucontext-cp', | ||
| 'ucontext-cp.c', | ||
| include_directories : inc, | ||
| link_with : liburing) | ||
| endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| install_man('io_uring.7', | ||
| 'io_uring_enter.2', | ||
| 'io_uring_get_sqe.3', | ||
| 'io_uring_queue_exit.3', | ||
| 'io_uring_queue_init.3', | ||
| 'io_uring_register.2', | ||
| 'io_uring_setup.2') |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,135 @@ | ||||||||||||||||||||||||||
| project('liburing', ['c','cpp'], | ||||||||||||||||||||||||||
| version : '0.7', | ||||||||||||||||||||||||||
| license : ['MIT', 'LGPL-2.1-only', 'GPL-2.0-only WITH Linux-syscall-note'], | ||||||||||||||||||||||||||
| meson_version : '>=0.53.0', | ||||||||||||||||||||||||||
| default_options : ['default_library=both', | ||||||||||||||||||||||||||
| 'buildtype=debugoptimized', | ||||||||||||||||||||||||||
| 'c_std=c11', | ||||||||||||||||||||||||||
| 'cpp_std=c++11', | ||||||||||||||||||||||||||
| 'warning_level=3']) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| lib_version = '2.0.0' | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| add_project_arguments('-D_GNU_SOURCE', | ||||||||||||||||||||||||||
| '-D__SANE_USERSPACE_TYPES__', | ||||||||||||||||||||||||||
| '-include', meson.current_build_dir() + '/config-host.h', | ||||||||||||||||||||||||||
| '-Wno-unused-parameter', | ||||||||||||||||||||||||||
| '-Wno-sign-compare', | ||||||||||||||||||||||||||
| '-fomit-frame-pointer', | ||||||||||||||||||||||||||
| language: ['c', 'cpp']) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| thread_dep = dependency('threads') | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| cc = meson.get_compiler('c') | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| code = '''#include <linux/fs.h> | ||||||||||||||||||||||||||
| int main(int argc, char **argv) | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| __kernel_rwf_t x; | ||||||||||||||||||||||||||
| x = 0; | ||||||||||||||||||||||||||
| return x; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| ''' | ||||||||||||||||||||||||||
| has__kernel_rwf_t = cc.compiles(code, name : '__kernel_rwf_t') | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| code = '''#include <linux/time.h> | ||||||||||||||||||||||||||
| #include <linux/time_types.h> | ||||||||||||||||||||||||||
| int main(int argc, char **argv) | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| struct __kernel_timespec ts; | ||||||||||||||||||||||||||
| ts.tv_sec = 0; | ||||||||||||||||||||||||||
| ts.tv_nsec = 1; | ||||||||||||||||||||||||||
| return 0; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| ''' | ||||||||||||||||||||||||||
| has__kernel_timespec = cc.compiles(code, name : '__kernel_timespec') | ||||||||||||||||||||||||||
|
Comment on lines
+35
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| code = '''#include <sys/types.h> | ||||||||||||||||||||||||||
| #include <sys/stat.h> | ||||||||||||||||||||||||||
| #include <fcntl.h> | ||||||||||||||||||||||||||
| #include <string.h> | ||||||||||||||||||||||||||
| int main(int argc, char **argv) | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| struct open_how how; | ||||||||||||||||||||||||||
| how.flags = 0; | ||||||||||||||||||||||||||
| how.mode = 0; | ||||||||||||||||||||||||||
| how.resolve = 0; | ||||||||||||||||||||||||||
| return 0; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| ''' | ||||||||||||||||||||||||||
| has_open_how = cc.compiles(code, name : 'open_how') | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| code = '''#include <sys/types.h> | ||||||||||||||||||||||||||
| #include <sys/stat.h> | ||||||||||||||||||||||||||
| #include <unistd.h> | ||||||||||||||||||||||||||
| #include <fcntl.h> | ||||||||||||||||||||||||||
| #include <string.h> | ||||||||||||||||||||||||||
| #include <linux/stat.h> | ||||||||||||||||||||||||||
| int main(int argc, char **argv) | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| struct statx x; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| return memset(&x, 0, sizeof(x)) != NULL; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| ''' | ||||||||||||||||||||||||||
| has_statx = cc.compiles(code, name : 'statx') | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| cpp = meson.get_compiler('cpp') | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| code = '''#include <iostream> | ||||||||||||||||||||||||||
| int main(int argc, char **argv) | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| std::cout << "Test"; | ||||||||||||||||||||||||||
| return 0; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| ''' | ||||||||||||||||||||||||||
| has_cxx = cpp.compiles(code, name : 'C++') | ||||||||||||||||||||||||||
|
Comment on lines
+77
to
+86
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't meson fail if cpp is in the project description but isn't available? If C++ should be optional there might be another way. I remember that we optionally add objective c in JackTrip if we compile on Darwin. |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| code = '''#include <ucontext.h> | ||||||||||||||||||||||||||
| int main(int argc, char **argv) | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| ucontext_t ctx; | ||||||||||||||||||||||||||
| getcontext(&ctx); | ||||||||||||||||||||||||||
| return 0; | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| ''' | ||||||||||||||||||||||||||
| has_ucontext = cc.compiles(code, name : 'ucontext') | ||||||||||||||||||||||||||
|
Comment on lines
+88
to
+96
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| conf_data = configuration_data() | ||||||||||||||||||||||||||
| conf_data.set('CONFIG_HAVE_KERNEL_RWF_T', has__kernel_rwf_t) | ||||||||||||||||||||||||||
| conf_data.set('CONFIG_HAVE_KERNEL_TIMESPEC', has__kernel_timespec) | ||||||||||||||||||||||||||
| conf_data.set('CONFIG_HAVE_OPEN_HOW', has_open_how) | ||||||||||||||||||||||||||
| conf_data.set('CONFIG_HAVE_STATX', has_statx) | ||||||||||||||||||||||||||
| conf_data.set('CONFIG_HAVE_CXX', has_cxx) | ||||||||||||||||||||||||||
| conf_data.set('CONFIG_HAVE_UCONTEXT', has_ucontext) | ||||||||||||||||||||||||||
| configure_file(output : 'config-host.h', | ||||||||||||||||||||||||||
| configuration : conf_data) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| subdir('src') | ||||||||||||||||||||||||||
| subdir('man') | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if get_option('examples') | ||||||||||||||||||||||||||
| subdir('examples') | ||||||||||||||||||||||||||
| endif | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if get_option('tests') | ||||||||||||||||||||||||||
| if get_option('default_library') != 'both' | ||||||||||||||||||||||||||
| error('default_library=both required to build tests') | ||||||||||||||||||||||||||
| endif | ||||||||||||||||||||||||||
| subdir('test') | ||||||||||||||||||||||||||
| endif | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| pkg_mod = import('pkgconfig') | ||||||||||||||||||||||||||
| pkg_mod.generate(libraries : liburing, | ||||||||||||||||||||||||||
| name : 'liburing', | ||||||||||||||||||||||||||
| version : meson.project_version(), | ||||||||||||||||||||||||||
| description : 'io_uring library', | ||||||||||||||||||||||||||
| url : 'http://git.kernel.dk/cgit/liburing/') | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| summary({'bindir' : get_option('bindir'), | ||||||||||||||||||||||||||
| 'libdir' : get_option('libdir'), | ||||||||||||||||||||||||||
| 'datadir' : get_option('datadir'), | ||||||||||||||||||||||||||
| }, section : 'Directories') | ||||||||||||||||||||||||||
| summary({'examples': get_option('examples'), | ||||||||||||||||||||||||||
| 'tests' : get_option('tests') | ||||||||||||||||||||||||||
| }, section : 'Configuration', bool_yn : true) | ||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| option('examples', | ||
| type : 'boolean', | ||
| value : false, | ||
| description : 'Build example programs') | ||
|
|
||
| option('tests', | ||
| type : 'boolean', | ||
| value : false, | ||
| description : 'Build test programs') |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| /* SPDX-License-Identifier: MIT */ | ||
| #ifndef LIBURING_COMPAT_H | ||
| #define LIBURING_COMPAT_H | ||
| @__kernel_rwf_t_compat@ | ||
| @__kernel_timespec_compat@ | ||
| @open_how_compat@ | ||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| if has__kernel_rwf_t | ||
| __kernel_rwf_t_compat = '' | ||
| else | ||
| __kernel_rwf_t_compat = '''typedef int __kernel_rwf_t; | ||
| ''' | ||
| endif | ||
|
|
||
| if has__kernel_timespec | ||
| __kernel_timespec_compat = '''#include <linux/time_types.h> | ||
| ''' | ||
| else | ||
| __kernel_timespec_compat = '''#include <stdint.h> | ||
|
|
||
| struct __kernel_timespec { | ||
| int64_t tv_sec; | ||
| long long tv_nsec; | ||
| }; | ||
| ''' | ||
| endif | ||
|
|
||
| if has_open_how | ||
| open_how_compat = '' | ||
| else | ||
| open_how_compat = '''#include <inttypes.h> | ||
|
|
||
| struct open_how { | ||
| uint64_t flags; | ||
| uint64_t mode; | ||
| uint64_t resolve; | ||
| }; | ||
| ''' | ||
| endif | ||
|
|
||
| conf_data = configuration_data() | ||
| conf_data.set('__kernel_rwf_t_compat', __kernel_rwf_t_compat) | ||
| conf_data.set('__kernel_timespec_compat', __kernel_timespec_compat) | ||
| conf_data.set('open_how_compat', open_how_compat) | ||
| configure_file(input : 'compat.h.in', | ||
| output : 'compat.h', | ||
| configuration : conf_data, | ||
| install : true, | ||
| install_dir : get_option('includedir') / 'liburing') | ||
|
|
||
| install_headers('barrier.h', | ||
| 'io_uring.h', | ||
| subdir : 'liburing') |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| install_headers('liburing.h') | ||
|
|
||
| subdir('liburing') |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| subdir('include') | ||
|
|
||
| inc = include_directories(['include', '.']) | ||
|
|
||
| liburing = library('uring', | ||
| 'queue.c', | ||
| 'register.c', | ||
| 'setup.c', | ||
| 'syscall.c', | ||
| include_directories : inc, | ||
| version : lib_version, | ||
| link_args: '-Wl,--version-script=' + meson.current_source_dir() + '/liburing.map', | ||
| link_depends: 'liburing.map', | ||
| install : true) | ||
|
|
||
| uring = declare_dependency(link_with: liburing, | ||
| include_directories: inc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.