Waybar/meson.build

403 lines
12 KiB
Meson
Raw Normal View History

2018-08-10 14:37:03 +00:00
project(
'waybar', 'cpp', 'c',
2022-03-06 13:54:48 +00:00
version: '0.9.10',
2018-08-10 14:37:03 +00:00
license: 'MIT',
meson_version: '>= 0.49.0',
2018-08-30 09:30:20 +00:00
default_options : [
'cpp_std=c++17',
2018-11-08 08:57:24 +00:00
'buildtype=release',
'default_library=static'
2018-08-30 09:30:20 +00:00
],
2018-08-10 14:37:03 +00:00
)
2018-08-08 21:54:58 +00:00
compiler = meson.get_compiler('cpp')
2018-12-26 10:13:36 +00:00
cpp_args = []
2018-08-19 11:41:22 +00:00
cpp_link_args = []
2018-08-08 21:54:58 +00:00
if get_option('libcxx')
2018-08-08 21:54:58 +00:00
cpp_args += ['-stdlib=libc++']
cpp_link_args += ['-stdlib=libc++', '-lc++abi']
endif
2018-08-08 21:54:58 +00:00
if compiler.has_link_argument('-lc++fs')
cpp_link_args += ['-lc++fs']
elif compiler.has_link_argument('-lc++experimental')
cpp_link_args += ['-lc++experimental']
elif compiler.has_link_argument('-lstdc++fs')
2018-08-08 21:54:58 +00:00
cpp_link_args += ['-lstdc++fs']
endif
2020-04-05 14:12:25 +00:00
git = find_program('git', native: true, required: false)
2018-12-26 10:13:36 +00:00
if not git.found()
add_project_arguments('-DVERSION="@0@"'.format(meson.project_version()), language: 'cpp')
else
2020-05-24 17:14:27 +00:00
git_path = run_command([git.path(), 'rev-parse', '--show-toplevel']).stdout().strip()
if meson.source_root() == git_path
git_commit_hash = run_command([git.path(), 'describe', '--always', '--tags']).stdout().strip()
git_branch = run_command([git.path(), 'rev-parse', '--abbrev-ref', 'HEAD']).stdout().strip()
version = '"@0@ (branch \'@1@\')"'.format(git_commit_hash, git_branch)
2020-05-24 17:14:27 +00:00
add_project_arguments('-DVERSION=@0@'.format(version), language: 'cpp')
else
add_project_arguments('-DVERSION="@0@"'.format(meson.project_version()), language: 'cpp')
endif
2018-12-26 10:13:36 +00:00
endif
2018-11-08 08:57:24 +00:00
if not compiler.has_header('filesystem')
if compiler.has_header('experimental/filesystem')
add_project_arguments('-DFILESYSTEM_EXPERIMENTAL', language: 'cpp')
else
add_project_arguments('-DNO_FILESYSTEM', language: 'cpp')
warning('No filesystem header found, some modules may not work')
endif
2018-11-08 08:57:24 +00:00
endif
code = '''
#include <langinfo.h>
#include <locale.h>
int main(int argc, char** argv) {
locale_t locale = newlocale(LC_ALL, "en_US.UTF-8", nullptr);
char* str;
str = nl_langinfo_l(_NL_TIME_WEEK_1STDAY, locale);
str = nl_langinfo_l(_NL_TIME_FIRST_WEEKDAY, locale);
freelocale(locale);
return 0;
}
'''
if compiler.links(code, name : 'nl_langinfo with _NL_TIME_WEEK_1STDAY, _NL_TIME_FIRST_WEEKDAY')
add_project_arguments('-DHAVE_LANGINFO_1STDAY', language: 'cpp')
endif
2018-08-08 21:54:58 +00:00
add_global_arguments(cpp_args, language : 'cpp')
add_global_link_arguments(cpp_link_args, language : 'cpp')
is_linux = host_machine.system() == 'linux'
2019-08-09 10:40:33 +00:00
is_dragonfly = host_machine.system() == 'dragonfly'
is_freebsd = host_machine.system() == 'freebsd'
is_netbsd = host_machine.system() == 'netbsd'
is_openbsd = host_machine.system() == 'openbsd'
2018-08-08 21:54:58 +00:00
thread_dep = dependency('threads')
fmt = dependency('fmt', version : ['>=7.0.0'], fallback : ['fmt', 'fmt_dep'])
2021-04-30 12:25:48 +00:00
spdlog = dependency('spdlog', version : ['>=1.8.5'], fallback : ['spdlog', 'spdlog_dep'], default_options : ['external_fmt=true'])
2018-08-08 21:54:58 +00:00
wayland_client = dependency('wayland-client')
wayland_cursor = dependency('wayland-cursor')
wayland_protos = dependency('wayland-protocols')
gtkmm = dependency('gtkmm-3.0', version : ['>=3.22.0'])
2018-10-25 09:47:03 +00:00
dbusmenu_gtk = dependency('dbusmenu-gtk3-0.4', required: get_option('dbusmenu-gtk'))
giounix = dependency('gio-unix-2.0', required: (get_option('dbusmenu-gtk').enabled() or get_option('logind').enabled()))
2018-08-08 21:54:58 +00:00
jsoncpp = dependency('jsoncpp')
sigcpp = dependency('sigc++-2.0')
libepoll = dependency('epoll-shim', required: false)
2018-10-21 09:58:35 +00:00
libnl = dependency('libnl-3.0', required: get_option('libnl'))
libnlgen = dependency('libnl-genl-3.0', required: get_option('libnl'))
libpulse = dependency('libpulse', required: get_option('pulseaudio'))
libudev = dependency('libudev', required: get_option('libudev'))
2021-02-07 20:05:11 +00:00
libevdev = dependency('libevdev', required: get_option('libevdev'))
2019-04-16 14:34:37 +00:00
libmpdclient = dependency('libmpdclient', required: get_option('mpd'))
2021-07-13 01:33:12 +00:00
xkbregistry = dependency('xkbregistry')
libsndio = compiler.find_library('sndio', required: get_option('sndio'))
if libsndio.found()
if not compiler.has_function('sioctl_open', prefix: '#include <sndio.h>', dependencies: libsndio)
if get_option('sndio').enabled()
error('libsndio is too old, required >=1.7.0')
else
warning('libsndio is too old, required >=1.7.0')
libsndio = dependency('', required: false)
endif
endif
endif
gtk_layer_shell = dependency('gtk-layer-shell-0',
required: get_option('gtk-layer-shell'),
fallback : ['gtk-layer-shell', 'gtk_layer_shell_dep'])
systemd = dependency('systemd', required: get_option('systemd'))
tz_dep = dependency('date',
required: false,
default_options : [ 'use_system_tzdb=true' ],
modules : [ 'date::date', 'date::date-tz' ],
fallback: [ 'date', 'tz_dep' ])
2019-09-10 12:12:52 +00:00
prefix = get_option('prefix')
sysconfdir = get_option('sysconfdir')
conf_data = configuration_data()
2019-09-10 12:12:52 +00:00
conf_data.set('prefix', prefix)
add_project_arguments('-DSYSCONFDIR="/@0@"'.format(join_paths(prefix, sysconfdir)), language : 'cpp')
if systemd.found()
user_units_dir = systemd.get_pkgconfig_variable('systemduserunitdir')
configure_file(
configuration: conf_data,
input: './resources/waybar.service.in',
output: '@BASENAME@',
install_dir: user_units_dir
)
endif
2018-08-08 21:54:58 +00:00
2018-08-20 15:20:02 +00:00
src_files = files(
'src/factory.cpp',
2019-06-15 12:57:52 +00:00
'src/AModule.cpp',
2018-08-20 15:20:02 +00:00
'src/ALabel.cpp',
'src/AIconLabel.cpp',
2018-08-20 15:20:02 +00:00
'src/modules/custom.cpp',
2019-09-23 20:25:54 +00:00
'src/modules/disk.cpp',
2019-08-22 16:04:09 +00:00
'src/modules/idle_inhibitor.cpp',
2019-03-13 12:18:08 +00:00
'src/modules/temperature.cpp',
2018-08-20 15:20:02 +00:00
'src/main.cpp',
'src/bar.cpp',
2020-01-21 16:48:45 +00:00
'src/client.cpp',
'src/config.cpp',
2021-10-31 22:55:13 +00:00
'src/group.cpp',
'src/util/ustring_clen.cpp'
2018-08-20 15:20:02 +00:00
)
2018-08-08 21:54:58 +00:00
if is_linux
2019-08-11 13:10:37 +00:00
add_project_arguments('-DHAVE_CPU_LINUX', language: 'cpp')
2019-08-09 10:40:33 +00:00
add_project_arguments('-DHAVE_MEMORY_LINUX', language: 'cpp')
src_files += files(
'src/modules/battery.cpp',
2019-08-11 13:10:37 +00:00
'src/modules/cpu/common.cpp',
'src/modules/cpu/linux.cpp',
2019-08-09 10:40:33 +00:00
'src/modules/memory/common.cpp',
'src/modules/memory/linux.cpp',
)
elif is_dragonfly or is_freebsd or is_netbsd or is_openbsd
2019-08-11 13:10:37 +00:00
add_project_arguments('-DHAVE_CPU_BSD', language: 'cpp')
2019-08-09 10:40:33 +00:00
add_project_arguments('-DHAVE_MEMORY_BSD', language: 'cpp')
src_files += files(
2019-08-11 13:10:37 +00:00
'src/modules/cpu/bsd.cpp',
'src/modules/cpu/common.cpp',
2019-08-09 10:40:33 +00:00
'src/modules/memory/bsd.cpp',
'src/modules/memory/common.cpp',
)
endif
2020-06-24 11:28:27 +00:00
add_project_arguments('-DHAVE_SWAY', language: 'cpp')
src_files += [
'src/modules/sway/ipc/client.cpp',
'src/modules/sway/bar.cpp',
2020-06-24 11:28:27 +00:00
'src/modules/sway/mode.cpp',
'src/modules/sway/language.cpp',
2020-06-24 11:28:27 +00:00
'src/modules/sway/window.cpp',
'src/modules/sway/workspaces.cpp'
]
2018-08-20 15:20:02 +00:00
if true
add_project_arguments('-DHAVE_WLR', language: 'cpp')
src_files += 'src/modules/wlr/taskbar.cpp'
2020-08-05 20:10:08 +00:00
src_files += 'src/modules/wlr/workspace_manager.cpp'
src_files += 'src/modules/wlr/workspace_manager_binding.cpp'
endif
2020-06-06 13:41:37 +00:00
if true
add_project_arguments('-DHAVE_RIVER', language: 'cpp')
src_files += 'src/modules/river/tags.cpp'
endif
2018-08-20 15:20:02 +00:00
if libnl.found() and libnlgen.found()
add_project_arguments('-DHAVE_LIBNL', language: 'cpp')
src_files += 'src/modules/network.cpp'
endif
if libpulse.found()
add_project_arguments('-DHAVE_LIBPULSE', language: 'cpp')
src_files += 'src/modules/pulseaudio.cpp'
endif
2018-10-25 09:47:03 +00:00
if dbusmenu_gtk.found()
add_project_arguments('-DHAVE_DBUSMENU', language: 'cpp')
src_files += files(
'src/modules/sni/tray.cpp',
2018-11-22 14:47:23 +00:00
'src/modules/sni/watcher.cpp',
'src/modules/sni/host.cpp',
'src/modules/sni/item.cpp'
2018-10-25 09:47:03 +00:00
)
endif
if libudev.found() and (is_linux or libepoll.found())
add_project_arguments('-DHAVE_LIBUDEV', language: 'cpp')
src_files += 'src/modules/backlight.cpp'
endif
2021-02-07 20:05:11 +00:00
if libevdev.found() and (is_linux or libepoll.found())
add_project_arguments('-DHAVE_LIBEVDEV', language: 'cpp')
src_files += 'src/modules/keyboard_state.cpp'
endif
2019-04-16 14:34:37 +00:00
if libmpdclient.found()
add_project_arguments('-DHAVE_LIBMPDCLIENT', language: 'cpp')
src_files += 'src/modules/mpd/mpd.cpp'
src_files += 'src/modules/mpd/state.cpp'
2019-04-16 14:34:37 +00:00
endif
if gtk_layer_shell.found()
add_project_arguments('-DHAVE_GTK_LAYER_SHELL', language: 'cpp')
endif
if libsndio.found()
add_project_arguments('-DHAVE_LIBSNDIO', language: 'cpp')
src_files += 'src/modules/sndio.cpp'
endif
if (giounix.found() and not get_option('logind').disabled())
add_project_arguments('-DHAVE_GIO_UNIX', language: 'cpp')
src_files += 'src/modules/inhibitor.cpp'
endif
2020-08-14 18:56:45 +00:00
if get_option('rfkill').enabled()
if is_linux
add_project_arguments('-DWANT_RFKILL', language: 'cpp')
src_files += files(
'src/modules/bluetooth.cpp',
'src/util/rfkill.cpp'
)
endif
endif
if tz_dep.found()
add_project_arguments('-DHAVE_LIBDATE', language: 'cpp')
src_files += 'src/modules/clock.cpp'
else
src_files += 'src/modules/simpleclock.cpp'
endif
2021-11-27 22:12:35 +00:00
if get_option('experimental')
add_project_arguments('-DUSE_EXPERIMENTAL', language: 'cpp')
endif
2018-08-20 15:20:02 +00:00
subdir('protocol')
2018-08-16 12:29:41 +00:00
2018-08-08 21:54:58 +00:00
executable(
'waybar',
2018-08-16 12:29:41 +00:00
src_files,
2018-08-08 21:54:58 +00:00
dependencies: [
thread_dep,
client_protos,
wayland_client,
fmt,
2019-05-18 23:44:45 +00:00
spdlog,
2018-08-08 21:54:58 +00:00
sigcpp,
jsoncpp,
wayland_cursor,
gtkmm,
2018-10-04 16:03:01 +00:00
dbusmenu_gtk,
2018-10-27 06:19:58 +00:00
giounix,
2018-08-09 14:38:24 +00:00
libnl,
libnlgen,
libpulse,
2019-04-16 14:34:37 +00:00
libudev,
libepoll,
libmpdclient,
2021-02-07 20:05:11 +00:00
libevdev,
gtk_layer_shell,
libsndio,
2021-07-13 01:33:12 +00:00
tz_dep,
2022-01-04 07:53:59 +00:00
xkbregistry
2018-08-08 21:54:58 +00:00
],
include_directories: [include_directories('include')],
install: true,
)
2018-08-09 15:02:30 +00:00
install_data(
'./resources/config',
'./resources/style.css',
install_dir: sysconfdir + '/xdg/waybar'
2018-08-09 15:02:30 +00:00
)
2018-08-16 12:29:41 +00:00
scdoc = dependency('scdoc', version: '>=1.9.2', native: true, required: get_option('man-pages'))
2019-08-22 16:04:09 +00:00
if scdoc.found()
scdoc_prog = find_program(scdoc.get_pkgconfig_variable('scdoc'), native: true)
sh = find_program('sh', native: true)
main_manpage = configure_file(
input: 'man/waybar.5.scd.in',
output: 'waybar.5.scd',
configuration: {
'sysconfdir': join_paths(prefix, sysconfdir)
}
)
main_manpage_path = join_paths(meson.build_root(), '@0@'.format(main_manpage))
2019-08-22 16:04:09 +00:00
mandir = get_option('mandir')
man_files = [
main_manpage_path,
2019-08-24 14:39:46 +00:00
'waybar-backlight.5.scd',
2019-08-24 16:44:29 +00:00
'waybar-battery.5.scd',
2019-08-26 12:31:57 +00:00
'waybar-clock.5.scd',
2019-08-26 12:23:11 +00:00
'waybar-cpu.5.scd',
2019-08-26 12:42:59 +00:00
'waybar-custom.5.scd',
2019-09-25 07:07:46 +00:00
'waybar-disk.5.scd',
2019-08-26 14:06:20 +00:00
'waybar-idle-inhibitor.5.scd',
2021-04-15 21:41:15 +00:00
'waybar-keyboard-state.5.scd',
2019-08-26 14:12:42 +00:00
'waybar-memory.5.scd',
2019-08-26 14:23:07 +00:00
'waybar-mpd.5.scd',
2019-08-26 16:42:30 +00:00
'waybar-network.5.scd',
2019-08-26 16:50:16 +00:00
'waybar-pulseaudio.5.scd',
2020-06-06 13:41:37 +00:00
'waybar-river-tags.5.scd',
'waybar-sway-language.5.scd',
2019-08-26 16:55:20 +00:00
'waybar-sway-mode.5.scd',
2019-08-26 17:00:46 +00:00
'waybar-sway-window.5.scd',
2019-08-26 17:08:06 +00:00
'waybar-sway-workspaces.5.scd',
2019-08-26 17:13:48 +00:00
'waybar-temperature.5.scd',
2019-08-26 17:15:58 +00:00
'waybar-tray.5.scd',
2019-08-26 21:49:04 +00:00
'waybar-states.5.scd',
'waybar-wlr-taskbar.5.scd',
2020-08-07 21:09:35 +00:00
'waybar-wlr-workspaces.5.scd',
2020-04-28 15:40:44 +00:00
'waybar-bluetooth.5.scd',
'waybar-sndio.5.scd',
2019-08-22 16:04:09 +00:00
]
2021-12-14 07:15:44 +00:00
if (giounix.found() and not get_option('logind').disabled())
man_files += 'waybar-inhibitor.5.scd'
endif
foreach file : man_files
path = '@0@'.format(file)
basename = path.split('/')[-1]
topic = basename.split('.')[-3]
section = basename.split('.')[-2]
2019-08-22 16:04:09 +00:00
output = '@0@.@1@'.format(topic, section)
custom_target(
output,
# drops the 'man' if `path` is an absolute path
input: join_paths('man', path),
2019-08-22 16:04:09 +00:00
output: output,
command: [
sh, '-c', '@0@ < @INPUT@ > @1@'.format(scdoc_prog.path(), output)
],
install: true,
install_dir: '@0@/man@1@'.format(mandir, section)
)
endforeach
endif
2021-08-14 01:33:24 +00:00
catch2 = dependency(
'catch2',
fallback: ['catch2', 'catch2_dep'],
required: get_option('tests'),
)
if catch2.found()
subdir('test')
endif
2018-08-16 12:29:41 +00:00
clangtidy = find_program('clang-tidy', required: false)
if clangtidy.found()
run_target(
'tidy',
command: [
clangtidy,
'-checks=*,-fuchsia-default-arguments',
'-p', meson.build_root()
] + src_files)
endif
2021-11-27 22:12:35 +00:00