Skip to content
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

build: add initial meson support #306

Merged
merged 7 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ exist a valid `libuv` wrapper in C++. That's all.
To be able to use `uvw`, users must provide the following system-wide tools:

* A full-featured compiler that supports at least C++17.
* `libuv` (which version depends on the tag of `uvw` in use).
* `libuv` (which version depends on the tag of `uvw` in use)
* If you use `meson`, libuv will be downloaded for you

The requirements below are mandatory to compile the tests and to extract the
documentation:
Expand All @@ -106,6 +107,17 @@ by `CMake` in some cases (see below for further details).<br/>
Because of that, users don't have to install it to run the tests or when `uvw`
libraries are compiled through `CMake`.

## Meson

You can use `uvw` with [meson](https://mesonbuild.com/) by simply adding it to your `subprojects` directory in your project. Currently, `uvw` is not available with `meson wrap`, but this will change with the release of `uvw` 3.2.1.
brenfwd marked this conversation as resolved.
Show resolved Hide resolved
brenfwd marked this conversation as resolved.
Show resolved Hide resolved

To compile `uvw` from source without using it as a subproject, in the `uvw` source directory, run:

* `$ meson setup build`
* If you want a static library, add `--default-library=static`
* `$ cd build`
* `$ meson compile`

## Library

`uvw` is a dual-mode library. It can be used in its header-only form or as a
Expand Down
53 changes: 53 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
project(
'uvw',
'cpp',
version: '3.3.0',
license: 'MIT',
default_options: ['cpp_std=c++17'],
)

libuv_dep = dependency('libuv', version: '1.46.0')

sources = [
'src/uvw/async.cpp',
'src/uvw/check.cpp',
'src/uvw/dns.cpp',
'src/uvw/emitter.cpp',
'src/uvw/fs.cpp',
'src/uvw/fs_event.cpp',
'src/uvw/fs_poll.cpp',
'src/uvw/idle.cpp',
'src/uvw/lib.cpp',
'src/uvw/loop.cpp',
'src/uvw/pipe.cpp',
'src/uvw/poll.cpp',
'src/uvw/prepare.cpp',
'src/uvw/process.cpp',
'src/uvw/signal.cpp',
'src/uvw/stream.cpp',
'src/uvw/tcp.cpp',
'src/uvw/thread.cpp',
'src/uvw/timer.cpp',
'src/uvw/tty.cpp',
'src/uvw/udp.cpp',
'src/uvw/util.cpp',
'src/uvw/work.cpp',
]

uvw_lib = library(
'uvw', sources,
include_directories: 'src',
dependencies: [libuv_dep],
cpp_args: ['-DUVW_AS_LIB'],
install: true,
)

uvw_dep = declare_dependency(
include_directories: ['src'],
dependencies: [libuv_dep],
link_with: [uvw_lib],
)

if meson.version().version_compare('>=0.54.0')
meson.override_dependency('uvw', uvw_dep)
endif
3 changes: 3 additions & 0 deletions subprojects/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!.gitignore
!*.wrap
13 changes: 13 additions & 0 deletions subprojects/libuv.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[wrap-file]
directory = libuv-v1.46.0
source_url = https://dist.libuv.org/dist/v1.46.0/libuv-v1.46.0.tar.gz
source_filename = libuv-v1.46.0.tar.gz
source_hash = 111f83958b9fdc65f1489195d25f342b9f7a3e683140c60e62c00fbaccddddce
patch_filename = libuv_1.46.0-1_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/libuv_1.46.0-1/get_patch
patch_hash = 41b1834129f13efcb4a94a137335eb85fe0662509010c157617954d2feb20ac8
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/libuv_1.46.0-1/libuv-v1.46.0.tar.gz
wrapdb_version = 1.46.0-1

[provide]
libuv = libuv_dep