neuwld

patched neuwld library (tracked)
git clone https://git.daat.foo/neuwld.git
Log | Files | Refs | README | LICENSE

commit da03b6d9cd93083a7dfe5dac3d20603ae26815a7
parent 10c9dd9acae668be7786327b12fd22e7304f3fc6
Author: sewn <sewn@disroot.org>
Date:   Sun,  1 Mar 2026 00:57:49 +0300

switch to meson

Diffstat:
MREADME.md | 14++++++--------
Dcommon.mk | 11-----------
Dconfig.mk | 19-------------------
Dintel/local.mk | 6------
Ameson.build | 133+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ameson.options | 4++++
Dprotocol/local.mk | 22----------------------
Mwayland-drm.c | 2+-
Dwld.pc.in | 13-------------
9 files changed, 144 insertions(+), 80 deletions(-)

diff --git a/README.md b/README.md @@ -1,16 +1,14 @@ -wld +newwld === -wld is a drawing library that targets Wayland. The [swc Wayland compositor +neuwld is a drawing library that targets Wayland. The [swc Wayland compositor library](https://github.com/michaelforney/swc) uses wld. Installing ========== -To build and install wld, simply use: +To build and install neuwld, simply use: ```Bash -make -make install +muon setup build +ninja -C build +muon -C build install ``` - -Various flags may be set in config.mk. You will likely want to compile -using only intel or noveau, not both. diff --git a/common.mk b/common.mk @@ -1,11 +0,0 @@ -# wld: common.mk - -.deps/$(dir): | .deps - @mkdir "$@" - -$(dir)/%.o: $(dir)/%.c | .deps/$(dir) - $(compile) $(WLD_PACKAGE_CFLAGS) - -$(dir)/%.lo: $(dir)/%.c | .deps/$(dir) - $(compile) $(WLD_PACKAGE_CFLAGS) -fPIC - diff --git a/config.mk b/config.mk @@ -1,19 +0,0 @@ -# wld: config.mk (BSD make) - -CC=gcc -CFLAGS=-pipe - -ENABLE_DEBUG=1 -ENABLE_STATIC=1 -ENABLE_SHARED=1 - -ENABLE_PIXMAN=1 -ENABLE_DRM=1 -ENABLE_WAYLAND=1 - -DRM_DRIVERS=intel nouveau -WAYLAND_INTERFACES=shm - -.if ${ENABLE_DRM} == 1 -WAYLAND_INTERFACES+= drm -.endif diff --git a/intel/local.mk b/intel/local.mk @@ -1,6 +0,0 @@ -# wld: intel/local.mk - -dir := intel - -include common.mk - diff --git a/meson.build b/meson.build @@ -0,0 +1,133 @@ +project('wld', 'c', + version: '0.0', + meson_version: '>=1.1', + license: 'MIT', + default_options: [ + # C11: libdrm uses anonymous union extension + # C23: nouveau.c uses empty initializer extension + 'c_std=c23', + 'warning_level=3', + 'default_library=static', + 'b_ndebug=if-release', + ], +) + +cc = meson.get_compiler('c') +pkg = import('pkgconfig') + +c_args = cc.get_supported_arguments([ + '-fvisibility=hidden', + '-Wvla', + '-Werror=implicit-function-declaration', + '-Werror=implicit-int', + '-Werror=pointer-sign', + '-Werror=pointer-arith', + + '-Wno-sign-compare', # pixman.c:630 + '-Wno-gnu-empty-struct', # ARRAY_LENGTH + '-Wno-gnu-statement-expression-from-macro-expansion', # CONTAINER_OF + '-Wno-gnu-zero-variadic-macro-arguments', # wld-private.h:57 + '-Wno-static-in-inline', # context.c:unwrap_buffer + '-Wno-unused-parameter', # pixman.c + '-Wno-zero-length-array', # libdrm/i915_drm.h:2472 + '-Wno-varargs', # nouveau.c:332 + '-Wno-excess-initializers', # wayland.c:121 +]) + [ + '-D_POSIX_C_SOURCE=200809L', '-D_NETBSD_SOURCE', + get_option('buildtype') == 'debug' ? '-DENABLE_DEBUG=1' : [], +] + +requires = [ + dependency('fontconfig'), + dependency('pixman-1'), +] +requires_private = [ + dependency('freetype2'), +] + +libwld_src = files( + 'buffer.c', + 'buffered_surface.c', + 'color.c', + 'context.c', + 'font.c', + 'renderer.c', + 'surface.c', + 'pixman.c', +) + +wayland = dependency('wayland-client', required: get_option('wayland')) +if wayland.found() + libwld_src += ['wayland.c', 'wayland-shm.c'] + c_args += '-DWITH_WAYLAND_SHM=1' + requires_private += wayland +endif + +drm = dependency('libdrm', required: get_option('drm')) +if drm.found() + libwld_src += ['drm.c', 'dumb.c'] + requires_private += drm + + drivers = get_option('drivers') + foreach driver, src : { + 'nouveau': ['nouveau.c'], + 'intel': ['intel.c', 'intel/batch.c'], + } + if not drivers.contains('auto') and not drivers.contains(driver) + continue + endif + dep = dependency('libdrm_' + driver, required: drivers.contains(driver)) + if dep.found() + libwld_src += src + c_args += '-DWITH_DRM_@0@=1'.format(driver) + requires_private += dep + endif + endforeach +endif + +if wayland.found() and drm.found() + libwld_src += 'wayland-drm.c' + c_args += '-DWITH_WAYLAND_DRM=1' + + protocols = import('wayland').scan_xml( + files('protocol/wayland-drm.xml'), + public: false, + client: true, + ) + libwld_src += [ protocols[0], protocols[1] ] +endif + +install_headers([ + 'wld.h', 'pixman.h', + drm.found() ? 'drm.h' : [], + wayland.found() ? 'wayland.h' : [], +], subdir: 'wld') + +libwld_lib = library( + 'wld', + libwld_src, + dependencies: requires + requires_private, + c_args: c_args, + # Prevents clashing with wld pixman.h + implicit_include_directories: false, + install: true, +) + +# Allows other meson projects to use libwld +libwld = declare_dependency( + link_with: libwld_lib, + dependencies: requires + requires_private, +) + +pkg.generate( + libwld_lib, + name: 'wld', + description: 'A primitive drawing library library targeted at Wayland', + requires: requires, + requires_private: requires_private, +) + +doxygen = find_program('doxygen', required: get_option('doxygen')) +if doxygen.found() + run_target('doxygen', command: [doxygen]) +endif diff --git a/meson.options b/meson.options @@ -0,0 +1,4 @@ +option('wayland', type: 'feature', value: 'auto', description: 'Wayland frontend') +option('drm', type: 'feature', value: 'auto', description: 'Enable libdrm backend') +option('drivers', type: 'array', choices: ['auto', 'intel', 'nouveau'], value: ['auto'], description: 'libdrm drivers') +option('doxygen', type: 'feature', value: 'auto', description: 'Build documentation') diff --git a/protocol/local.mk b/protocol/local.mk @@ -1,22 +0,0 @@ -# wld: protocol/local.mk - -dir := protocol - -PROTOCOL_EXTENSIONS = $(dir)/wayland-drm.xml - -# GNUMake correctly marks %-protocol.c as an intermediate file, and deletes it -# after the build. The file can be preserved by marking it as precious. -.PRECIOUS: $(dir)/%-protocol.c - -$(dir)/%-protocol.c: $(dir)/%.xml - $(call quiet,GEN,$(WAYLAND_SCANNER)) private-code < $< > $@ - -$(dir)/%-client-protocol.h: $(dir)/%.xml - $(call quiet,GEN,$(WAYLAND_SCANNER)) client-header < $< > $@ - -CLEAN_FILES += \ - $(PROTOCOL_EXTENSIONS:%.xml=%-protocol.c) \ - $(PROTOCOL_EXTENSIONS:%.xml=%-client-protocol.h) - -include common.mk - diff --git a/wayland-drm.c b/wayland-drm.c @@ -23,7 +23,7 @@ #include "drm-private.h" #include "drm.h" -#include "protocol/wayland-drm-client-protocol.h" +#include "wayland-drm-client-protocol.h" #include "wayland-private.h" #include "wayland.h" #include "wld-private.h" diff --git a/wld.pc.in b/wld.pc.in @@ -1,13 +0,0 @@ -prefix=@PREFIX@ -libdir=@LIBDIR@ -includedir=@INCLUDEDIR@ - -Name: wld -Description: A primitive drawing library library targeted at Wayland -Version: @VERSION@ -Cflags: -I${includedir} -Libs: -L${libdir} -lwld - -Requires: @WLD_REQUIRES@ -Requires.private: @WLD_REQUIRES_PRIVATE@ -