summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Thompson <wjt@endlessm.com>2019-03-28 16:09:32 +0000
committerWill Thompson <wjt@endlessm.com>2019-03-28 16:09:32 +0000
commit0f53dc35e4697bf1c545cb4eae795c79299e2cd0 (patch)
tree82bf549f64c04cf9f9ee049e2826fcd96c033c6a
parente16bdc7ef91e5bbdfc1881b51332226393275bb9 (diff)
downloadlibglnx-0f53dc35e4697bf1c545cb4eae795c79299e2cd0.tar.gz
Add meson.build files
-rw-r--r--meson.build83
-rw-r--r--tests/meson.build19
2 files changed, 102 insertions, 0 deletions
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..d9abf37
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,83 @@
+project('libglnx', 'c')
+
+add_project_arguments('-D_GNU_SOURCE', language: 'c')
+
+cc = meson.get_compiler('c')
+
+
+check_functions = [
+ 'renameat2',
+ 'memfd_create',
+ 'copy_file_range',
+]
+conf = configuration_data()
+foreach check_function : check_functions
+ if cc.compiles('''
+ #include <sys/types.h>
+ #include <unistd.h>
+ #include <stdio.h>
+ #include <sys/mount.h>
+ #include <fcntl.h>
+ #include <sched.h>
+ #include <linux/loop.h>
+ #include <linux/random.h>
+ #include <sys/mman.h>
+
+ int func (void) {
+ (void) ''' + check_function + ''';
+ }
+ ''',
+ args : '-D_GNU_SOURCE',
+ name : check_function + '() is declared',
+ )
+ conf.set('HAVE_DECL_' + check_function.underscorify().to_upper(), 1)
+ endif
+endforeach
+config_h = configure_file(
+ output : 'config.h',
+ configuration : conf,
+)
+
+libglnx_deps = [
+ dependency('gio-2.0'),
+ dependency('gio-unix-2.0'),
+]
+libglnx_inc = include_directories('.')
+libglnx_sources = [
+ 'glnx-backport-autocleanups.h',
+ 'glnx-backport-autoptr.h',
+ 'glnx-backports.c',
+ 'glnx-backports.h',
+ 'glnx-console.c',
+ 'glnx-console.h',
+ 'glnx-dirfd.c',
+ 'glnx-dirfd.h',
+ 'glnx-errors.c',
+ 'glnx-errors.h',
+ 'glnx-fdio.c',
+ 'glnx-fdio.h',
+ 'glnx-local-alloc.c',
+ 'glnx-local-alloc.h',
+ 'glnx-lockfile.c',
+ 'glnx-lockfile.h',
+ 'glnx-macros.h',
+ 'glnx-missing.h',
+ 'glnx-missing-syscall.h',
+ 'glnx-shutil.c',
+ 'glnx-shutil.h',
+ 'glnx-xattrs.c',
+ 'glnx-xattrs.h',
+ 'libglnx.h',
+]
+
+libglnx = static_library('glnx',
+ libglnx_sources,
+ dependencies : libglnx_deps,
+ include_directories : libglnx_inc,
+ install : false)
+libglnx_dep = declare_dependency(
+ include_directories : libglnx_inc,
+ link_with : libglnx)
+
+subdir('tests')
+
diff --git a/tests/meson.build b/tests/meson.build
new file mode 100644
index 0000000..d3eddf0
--- /dev/null
+++ b/tests/meson.build
@@ -0,0 +1,19 @@
+
+test_names = [
+ 'errors',
+ 'fdio',
+ 'macros',
+ 'shutil',
+ 'xattrs',
+]
+
+foreach test_name : test_names
+ exe = executable(test_name,
+ ['test-libglnx-' + test_name + '.c', 'libglnx-testlib.h'],
+ dependencies: [
+ libglnx_dep,
+ libglnx_deps,
+ ],
+ )
+ test(test_name, exe)
+endforeach