1
0
Fork 0
mirror of https://gitlab.com/niansa/libasync.git synced 2025-03-06 20:53:29 +01:00

meson: improve meson.build file and drop library.makefile

This commit is contained in:
Kacper Słomiński 2022-01-25 01:10:15 +01:00
parent e9b80a5dde
commit e22243d8d2
4 changed files with 74 additions and 62 deletions

View file

@ -1,16 +0,0 @@
.PHONY: install
install:
mkdir -p $(DESTDIR)$(prefix)include/async
install -p --mode=0644 $S/include/async/basic.hpp $(DESTDIR)$(prefix)include/async/
install -p --mode=0644 $S/include/async/cancellation.hpp $(DESTDIR)$(prefix)include/async/
install -p --mode=0644 $S/include/async/execution.hpp $(DESTDIR)$(prefix)include/async/
install -p --mode=0644 $S/include/async/mutex.hpp $(DESTDIR)$(prefix)include/async/
install -p --mode=0644 $S/include/async/oneshot-event.hpp $(DESTDIR)$(prefix)include/async/
install -p --mode=0644 $S/include/async/post-ack.hpp $(DESTDIR)$(prefix)include/async/
install -p --mode=0644 $S/include/async/recurring-event.hpp $(DESTDIR)$(prefix)include/async/
install -p --mode=0644 $S/include/async/result.hpp $(DESTDIR)$(prefix)include/async/
install -p --mode=0644 $S/include/async/queue.hpp $(DESTDIR)$(prefix)include/async/
install -p --mode=0644 $S/include/async/algorithm.hpp $(DESTDIR)$(prefix)include/async/
install -p --mode=0644 $S/include/async/promise.hpp $(DESTDIR)$(prefix)include/async/

View file

@ -1,50 +1,42 @@
project('libasync', 'cpp')
cpp_args = []
coro_dep_name = ''
if meson.get_compiler('cpp').has_argument('-fcoroutines')
cpp_args += ['-fcoroutines']
coro_dep_name = 'std_coroutine_dep'
elif meson.get_compiler('cpp').has_argument('-fcoroutines-ts')
cpp_args = ['-fcoroutines-ts', '-DLIBASYNC_FORCE_USE_EXPERIMENTAL']
coro_dep_name = 'clang_coroutine_dep'
else
error('unsupported compiler')
endif
cxxshim_coroutine_dep = subproject('cxxshim').get_variable(coro_dep_name)
frigg_dep = subproject('frigg').get_variable('frigg_dep')
gtest_dep = dependency('gtest', main: true, required: false)
gtest_binary = executable('gtests',
'tests/basic.cpp',
'tests/queue.cpp',
'tests/mutex.cpp',
'tests/race.cpp',
'tests/algorithm.cpp',
'tests/promise.cpp',
'tests/sequenced.cpp',
include_directories: include_directories('include/'),
cpp_args: cpp_args,
dependencies: [
cxxshim_coroutine_dep,
frigg_dep,
gtest_dep
],
override_options: [
'cpp_std=c++2a'
project('libasync', 'cpp',
default_options : [
'cpp_std=c++20'
])
test('gtest test', gtest_binary)
libasync_inc = include_directories('include/')
libasync_dep = declare_dependency(include_directories : libasync_inc)
hotdoc = import('hotdoc')
docs = hotdoc.generate_doc('libasync',
project_version: '0',
sitemap: 'docs/sitemap',
index: 'docs/src/index.md',
extra_assets: [ 'docs/assets/' ],
)
if get_option('install_headers')
install_headers(
'include/async/algorithm.hpp',
'include/async/basic.hpp',
'include/async/cancellation.hpp',
'include/async/execution.hpp',
'include/async/mutex.hpp',
'include/async/oneshot-event.hpp',
'include/async/post-ack.hpp',
'include/async/promise.hpp',
'include/async/queue.hpp',
'include/async/recurring-event.hpp',
'include/async/result.hpp',
'include/async/sequenced-event.hpp',
subdir : 'async/')
endif
run_target('build-doc',
command: [ files('docs/run_hotdoc'), docs.config_path(), ],
)
if get_option('build_tests')
subdir('tests')
endif
if get_option('enable_docs')
hotdoc = import('hotdoc')
docs = hotdoc.generate_doc('libasync',
project_version : '0',
sitemap : 'docs/sitemap',
index : 'docs/src/index.md',
extra_assets : [ 'docs/assets/' ]
)
run_target('build-doc',
command : [ files('docs/run_hotdoc'), docs.config_path() ]
)
endif

3
meson_options.txt Normal file
View file

@ -0,0 +1,3 @@
option('install_headers', type : 'boolean', value : true)
option('build_tests', type : 'boolean', value : false)
option('enable_docs', type : 'boolean', value : false)

33
tests/meson.build Normal file
View file

@ -0,0 +1,33 @@
cpp_args = []
deps = [ libasync_dep ]
if meson.get_compiler('cpp').has_argument('-fcoroutines')
cpp_args += '-fcoroutines'
elif meson.get_compiler('cpp').has_argument('-fcoroutines-ts')
cpp_args += [ '-fcoroutines-ts', '-DLIBASYNC_FORCE_USE_EXPERIMENTAL', '-fsized-deallocation' ]
deps += subproject('cxxshim').get_variable('clang_coroutine_dep')
else
error('Unsupported compiler')
endif
deps += subproject('frigg').get_variable('frigg_dep')
deps += dependency('gtest', main : true)
sources = files(
'basic.cpp',
'queue.cpp',
'mutex.cpp',
'race.cpp',
'algorithm.cpp',
'promise.cpp',
'sequenced.cpp'
)
exe = executable('gtests',
sources,
cpp_args : cpp_args,
dependencies : deps)
test('gtest test', exe)