2020-07-06 12:37:41 +02:00
|
|
|
project('power-profiles-daemon', [ 'c' ],
|
2024-04-04 01:49:01 +02:00
|
|
|
version: '0.21',
|
2020-07-06 12:37:41 +02:00
|
|
|
license: 'GPLv3+',
|
|
|
|
default_options: [
|
|
|
|
'buildtype=debugoptimized',
|
|
|
|
'warning_level=1',
|
|
|
|
'c_std=c99',
|
|
|
|
],
|
2024-02-14 00:34:29 +01:00
|
|
|
meson_version: '>= 0.59.0')
|
2020-07-06 12:37:41 +02:00
|
|
|
|
|
|
|
cc = meson.get_compiler('c')
|
|
|
|
|
|
|
|
common_cflags = cc.get_supported_arguments([
|
|
|
|
'-fgnu89-inline',
|
|
|
|
'-Wundef',
|
|
|
|
'-Wunused',
|
|
|
|
'-Wstrict-prototypes',
|
|
|
|
'-Werror-implicit-function-declaration',
|
|
|
|
'-Wno-pointer-sign',
|
2024-02-02 16:00:03 +01:00
|
|
|
'-Wshadow',
|
|
|
|
'-Wno-sign-compare',
|
|
|
|
'-Wno-cast-function-type',
|
|
|
|
'-Wno-unused-parameter',
|
|
|
|
'-Wno-missing-field-initializers',
|
|
|
|
'-Wno-type-limits',
|
2020-07-06 12:37:41 +02:00
|
|
|
])
|
|
|
|
|
2020-08-07 11:23:06 +02:00
|
|
|
prefix = get_option('prefix')
|
|
|
|
libexecdir = prefix / get_option('libexecdir')
|
2020-07-06 12:37:41 +02:00
|
|
|
bindir = get_option('bindir')
|
2022-06-28 15:30:54 +02:00
|
|
|
dbusconfdir = get_option('datadir') / 'dbus-1' / 'system.d'
|
2020-08-10 11:16:43 +02:00
|
|
|
dbusservicedir = get_option('datadir') / 'dbus-1' / 'system-services'
|
2020-07-06 12:37:41 +02:00
|
|
|
|
|
|
|
systemd_system_unit_dir = get_option('systemdsystemunitdir')
|
|
|
|
if systemd_system_unit_dir == 'auto'
|
|
|
|
systemd_dep = dependency('systemd')
|
2024-02-13 18:43:38 +01:00
|
|
|
systemd_system_unit_dir = systemd_dep.get_variable('systemdsystemunitdir')
|
2020-07-06 12:37:41 +02:00
|
|
|
endif
|
2024-02-14 04:23:44 +01:00
|
|
|
glib_dep = dependency('glib-2.0')
|
2024-02-14 22:16:00 +01:00
|
|
|
gio_unix_dep = dependency('gio-unix-2.0')
|
2020-07-06 12:37:41 +02:00
|
|
|
gio_dep = dependency('gio-2.0')
|
2020-09-15 10:29:56 +02:00
|
|
|
gudev_dep = dependency('gudev-1.0', version: '>= 234')
|
2020-09-03 12:16:15 +02:00
|
|
|
upower_dep = dependency('upower-glib')
|
2024-02-15 06:10:18 +01:00
|
|
|
polkit_gobject_dep = dependency('polkit-gobject-1', version: '>= 0.99')
|
2024-02-13 18:43:38 +01:00
|
|
|
polkit_policy_directory = polkit_gobject_dep.get_variable('policydir')
|
2020-07-06 12:37:41 +02:00
|
|
|
|
2024-04-03 21:01:46 +02:00
|
|
|
python3_required_modules = []
|
|
|
|
gi_required_modules = {}
|
|
|
|
|
|
|
|
powerprofilesctl_required_gi_modules = {
|
|
|
|
'GLib': '2.0',
|
|
|
|
'Gio': '2.0',
|
|
|
|
}
|
|
|
|
|
2020-07-06 12:37:41 +02:00
|
|
|
gnome = import('gnome')
|
|
|
|
|
|
|
|
add_global_arguments('-D_GNU_SOURCE=1', language: 'c')
|
2021-04-08 12:48:23 +02:00
|
|
|
add_global_arguments(common_cflags, language: 'c')
|
2020-07-06 12:37:41 +02:00
|
|
|
|
2024-02-15 05:53:27 +01:00
|
|
|
pylint = find_program('pylint-3', 'pylint3', 'pylint', required: get_option('pylint'))
|
|
|
|
if pylint.found()
|
2022-06-23 17:28:51 +02:00
|
|
|
nomalloc = environment({'MALLOC_PERTURB_': '0'})
|
2021-11-08 15:39:07 +01:00
|
|
|
pylint_flags = ['-d', 'C0116', '-d', 'C0114', '-d', 'W0707', '-d', 'W0706' ]
|
2021-10-06 10:22:10 +02:00
|
|
|
endif
|
2021-09-28 12:55:59 +02:00
|
|
|
xmllint = find_program('xmllint', required: false)
|
2021-03-12 08:59:38 +01:00
|
|
|
|
2024-02-15 04:05:37 +01:00
|
|
|
argparse_manpage = find_program('argparse-manpage', required: get_option('manpage'))
|
2024-04-03 21:01:46 +02:00
|
|
|
if argparse_manpage.found()
|
|
|
|
gi_required_modules += powerprofilesctl_required_gi_modules
|
|
|
|
endif
|
2024-02-15 04:05:37 +01:00
|
|
|
|
2024-02-13 20:28:22 +01:00
|
|
|
bus_names = {
|
|
|
|
'org.freedesktop.UPower.PowerProfiles': '/org/freedesktop/UPower/PowerProfiles',
|
|
|
|
'net.hadess.PowerProfiles': '/net/hadess/PowerProfiles',
|
|
|
|
}
|
|
|
|
|
2024-02-14 03:33:55 +01:00
|
|
|
address_sanitizer = get_option('b_sanitize') == 'address' or \
|
|
|
|
get_option('b_sanitize') == 'address,undefined' or \
|
|
|
|
get_option('b_sanitize') == 'leak'
|
|
|
|
|
2024-04-03 21:01:46 +02:00
|
|
|
bashcomp = dependency('bash-completion', required: get_option('bashcomp'))
|
|
|
|
zshcomp = get_option('zshcomp') != ''
|
|
|
|
|
2024-02-15 05:39:55 +01:00
|
|
|
python = import('python')
|
|
|
|
python3 = python.find_installation('python3')
|
|
|
|
|
2024-04-03 21:01:46 +02:00
|
|
|
if bashcomp.found() or zshcomp
|
|
|
|
python3_required_modules += 'shtab'
|
|
|
|
gi_required_modules += powerprofilesctl_required_gi_modules
|
2024-02-15 05:39:55 +01:00
|
|
|
endif
|
|
|
|
|
2024-04-03 21:01:46 +02:00
|
|
|
if get_option('tests')
|
|
|
|
python3_required_modules += [
|
|
|
|
'dbusmock',
|
|
|
|
]
|
|
|
|
gi_required_modules += powerprofilesctl_required_gi_modules
|
|
|
|
gi_required_modules += {
|
|
|
|
'UMockdev': '1.0',
|
|
|
|
}
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Python 3 required modules
|
|
|
|
if gi_required_modules.keys().length() > 0
|
|
|
|
python3_required_modules += 'gi'
|
|
|
|
endif
|
|
|
|
|
|
|
|
foreach p : python3_required_modules
|
|
|
|
# Source: https://docs.python.org/3/library/importlib.html#checking-if-a-module-can-be-imported
|
|
|
|
script = 'import importlib.util; import sys; exit(1) if importlib.util.find_spec(\''+ p +'\') is None else exit(0)'
|
|
|
|
if run_command(python3, '-c', script, check: false).returncode() == 0
|
|
|
|
message('Python3 module \'@0@\' found: YES'.format(p))
|
|
|
|
else
|
2024-04-04 01:33:38 +02:00
|
|
|
error('Python3 module \'@0@\' required but not found'.format(p))
|
2024-04-03 21:01:46 +02:00
|
|
|
endif
|
|
|
|
endforeach
|
|
|
|
|
|
|
|
foreach module, version : gi_required_modules
|
|
|
|
script = 'import gi; gi.require_version("@0@", "@1@")'.format(module, version)
|
|
|
|
if run_command(python3, '-c', script, check: false).returncode() == 0
|
|
|
|
message('Python3 module \'@0@\' found: YES @1@'.format(module, version))
|
|
|
|
else
|
2024-04-04 01:33:38 +02:00
|
|
|
error('''GObject Introspection module '@0@' version @1@ required but not found'''.format(
|
2024-04-03 21:01:46 +02:00
|
|
|
module, version))
|
|
|
|
endif
|
|
|
|
endforeach
|
2024-02-15 05:39:55 +01:00
|
|
|
|
2020-07-06 12:37:41 +02:00
|
|
|
subdir('src')
|
|
|
|
subdir('data')
|
|
|
|
|
|
|
|
if get_option('gtk_doc')
|
|
|
|
# Make COPYING available in the build root for docs
|
|
|
|
configure_file(
|
|
|
|
input: 'COPYING',
|
|
|
|
output: 'COPYING',
|
|
|
|
copy: true,
|
|
|
|
)
|
|
|
|
subdir('docs')
|
|
|
|
endif
|
2020-07-16 16:09:56 +02:00
|
|
|
|
2022-06-28 15:36:03 +02:00
|
|
|
if get_option('tests')
|
|
|
|
subdir('tests')
|
|
|
|
endif
|
2021-04-01 10:30:12 +02:00
|
|
|
|
|
|
|
meson.add_dist_script(
|
2024-02-13 18:43:38 +01:00
|
|
|
find_program('check-news.sh').full_path(),
|
2021-04-01 10:30:12 +02:00
|
|
|
'@0@'.format(meson.project_version())
|
|
|
|
)
|
2024-02-15 05:49:35 +01:00
|
|
|
|
|
|
|
summary({
|
|
|
|
'tests': get_option('tests'),
|
|
|
|
'bash-completion': bashcomp,
|
|
|
|
'zsh-completion': zshcomp,
|
|
|
|
'manpages': argparse_manpage.found(),
|
|
|
|
'python linting': pylint.found(),
|
|
|
|
'gtk_doc': get_option('gtk_doc'),
|
|
|
|
})
|