2018-08-10 14:37:03 +00:00
|
|
|
project(
|
|
|
|
'waybar', 'cpp', 'c',
|
2024-01-08 16:03:42 +00:00
|
|
|
version: '4.1.0',
|
2018-08-10 14:37:03 +00:00
|
|
|
license: 'MIT',
|
2024-01-08 16:03:42 +00:00
|
|
|
meson_version: '>= 1.3.0',
|
2018-08-30 09:30:20 +00:00
|
|
|
default_options : [
|
2024-01-08 16:03:42 +00:00
|
|
|
'cpp_std=c++23',
|
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
|
|
|
|
2020-02-11 13:38:05 +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
|
|
|
|
2019-05-12 17:53:14 +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']
|
2019-08-09 10:00:52 +00:00
|
|
|
endif
|
2018-08-08 21:54:58 +00:00
|
|
|
|
2019-08-09 10:00:52 +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()
|
2020-06-24 13:06:30 +00:00
|
|
|
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')
|
2019-05-12 17:53:14 +00:00
|
|
|
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
|
|
|
|
|
2020-02-05 19:02:42 +00:00
|
|
|
code = '''
|
|
|
|
#include <langinfo.h>
|
|
|
|
#include <locale.h>
|
2020-02-04 00:58:18 +00:00
|
|
|
int main(int argc, char** argv) {
|
2020-02-05 19:02:42 +00:00
|
|
|
locale_t locale = newlocale(LC_ALL, "en_US.UTF-8", nullptr);
|
2020-02-04 00:58:18 +00:00
|
|
|
char* str;
|
2020-02-05 19:02:42 +00:00
|
|
|
str = nl_langinfo_l(_NL_TIME_WEEK_1STDAY, locale);
|
|
|
|
str = nl_langinfo_l(_NL_TIME_FIRST_WEEKDAY, locale);
|
|
|
|
freelocale(locale);
|
2020-02-04 00:58:18 +00:00
|
|
|
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')
|
|
|
|
|
2019-08-09 09:52:16 +00:00
|
|
|
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'
|
2019-08-09 09:52:16 +00:00
|
|
|
|
2024-01-08 16:03:42 +00:00
|
|
|
jsoncpp = dependency('jsoncpp', version : ['>=1.9.4'], fallback : ['jsoncpp', 'jsoncpp_dep'])
|
2018-08-08 21:54:58 +00:00
|
|
|
wayland_client = dependency('wayland-client')
|
|
|
|
wayland_cursor = dependency('wayland-cursor')
|
|
|
|
wayland_protos = dependency('wayland-protocols')
|
2024-01-08 16:03:42 +00:00
|
|
|
sigcpp = dependency('sigc++-3.0', version: ['>=3.4.0'])
|
|
|
|
gtkmm = dependency('gtkmm-4.0', version : ['>=4.12.0'])
|
|
|
|
giounix = dependency('gio-unix-2.0', version: ['>=2.76.4'])
|
|
|
|
spdlog = dependency('spdlog', version : ['>=1.10.0'], fallback : ['spdlog', 'spdlog_dep'], default_options : ['external_fmt=enabled'])
|
2023-01-17 01:30:06 +00:00
|
|
|
|
2024-01-08 16:03:42 +00:00
|
|
|
gtk_layer_shell = dependency('gtk4-layer-shell-0',
|
|
|
|
version : ['>=1.0.2'],
|
|
|
|
fallback : ['gtk4-layer-shell', 'gtk_layer_shell'],
|
2024-01-14 18:25:37 +00:00
|
|
|
default_options : ['introspection=false', 'vapi=false'])
|
2023-11-10 14:57:26 +00:00
|
|
|
|
2024-02-22 20:24:10 +00:00
|
|
|
cpp_lib_chrono = compiler.compute_int('__cpp_lib_chrono', prefix : '#include <chrono>')
|
|
|
|
have_chrono_timezones = cpp_lib_chrono >= 201611
|
|
|
|
|
|
|
|
if have_chrono_timezones
|
|
|
|
code = '''
|
|
|
|
#include <chrono>
|
|
|
|
using namespace std::chrono;
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
const time_zone* tz;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
'''
|
|
|
|
if not compiler.links(code)
|
|
|
|
have_chrono_timezones = false
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
if have_chrono_timezones
|
|
|
|
tz_dep = declare_dependency()
|
|
|
|
else
|
|
|
|
tz_dep = dependency('date',
|
|
|
|
required: false,
|
|
|
|
default_options : [ 'use_system_tzdb=true' ],
|
|
|
|
modules : [ 'date::date', 'date::date-tz' ],
|
|
|
|
fallback: [ 'date', 'tz_dep' ])
|
|
|
|
endif
|
|
|
|
|
2019-09-10 12:12:52 +00:00
|
|
|
prefix = get_option('prefix')
|
build: drop -Dout in favor of --prefix
$ meson --prefix=/tmp/foo _build
$ ninja install -C _build
[49/50] Installing files.
Installing waybar to /tmp/foo/bin
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 127, in run
return options.run_func(options)
File "/usr/lib/python3.6/site-packages/mesonbuild/minstall.py", line 514, in run
installer.do_install(datafilename)
File "/usr/lib/python3.6/site-packages/mesonbuild/minstall.py", line 346, in do_install
self.install_data(d)
File "/usr/lib/python3.6/site-packages/mesonbuild/minstall.py", line 375, in install_data
d.dirmaker.makedirs(outdir, exist_ok=True)
File "/usr/lib/python3.6/site-packages/mesonbuild/minstall.py", line 55, in makedirs
os.makedirs(path, exist_ok=exist_ok)
File "/usr/lib/python3.6/os.py", line 210, in makedirs
makedirs(head, mode, exist_ok)
File "/usr/lib/python3.6/os.py", line 220, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/etc/xdg'
FAILED: meson-install
2019-08-11 10:09:55 +00:00
|
|
|
sysconfdir = get_option('sysconfdir')
|
2019-09-08 12:04:34 +00:00
|
|
|
conf_data = configuration_data()
|
2019-09-10 12:12:52 +00:00
|
|
|
conf_data.set('prefix', prefix)
|
2019-09-08 12:04:34 +00:00
|
|
|
|
build: drop -Dout in favor of --prefix
$ meson --prefix=/tmp/foo _build
$ ninja install -C _build
[49/50] Installing files.
Installing waybar to /tmp/foo/bin
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 127, in run
return options.run_func(options)
File "/usr/lib/python3.6/site-packages/mesonbuild/minstall.py", line 514, in run
installer.do_install(datafilename)
File "/usr/lib/python3.6/site-packages/mesonbuild/minstall.py", line 346, in do_install
self.install_data(d)
File "/usr/lib/python3.6/site-packages/mesonbuild/minstall.py", line 375, in install_data
d.dirmaker.makedirs(outdir, exist_ok=True)
File "/usr/lib/python3.6/site-packages/mesonbuild/minstall.py", line 55, in makedirs
os.makedirs(path, exist_ok=exist_ok)
File "/usr/lib/python3.6/os.py", line 210, in makedirs
makedirs(head, mode, exist_ok)
File "/usr/lib/python3.6/os.py", line 220, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/etc/xdg'
FAILED: meson-install
2019-08-11 10:09:55 +00:00
|
|
|
add_project_arguments('-DSYSCONFDIR="/@0@"'.format(join_paths(prefix, sysconfdir)), language : 'cpp')
|
|
|
|
|
2018-08-20 15:20:02 +00:00
|
|
|
src_files = files(
|
2024-01-08 16:03:42 +00:00
|
|
|
'src/main.cpp',
|
|
|
|
'src/client.cpp',
|
|
|
|
'src/bar.cpp',
|
|
|
|
'src/config.cpp',
|
|
|
|
'src/util/portal.cpp',
|
|
|
|
'src/util/prepare_for_sleep.cpp',
|
2024-02-22 18:06:41 +00:00
|
|
|
'src/AModule.cpp',
|
2024-02-22 20:24:10 +00:00
|
|
|
'src/ALabel.cpp',
|
|
|
|
'src/factory.cpp',
|
2024-02-24 17:32:14 +00:00
|
|
|
'src/util/ustring_clen.cpp',
|
|
|
|
'src/group.cpp'
|
2024-02-22 20:24:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
man_files = files(
|
|
|
|
'man/waybar-custom.5.scd',
|
|
|
|
'man/waybar-disk.5.scd',
|
|
|
|
'man/waybar-idle-inhibitor.5.scd',
|
|
|
|
'man/waybar-image.5.scd',
|
|
|
|
'man/waybar-states.5.scd',
|
|
|
|
'man/waybar-temperature.5.scd',
|
2018-08-20 15:20:02 +00:00
|
|
|
)
|
2018-08-08 21:54:58 +00:00
|
|
|
|
2024-02-22 20:24:10 +00:00
|
|
|
if have_chrono_timezones
|
|
|
|
add_project_arguments('-DHAVE_CHRONO_TIMEZONES', language: 'cpp')
|
|
|
|
src_files += files('src/modules/clock.cpp')
|
|
|
|
man_files += files('man/waybar-clock.5.scd')
|
|
|
|
elif tz_dep.found()
|
|
|
|
add_project_arguments('-DHAVE_LIBDATE', language: 'cpp')
|
|
|
|
src_files += files('src/modules/clock.cpp')
|
|
|
|
man_files += files('man/waybar-clock.5.scd')
|
|
|
|
else
|
|
|
|
src_files += files('src/modules/simpleclock.cpp')
|
|
|
|
man_files += files('man/waybar-clock.5.scd')
|
|
|
|
endif
|
|
|
|
|
2024-02-26 19:18:29 +00:00
|
|
|
if get_option('experimental')
|
|
|
|
add_project_arguments('-DUSE_EXPERIMENTAL', language: 'cpp')
|
|
|
|
endif
|
|
|
|
|
|
|
|
cava = dependency('cava',
|
|
|
|
version : '>=0.10.1',
|
|
|
|
required: get_option('cava'),
|
|
|
|
fallback : ['cava', 'cava_dep'],
|
|
|
|
not_found_message: 'cava is not found. Building waybar without cava')
|
|
|
|
|
|
|
|
if cava.found()
|
|
|
|
add_project_arguments('-DHAVE_LIBCAVA', language: 'cpp')
|
|
|
|
src_files += files('src/modules/cava.cpp')
|
|
|
|
man_files += files('man/waybar-cava.5.scd')
|
|
|
|
endif
|
|
|
|
|
2023-04-14 23:36:15 +00:00
|
|
|
inc_dirs = ['include']
|
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',
|
2024-01-08 16:03:42 +00:00
|
|
|
[src_files],
|
2018-08-08 21:54:58 +00:00
|
|
|
dependencies: [
|
2024-01-08 16:03:42 +00:00
|
|
|
gtk_layer_shell,
|
|
|
|
gtkmm,
|
|
|
|
giounix,
|
2018-08-08 21:54:58 +00:00
|
|
|
sigcpp,
|
|
|
|
jsoncpp,
|
2024-01-08 16:03:42 +00:00
|
|
|
wayland_client,
|
2018-08-08 21:54:58 +00:00
|
|
|
wayland_cursor,
|
2024-01-08 16:03:42 +00:00
|
|
|
client_protos,
|
2024-02-26 19:18:29 +00:00
|
|
|
spdlog,
|
|
|
|
cava
|
2018-08-08 21:54:58 +00:00
|
|
|
],
|
2023-04-14 23:36:15 +00:00
|
|
|
include_directories: inc_dirs,
|
2018-08-08 21:54:58 +00:00
|
|
|
install: true,
|
|
|
|
)
|
2018-08-09 15:02:30 +00:00
|
|
|
|
|
|
|
install_data(
|
|
|
|
'./resources/config',
|
|
|
|
'./resources/style.css',
|
build: drop -Dout in favor of --prefix
$ meson --prefix=/tmp/foo _build
$ ninja install -C _build
[49/50] Installing files.
Installing waybar to /tmp/foo/bin
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/mesonbuild/mesonmain.py", line 127, in run
return options.run_func(options)
File "/usr/lib/python3.6/site-packages/mesonbuild/minstall.py", line 514, in run
installer.do_install(datafilename)
File "/usr/lib/python3.6/site-packages/mesonbuild/minstall.py", line 346, in do_install
self.install_data(d)
File "/usr/lib/python3.6/site-packages/mesonbuild/minstall.py", line 375, in install_data
d.dirmaker.makedirs(outdir, exist_ok=True)
File "/usr/lib/python3.6/site-packages/mesonbuild/minstall.py", line 55, in makedirs
os.makedirs(path, exist_ok=exist_ok)
File "/usr/lib/python3.6/os.py", line 210, in makedirs
makedirs(head, mode, exist_ok)
File "/usr/lib/python3.6/os.py", line 220, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/etc/xdg'
FAILED: meson-install
2019-08-11 10:09:55 +00:00
|
|
|
install_dir: sysconfdir + '/xdg/waybar'
|
2018-08-09 15:02:30 +00:00
|
|
|
)
|