Skip to content
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

initial meson move #1226

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -9,6 +9,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 @@ -132,8 +132,10 @@ doc: docs/dunst.1 docs/dunst.5 docs/dunstctl.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}|" $< > $@
fwsmit marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -145,11 +147,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
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 @@ -59,7 +59,7 @@ Display a notification on startup.

=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 @@ -112,7 +112,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,
)
2 changes: 1 addition & 1 deletion dunst.systemd.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ PartOf=graphical-session.target
[Service]
Type=dbus
BusName=org.freedesktop.Notifications
ExecStart=##PREFIX##/bin/dunst
ExecStart=@bindir@/dunst
109 changes: 109 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
project(
'dunst',
'c',
version: '1.9.2',
license: 'MIT',
meson_version: '>=0.60.0',
default_options: [
'c_std=gnu99',
zappolowski marked this conversation as resolved.
Show resolved Hide resolved
'warning_level=1',
'b_ndebug=if-release',
],
)

add_project_arguments([
'-Wno-maybe-uninitialized',
], language: 'c')

if get_option('buildtype').startswith('debug')
add_project_arguments('-DDEBUG_BUILD', language: 'c')
endif

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'))
zappolowski marked this conversation as resolved.
Show resolved Hide resolved
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'))

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

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'
)

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'))
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
74 changes: 74 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
dunst_depends = [
cairo,
glib,
gio,
gdk_pixbuf,
pangocairo,
systemd,
libnotify,
realtime,
math,
]

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
add_global_arguments('-DENABLE_X11', language: 'c')

dunst_depends += [
x11,
xinerama,
xext,
xrandr,
xscrnsaver,
]
dunst_src_files += files(
'x11/screen.c',
'x11/x.c',
)
endif

if wayland_support
add_global_arguments('-DENABLE_WAYLAND', language: 'c')

subdir('wayland/protocols')

dunst_depends += [
wayland_client, wayland_cursor,
]
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: '@BASENAME@.h',
arguments: ['private-code', '@INPUT@', '@OUTPUT@'],
)

wayland_scanner_client = generator(
wayland_scanner_prog,
output: '@BASENAME@-client-header.h',
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
41 changes: 41 additions & 0 deletions test/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
test_src_files = [
'dbus.c',
'draw.c',
'dunst.c',
'helpers.c',
'icon-lookup.c',
'icon.c',
'ini.c',
'input.c',
'log.c',
'markup.c',
'menu.c',
'misc.c',
'notification.c',
'option_parser.c',
'queues.c',
'rules.c',
'setting.c',
'settings_data.c',
'test.c',
'utils.c',
]

fs = import('fs')
foreach dunst_src_file : dunst_src_files
if fs.name(dunst_src_file) not in test_src_files
test_src_files += dunst_src_file
endif
endforeach

test_prog = executable('test-runner',
test_src_files,
dependencies: dunst_depends,
c_args: c_version_arg,
install: false,
)

test('Run tests',
test_prog,
args: meson.current_source_dir(),
)