Skip to content

initial meson move #1226

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

Merged
merged 23 commits into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
566a453
initial meson build
sewnie Nov 13, 2023
87e9ea0
meson: use files() for dunst sources
alebastr Jan 13, 2024
8d2053a
meson: use path seperator
alebastr Jan 13, 2024
c6d8479
meson: make man generation automatic requirement
alebastr Jan 13, 2024
b9ba39c
meson: remove test build option
sewnie Jan 13, 2024
60e8aed
meson: allow debug builds by default
sewnie Jan 13, 2024
655845f
meson: set test workdir for it's data
sewnie Jan 13, 2024
88a4414
meson: set sysconfdir xdg, use dep variable for systemd
sewnie Jan 14, 2024
97b5e77
meson: use dunst.service for systemd service name
sewnie Jan 14, 2024
754dca3
meson: don't consider wayland protos as source
sewnie Jan 25, 2024
d2bd7b6
meson: lower wayland-protos version requirement
sewnie Feb 29, 2024
bb21c8c
meson: make x11 support optional, add summary
sewnie Feb 29, 2024
e972d6f
src/meson: add missing wayland source
sewnie Aug 25, 2024
767c892
meson: add WAYLAND_ONLY and tweak compiler flags
sewnie Aug 25, 2024
ddc0659
test/meson: update run for arg
sewnie Aug 26, 2024
ac91611
meson/test: use env to send testdir info
sewnie Dec 12, 2024
93e0038
meson: update to config.mk
sewnie Jan 30, 2025
9d33d4f
README: add meson build instructions
sewnie Jan 30, 2025
62c70bb
src/meson: move append depends & flags to toplevel meson
sewnie Mar 8, 2025
4add2a9
test/meson: don't build by default
sewnie Mar 8, 2025
61f3e86
meson: change debug check & minor style change
sewnie Mar 8, 2025
71cb3ac
meson: use muon fmt
sewnie Mar 8, 2025
ee5b45b
meson: remove debug flag, set test log env
sewnie Mar 19, 2025
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ core
vgcore.*

/docs/*.1
/docs/dunst.1.pod
/docs/*.5
/docs/internal/coverage
/docs/internal/html
Expand Down
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,10 @@ doc: docs/dunst.1 docs/dunst.5 docs/dunstctl.1 docs/dunstify.1

# Can't dedup this as we need to explicitly provide the name and title text to
# pod2man :(
docs/dunst.1.pod: docs/dunst.1.pod.in
${SED} "s|@sysconfdir@|${SYSCONFDIR}|" $< > $@
docs/dunst.1: docs/dunst.1.pod
${SED} "s|##SYSCONFDIR##|${SYSCONFDIR}|" $< | ${POD2MAN} --name=dunst -c "Dunst Reference" --section=1 --release=${VERSION} > $@
${POD2MAN} --name=dunst -c "Dunst Reference" --section=1 --release=${VERSION} $< > $@
docs/dunst.5: docs/dunst.5.pod
${POD2MAN} --name=dunst -c "Dunst Reference" --section=5 --release=${VERSION} $< > $@
docs/dunstctl.1: docs/dunstctl.pod
Expand All @@ -153,11 +155,11 @@ doc-doxygen:
.PHONY: service service-dbus service-systemd wayland-protocols
service: service-dbus
service-dbus:
@${SED} "s|##PREFIX##|$(PREFIX)|" org.knopwob.dunst.service.in > org.knopwob.dunst.service
@${SED} "s|@bindir@|$(BINDIR)|" org.knopwob.dunst.service.in > org.knopwob.dunst.service
ifneq (0,${SYSTEMD})
service: service-systemd
service-systemd:
@${SED} "s|##PREFIX##|$(PREFIX)|" dunst.systemd.service.in > dunst.systemd.service
@${SED} "s|@bindir@|$(BINDIR)|" dunst.systemd.service.in > dunst.systemd.service
endif

ifneq (0,${WAYLAND})
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,25 @@ The names will be different depending on your [distribution](https://github.com/

### Building

#### Makefile

```
git clone https://github.com/dunst-project/dunst.git
cd dunst
make
sudo make install
```

#### Meson

```
meson setup build
ninja -C build
ninja -C build install
```

Custom Meson build parameters can be found in [meson_options.txt](meson_options.txt).

### Make parameters

- `DESTDIR=<PATH>`: Set the destination directory of the installation. (Default: `/`)
Expand Down
4 changes: 2 additions & 2 deletions docs/dunst.1.pod → docs/dunst.1.pod.in
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Set notification timeout time.

=head1 CONFIGURATION

A default configuration file is included (usually ##SYSCONFDIR##/dunst/dunstrc)
A default configuration file is included (usually @sysconfdir@/dunst/dunstrc)
and serves as the least important configuration file. Note: this was previously
/usr/share/dunst/dunstrc. You can edit this file to change the system-wide
defaults or copy it to a more important location to override its settings. See
Expand Down Expand Up @@ -145,7 +145,7 @@ This is the most important directory. (C<$HOME/.config> if unset or empty)

This, like C<$PATH> for instance, is a :-separated list of base directories
in I<descending order of importance>.
(F<##SYSCONFDIR##> if unset or empty)
(F<@sysconfdir@> if unset or empty)

=back

Expand Down
60 changes: 60 additions & 0 deletions docs/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
man1 = get_option('mandir') / 'man1'
man5 = get_option('mandir') / 'man5'
pod2man_version_arg = '--release=@0@'.format(meson.project_version())

dunst1 = configure_file(
input: 'dunst.1.pod.in',
output: 'dunst.1.pod',
configuration: conf_data,
)

custom_target(
'dunst1_pod2man',
input: dunst1,
output: 'dunst.1',
command: [
pod2man,
'--name=dunst',
'--center=Dunst Reference',
'--section=1',
pod2man_version_arg,
'@INPUT@',
'@OUTPUT@',
],
install: true,
install_dir: man1,
)

custom_target(
'dunst5_pod2man',
input: 'dunst.5.pod',
output: 'dunst.5',
command: [
pod2man,
'--name=dunst',
'--center=Dunst Reference',
'--section=5',
pod2man_version_arg,
'@INPUT@',
'@OUTPUT@',
],
install: true,
install_dir: man5,
)

custom_target(
'dunstctl_pod2man',
input: 'dunstctl.pod',
output: 'dunstctl.1',
command: [
pod2man,
'--name=dunst',
'--center=dunstctl Reference',
'--section=1',
pod2man_version_arg,
'@INPUT@',
'@OUTPUT@',
],
install: true,
install_dir: man1,
)
1 change: 1 addition & 0 deletions dunst.systemd.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ PartOf=graphical-session.target
Type=dbus
BusName=org.freedesktop.Notifications
ExecStart=##PREFIX##/bin/dunst
ExecStart=@bindir@/dunst
Slice=session.slice
126 changes: 126 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
project(
'dunst',
'c',
version: '1.9.2',
license: 'MIT',
meson_version: '>=0.60.0',
default_options: [
'c_std=gnu11',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gnu99 seems to be enough.
also the only divergence from c99 that I can find is the use of variadic macros in our codebase with no extra args

'warning_level=1',
'b_ndebug=if-release',
],
)

cc = meson.get_compiler('c')

cairo = dependency('cairo')
glib = dependency('glib-2.0')
gio = dependency('gio-2.0')
gdk_pixbuf = dependency('gdk-pixbuf-2.0')
pangocairo = dependency('pangocairo')
x11 = dependency('x11', required: get_option('x11'))
xinerama = dependency('xinerama', required: get_option('x11'))
xext = dependency('xext', required: get_option('x11'))
xrandr = dependency('xrandr', required: get_option('x11'), version: '>=1.5')
xscrnsaver = dependency('xscrnsaver', required: get_option('x11'))
systemd = dependency('systemd', required: get_option('systemd'))
libnotify = dependency('libnotify', required: get_option('dunstify'))
realtime = cc.find_library('rt')
math = cc.find_library('m')
wayland_client = dependency('wayland-client', required: get_option('wayland'))
wayland_protos = dependency('wayland-protocols', version: '>=1.12', required: get_option('wayland'))
wayland_cursor = dependency('wayland-cursor', required: get_option('wayland'))

dunst_depends = [
cairo,
glib,
gio,
gdk_pixbuf,
pangocairo,
systemd,
libnotify,
realtime,
math,
]

x11_support = x11.found() and xinerama.found() and xext.found() and xrandr.found() and xscrnsaver.found()
wayland_support = wayland_client.found() and wayland_cursor.found() and wayland_protos.found()

if not x11_support and not wayland_support
error('either wayland or x11 support is required')
endif

if wayland_support and not x11_support
add_project_arguments('-DWAYLAND_ONLY', language: 'c')
endif

if x11_support
dunst_depends += [x11, xinerama, xext, xrandr, xscrnsaver]
add_project_arguments('-DENABLE_X11', language: 'c')
endif

if wayland_support
dunst_depends += [wayland_client, wayland_cursor]
add_project_arguments('-DENABLE_WAYLAND', language: 'c')
endif

c_version_arg = '-DVERSION="@0@"'.format(meson.project_version())
sysconfdir = get_option('sysconfdir') / 'xdg'

add_project_arguments(
'-DSYSCONFDIR="@0@"'.format(get_option('prefix') / sysconfdir),
language: 'c',
)
Comment on lines +70 to +73

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can see for example this was already done here.


subdir('src')

install_data('dunstctl', install_dir: get_option('bindir'))
install_data('dunstrc', install_dir: sysconfdir / 'dunst')

conf_data = configuration_data()
conf_data.set('bindir', get_option('bindir'))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... but forgotten here.

conf_data.set('sysconfdir', sysconfdir)

configure_file(
input: 'org.knopwob.dunst.service.in',
output: 'dunst.service',
configuration: conf_data,
install_dir: get_option('datadir') / 'dbus-1/services',
)

if systemd.found()
user_units_dir = systemd.get_variable(pkgconfig: 'systemduserunitdir')
configure_file(
configuration: conf_data,
input: 'dunst.systemd.service.in',
output: '@BASENAME@',
install_dir: user_units_dir,
)
endif

if libnotify.found()
executable(
'dunstify',
'dunstify.c',
dependencies: [glib, libnotify, gdk_pixbuf],
install: true,
)
endif

subdir('test')

pod2man = find_program('pod2man', native: true, required: get_option('docs'))
if pod2man.found()
subdir('docs')
endif

summary(
{
'X11 support': x11_support,
'Wayland support': wayland_support,
'Man pages': pod2man.found(),
'Dunstify': libnotify.found(),
'Install systemd service units': systemd.found(),
},
bool_yn: true,
)
5 changes: 5 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
option('docs', type: 'feature', value: 'auto', description: 'Generate and install man pages')
option('wayland', type: 'feature', value: 'auto', description: 'Enable wayland support')
option('x11', type: 'feature', value: 'auto', description: 'Enable X11 support')
option('dunstify', type: 'feature', value: 'auto', description: 'Install libnotify dunstify utility')
option('systemd', type: 'feature', value: 'auto', description: 'Install systemd user service unit')
2 changes: 1 addition & 1 deletion org.knopwob.dunst.service.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[D-BUS Service]
Name=org.freedesktop.Notifications
Exec=##PREFIX##/bin/dunst
Exec=@bindir@/dunst
SystemdService=dunst.service
48 changes: 48 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
dunst_src_files = files(
'dbus.c',
'draw.c',
'dunst.c',
'icon-lookup.c',
'icon.c',
'ini.c',
'input.c',
'log.c',
'markup.c',
'menu.c',
'notification.c',
'option_parser.c',
'output.c',
'queues.c',
'rules.c',
'settings.c',
'utils.c',
)

if x11_support
dunst_src_files += files(
'x11/screen.c',
'x11/x.c',
)
endif

if wayland_support
subdir('wayland/protocols')

dunst_src_files += files(
'wayland/foreign_toplevel.c',
'wayland/libgwater-wayland.c',
'wayland/pool-buffer.c',
'wayland/wl.c',
'wayland/wl_output.c',
'wayland/wl_seat.c',
)
endif

executable(
'dunst',
'../main.c',
dunst_src_files,
dependencies: dunst_depends,
c_args: c_version_arg,
install: true,
)
29 changes: 29 additions & 0 deletions src/wayland/protocols/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
wl_protocol_dir = wayland_protos.get_variable(pkgconfig: 'pkgdatadir')

wayland_scanner = dependency('wayland-scanner', version: '>=1.14.91', native: true)
wayland_scanner_path = wayland_scanner.get_variable(pkgconfig: 'wayland_scanner')
wayland_scanner_prog = find_program(wayland_scanner_path, native: true)

wayland_scanner_code = generator(
wayland_scanner_prog,
output: '@[email protected]',
arguments: ['private-code', '@INPUT@', '@OUTPUT@'],
)

wayland_scanner_client = generator(
wayland_scanner_prog,
output: '@[email protected]',
arguments: ['client-header', '@INPUT@', '@OUTPUT@'],
)

client_protocols = [
wl_protocol_dir / 'stable/xdg-shell/xdg-shell.xml',
'wlr-layer-shell-unstable-v1.xml',
'idle.xml',
'wlr-foreign-toplevel-management-unstable-v1.xml',
]

foreach p : client_protocols
wayland_scanner_code.process(p)
wayland_scanner_client.process(p)
endforeach
Loading