Skip to content

Commit

Permalink
build: add initial meson support (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
brenfwd authored Feb 8, 2024
1 parent a497837 commit ba10b27
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 1 deletion.
25 changes: 25 additions & 0 deletions .github/workflows/build-meson.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: build-meson

on: [push, pull_request]

jobs:
meson:
timeout-minutes: 60
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Install Meson
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get update --fix-missing
sudo apt-get install -y meson
- name: Meson Build (shared)
run: |
meson setup build
meson compile -C build
- name: Meson Build (static)
run: |
rm -rf build/
meson setup build --default-library=static
meson compile -C build
17 changes: 16 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,20 @@ 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.4.x.
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

0 comments on commit ba10b27

Please sign in to comment.