commit da03b6d

sewn  ·  2026-02-28 21:57:49 +0000 UTC
parent 10c9dd9
switch to meson
9 files changed,  +144, -80
+6, -8
 1@@ -1,16 +1,14 @@
 2-wld
 3+newwld
 4 ===
 5-wld is a drawing library that targets Wayland. The [swc Wayland compositor
 6+neuwld is a drawing library that targets Wayland. The [swc Wayland compositor
 7 library](https://github.com/michaelforney/swc) uses wld.
 8 
 9 Installing
10 ==========
11-To build and install wld, simply use:
12+To build and install neuwld, simply use:
13 
14 ```Bash
15-make
16-make install
17+muon setup build
18+ninja -C build
19+muon -C build install
20 ```
21-
22-Various flags may be set in config.mk. You will likely want to compile
23-using only intel or noveau, not both.
+0, -11
 1@@ -1,11 +0,0 @@
 2-# wld: common.mk
 3-
 4-.deps/$(dir): | .deps
 5-	@mkdir "$@"
 6-
 7-$(dir)/%.o: $(dir)/%.c | .deps/$(dir)
 8-	$(compile) $(WLD_PACKAGE_CFLAGS)
 9-
10-$(dir)/%.lo: $(dir)/%.c | .deps/$(dir)
11-	$(compile) $(WLD_PACKAGE_CFLAGS) -fPIC
12-
+0, -19
 1@@ -1,19 +0,0 @@
 2-# wld: config.mk (BSD make)
 3-
 4-CC=gcc
 5-CFLAGS=-pipe
 6-
 7-ENABLE_DEBUG=1
 8-ENABLE_STATIC=1
 9-ENABLE_SHARED=1
10-
11-ENABLE_PIXMAN=1
12-ENABLE_DRM=1
13-ENABLE_WAYLAND=1
14-
15-DRM_DRIVERS=intel nouveau
16-WAYLAND_INTERFACES=shm
17-
18-.if ${ENABLE_DRM} == 1
19-WAYLAND_INTERFACES+= drm
20-.endif
+0, -6
1@@ -1,6 +0,0 @@
2-# wld: intel/local.mk
3-
4-dir := intel
5-
6-include common.mk
7-
+133, -0
  1@@ -0,0 +1,133 @@
  2+project('wld', 'c',
  3+  version: '0.0',
  4+  meson_version: '>=1.1',
  5+  license: 'MIT',
  6+  default_options: [
  7+    # C11: libdrm uses anonymous union extension
  8+    # C23: nouveau.c uses empty initializer extension
  9+    'c_std=c23',
 10+    'warning_level=3',
 11+    'default_library=static',
 12+    'b_ndebug=if-release',
 13+  ],
 14+)
 15+
 16+cc = meson.get_compiler('c')
 17+pkg = import('pkgconfig')
 18+
 19+c_args = cc.get_supported_arguments([
 20+  '-fvisibility=hidden',
 21+  '-Wvla',
 22+  '-Werror=implicit-function-declaration',
 23+  '-Werror=implicit-int',
 24+  '-Werror=pointer-sign',
 25+  '-Werror=pointer-arith',
 26+
 27+  '-Wno-sign-compare', # pixman.c:630
 28+  '-Wno-gnu-empty-struct', # ARRAY_LENGTH
 29+  '-Wno-gnu-statement-expression-from-macro-expansion', # CONTAINER_OF
 30+  '-Wno-gnu-zero-variadic-macro-arguments', # wld-private.h:57
 31+  '-Wno-static-in-inline', # context.c:unwrap_buffer
 32+  '-Wno-unused-parameter', # pixman.c
 33+  '-Wno-zero-length-array', # libdrm/i915_drm.h:2472
 34+  '-Wno-varargs', # nouveau.c:332
 35+  '-Wno-excess-initializers', # wayland.c:121
 36+]) + [
 37+  '-D_POSIX_C_SOURCE=200809L', '-D_NETBSD_SOURCE',
 38+  get_option('buildtype') == 'debug' ? '-DENABLE_DEBUG=1' : [],
 39+]
 40+
 41+requires = [
 42+  dependency('fontconfig'),
 43+  dependency('pixman-1'),
 44+]
 45+requires_private = [
 46+  dependency('freetype2'),
 47+]
 48+
 49+libwld_src = files(
 50+  'buffer.c',
 51+  'buffered_surface.c',
 52+  'color.c',
 53+  'context.c',
 54+  'font.c',
 55+  'renderer.c',
 56+  'surface.c',
 57+  'pixman.c',
 58+)
 59+
 60+wayland = dependency('wayland-client', required: get_option('wayland'))
 61+if wayland.found()
 62+  libwld_src += ['wayland.c', 'wayland-shm.c']
 63+  c_args += '-DWITH_WAYLAND_SHM=1'
 64+  requires_private += wayland
 65+endif
 66+
 67+drm = dependency('libdrm', required: get_option('drm'))
 68+if drm.found()
 69+  libwld_src += ['drm.c', 'dumb.c']  
 70+  requires_private += drm
 71+
 72+  drivers = get_option('drivers')
 73+  foreach driver, src : {
 74+    'nouveau': ['nouveau.c'],
 75+    'intel': ['intel.c', 'intel/batch.c'],
 76+  }
 77+    if not drivers.contains('auto') and not drivers.contains(driver)
 78+      continue
 79+    endif
 80+    dep = dependency('libdrm_' + driver, required: drivers.contains(driver))
 81+    if dep.found()
 82+      libwld_src += src
 83+      c_args += '-DWITH_DRM_@0@=1'.format(driver)
 84+      requires_private += dep
 85+    endif
 86+  endforeach
 87+endif
 88+
 89+if wayland.found() and drm.found()
 90+  libwld_src += 'wayland-drm.c'
 91+  c_args += '-DWITH_WAYLAND_DRM=1'
 92+
 93+  protocols = import('wayland').scan_xml(
 94+    files('protocol/wayland-drm.xml'),
 95+    public: false,
 96+    client: true,
 97+  )
 98+  libwld_src += [ protocols[0], protocols[1] ]
 99+endif
100+
101+install_headers([
102+  'wld.h', 'pixman.h',
103+  drm.found() ? 'drm.h' : [],
104+  wayland.found() ? 'wayland.h' : [],
105+], subdir: 'wld')
106+
107+libwld_lib = library(
108+	'wld',
109+	libwld_src,
110+	dependencies: requires + requires_private,
111+	c_args: c_args,
112+	# Prevents clashing with wld pixman.h
113+	implicit_include_directories: false,
114+	install: true,
115+)
116+
117+# Allows other meson projects to use libwld
118+libwld = declare_dependency(
119+	link_with: libwld_lib,
120+	dependencies: requires + requires_private,
121+)
122+
123+pkg.generate(
124+  libwld_lib,
125+  name: 'wld',
126+  description: 'A primitive drawing library library targeted at Wayland',
127+  requires: requires,
128+  requires_private: requires_private,
129+)
130+
131+doxygen = find_program('doxygen', required: get_option('doxygen'))
132+if doxygen.found()
133+  run_target('doxygen', command: [doxygen])
134+endif
+4, -0
1@@ -0,0 +1,4 @@
2+option('wayland', type: 'feature', value: 'auto', description: 'Wayland frontend')
3+option('drm', type: 'feature', value: 'auto', description: 'Enable libdrm backend')
4+option('drivers', type: 'array', choices: ['auto', 'intel', 'nouveau'], value: ['auto'], description: 'libdrm drivers')
5+option('doxygen', type: 'feature', value: 'auto', description: 'Build documentation')
+0, -22
 1@@ -1,22 +0,0 @@
 2-# wld: protocol/local.mk
 3-
 4-dir := protocol
 5-
 6-PROTOCOL_EXTENSIONS = $(dir)/wayland-drm.xml
 7-
 8-# GNUMake correctly marks %-protocol.c as an intermediate file, and deletes it
 9-# after the build. The file can be preserved by marking it as precious.
10-.PRECIOUS: $(dir)/%-protocol.c
11-
12-$(dir)/%-protocol.c: $(dir)/%.xml
13-	$(call quiet,GEN,$(WAYLAND_SCANNER)) private-code < $< > $@
14-
15-$(dir)/%-client-protocol.h: $(dir)/%.xml
16-	$(call quiet,GEN,$(WAYLAND_SCANNER)) client-header < $< > $@
17-
18-CLEAN_FILES +=                                          \
19-    $(PROTOCOL_EXTENSIONS:%.xml=%-protocol.c)           \
20-    $(PROTOCOL_EXTENSIONS:%.xml=%-client-protocol.h)
21-
22-include common.mk
23-
+1, -1
1@@ -23,7 +23,7 @@
2 
3 #include "drm-private.h"
4 #include "drm.h"
5-#include "protocol/wayland-drm-client-protocol.h"
6+#include "wayland-drm-client-protocol.h"
7 #include "wayland-private.h"
8 #include "wayland.h"
9 #include "wld-private.h"
+0, -13
 1@@ -1,13 +0,0 @@
 2-prefix=@PREFIX@
 3-libdir=@LIBDIR@
 4-includedir=@INCLUDEDIR@
 5-
 6-Name: wld
 7-Description: A primitive drawing library library targeted at Wayland
 8-Version: @VERSION@
 9-Cflags: -I${includedir}
10-Libs: -L${libdir} -lwld
11-
12-Requires: @WLD_REQUIRES@
13-Requires.private: @WLD_REQUIRES_PRIVATE@
14-