diff --git a/.github/workflows/build-meson.yml b/.github/workflows/build-meson.yml new file mode 100644 index 00000000..4629d7ad --- /dev/null +++ b/.github/workflows/build-meson.yml @@ -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 diff --git a/README.md b/README.md index b2d04c40..f9c51ee3 100644 --- a/README.md +++ b/README.md @@ -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: @@ -106,6 +107,20 @@ by `CMake` in some cases (see below for further details).
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 diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..76fc1ca3 --- /dev/null +++ b/meson.build @@ -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 diff --git a/subprojects/.gitignore b/subprojects/.gitignore new file mode 100644 index 00000000..9a1d1e46 --- /dev/null +++ b/subprojects/.gitignore @@ -0,0 +1,3 @@ +* +!.gitignore +!*.wrap diff --git a/subprojects/libuv.wrap b/subprojects/libuv.wrap new file mode 100644 index 00000000..f857ffae --- /dev/null +++ b/subprojects/libuv.wrap @@ -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