mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
treewide: only define feature macros when the feature is available
Most feature checks already use #ifdef, and do not care about
the value of the macro. Convert all feature checks to do that,
and simplify the meson build scripts by replacing
if cond
cdata.set('X', 1)
endif
with
cdata.set('X', cond)
This commit is contained in:
parent
140378efd6
commit
15e7a61aa7
15 changed files with 49 additions and 83 deletions
68
meson.build
68
meson.build
|
|
@ -218,38 +218,29 @@ check_headers = [
|
|||
]
|
||||
|
||||
foreach h : check_headers
|
||||
if cc.has_header(h.get(0))
|
||||
cdata.set(h.get(1), 1)
|
||||
endif
|
||||
cdata.set(h.get(1), cc.has_header(h.get(0)))
|
||||
endforeach
|
||||
|
||||
if cc.has_function('gettid', prefix : '#include<unistd.h>', args: [ '-D_GNU_SOURCE' ])
|
||||
cdata.set('HAVE_GETTID', 1)
|
||||
endif
|
||||
check_functions = [
|
||||
['gettid', '#include <unistd.h>', ['-D_GNU_SOURCE']],
|
||||
['memfd_create', '#include <sys/mman.h>', ['-D_GNU_SOURCE']],
|
||||
['getrandom', '#include <stddef.h>\n#include <sys/random.h>', ['-D_GNU_SOURCE']],
|
||||
['sigabbrev_np', '#include <string.h>', ['-D_GNU_SOURCE']],
|
||||
]
|
||||
|
||||
if cc.has_function('memfd_create', prefix : '#include <sys/mman.h>', args : [ '-D_GNU_SOURCE' ])
|
||||
cdata.set('HAVE_MEMFD_CREATE', 1)
|
||||
endif
|
||||
foreach f : check_functions
|
||||
cdata.set('HAVE_' + f.get(0).to_upper(),
|
||||
cc.has_function(f.get(0), prefix: f.get(1), args: f.get(2)))
|
||||
endforeach
|
||||
|
||||
if cc.has_function('getrandom', prefix : '#include <stddef.h>\n#include <sys/random.h>', args : [ '-D_GNU_SOURCE' ])
|
||||
cdata.set('HAVE_GETRANDOM', 1)
|
||||
endif
|
||||
|
||||
if cc.has_function('sigabbrev_np', prefix : '#include <string.h>', args : [ '-D_GNU_SOURCE' ])
|
||||
cdata.set('HAVE_SIGABBREV_NP', 1)
|
||||
endif
|
||||
|
||||
if cc.get_define('SYS_pidfd_open', prefix : '#include <sys/syscall.h>') != ''
|
||||
cdata.set('HAVE_PIDFD_OPEN', 1)
|
||||
endif
|
||||
cdata.set('HAVE_PIDFD_OPEN',
|
||||
cc.get_define('SYS_pidfd_open', prefix: '#include <sys/syscall.h>') != '')
|
||||
|
||||
systemd = dependency('systemd', required: get_option('systemd'))
|
||||
systemd_dep = dependency('libsystemd',required: get_option('systemd'))
|
||||
summary({'systemd conf data': systemd.found()}, bool_yn: true)
|
||||
summary({'libsystemd': systemd_dep.found()}, bool_yn: true)
|
||||
if systemd.found() and systemd_dep.found()
|
||||
cdata.set('HAVE_SYSTEMD', 1)
|
||||
endif
|
||||
cdata.set('HAVE_SYSTEMD', systemd.found() and systemd_dep.found())
|
||||
|
||||
configinc = include_directories('.')
|
||||
includes_inc = include_directories('include')
|
||||
|
|
@ -276,9 +267,7 @@ dl_lib = cc.find_library('dl', required : false)
|
|||
pthread_lib = dependency('threads')
|
||||
dbus_dep = dependency('dbus-1', required : get_option('dbus'))
|
||||
summary({'dbus (Bluetooth, rt, portal, pw-reserve)': dbus_dep.found()}, bool_yn: true, section: 'Misc dependencies')
|
||||
if dbus_dep.found()
|
||||
cdata.set('HAVE_DBUS', 1)
|
||||
endif
|
||||
cdata.set('HAVE_DBUS', dbus_dep.found())
|
||||
sdl_dep = dependency('sdl2', required : get_option('sdl2'))
|
||||
summary({'SDL2 (video examples)': sdl_dep.found()}, bool_yn: true, section: 'Misc dependencies')
|
||||
drm_dep = dependency('libdrm', required : false)
|
||||
|
|
@ -292,9 +281,7 @@ summary({'readline (for pw-cli)': readline_dep.found()}, bool_yn: true, section:
|
|||
ncurses_dep = dependency('ncursesw', required : false)
|
||||
sndfile_dep = dependency('sndfile', version : '>= 1.0.20', required : get_option('sndfile'))
|
||||
summary({'sndfile': sndfile_dep.found()}, bool_yn: true, section: 'pw-cat/pw-play/pw-dump/filter-chain')
|
||||
if sndfile_dep.found()
|
||||
cdata.set('HAVE_SNDFILE', 1)
|
||||
endif
|
||||
cdata.set('HAVE_SNDFILE', sndfile_dep.found())
|
||||
pulseaudio_dep = dependency('libpulse', required : get_option('libpulse'))
|
||||
summary({'libpulse': pulseaudio_dep.found()}, bool_yn: true, section: 'Streaming between daemons')
|
||||
avahi_dep = dependency('avahi-client', required : get_option('avahi'))
|
||||
|
|
@ -311,14 +298,10 @@ summary({'libcanberra (x11-bell)': canberra_dep.found()}, bool_yn: true,
|
|||
|
||||
libusb_dep = dependency('libusb-1.0', required : get_option('libusb'))
|
||||
summary({'libusb (Bluetooth quirks)': libusb_dep.found()}, bool_yn: true, section: 'Backend')
|
||||
if libusb_dep.found()
|
||||
cdata.set('HAVE_LIBUSB', 1)
|
||||
endif
|
||||
cdata.set('HAVE_LIBUSB', libusb_dep.found())
|
||||
|
||||
cap_lib = dependency('libcap', required : false)
|
||||
if cap_lib.found()
|
||||
cdata.set('HAVE_LIBCAP', 1)
|
||||
endif
|
||||
cdata.set('HAVE_LIBCAP', cap_lib.found())
|
||||
|
||||
gst_option = get_option('gstreamer')
|
||||
gst_deps_def = {
|
||||
|
|
@ -353,18 +336,13 @@ endforeach
|
|||
gst_dp_found = gst_dep.length() > 0
|
||||
summary({'gstreamer-device-provider': gst_dp_found}, bool_yn: true, section: 'Backend')
|
||||
|
||||
if not get_option('gstreamer-device-provider').disabled()
|
||||
cdata.set('HAVE_GSTREAMER_DEVICE_PROVIDER', 1)
|
||||
endif
|
||||
cdata.set('HAVE_GSTREAMER_DEVICE_PROVIDER', not get_option('gstreamer-device-provider').disabled())
|
||||
|
||||
webrtc_dep = dependency('webrtc-audio-processing',
|
||||
version : ['>= 0.2', '< 1.0'],
|
||||
required : get_option('echo-cancel-webrtc'))
|
||||
summary({'WebRTC Echo Canceling': webrtc_dep.found()}, bool_yn: true, section: 'Misc dependencies')
|
||||
|
||||
if webrtc_dep.found()
|
||||
cdata.set('HAVE_WEBRTC', 1)
|
||||
endif
|
||||
cdata.set('HAVE_WEBRTC', webrtc_dep.found())
|
||||
|
||||
# On FreeBSD, epoll-shim library is required for eventfd() and timerfd()
|
||||
epoll_shim_dep = (build_machine.system() == 'freebsd'
|
||||
|
|
@ -400,9 +378,7 @@ summary({'OpenSSL (for raop-sink)': openssl_lib.found()}, bool_yn: true)
|
|||
|
||||
lilv_lib = dependency('lilv-0', required: get_option('lv2'))
|
||||
summary({'lilv (for lv2 plugins)': lilv_lib.found()}, bool_yn: true)
|
||||
if lilv_lib.found()
|
||||
cdata.set('HAVE_LILV', 1)
|
||||
endif
|
||||
cdata.set('HAVE_LILV', lilv_lib.found())
|
||||
|
||||
installed_tests_metadir = pipewire_datadir / 'installed-tests' / pipewire_name
|
||||
installed_tests_execdir = pipewire_libexecdir / 'installed-tests' / pipewire_name
|
||||
|
|
@ -411,7 +387,7 @@ installed_tests_template = files('template.test.in')
|
|||
|
||||
if not get_option('tests').disabled()
|
||||
gstack = find_program('gstack', required : false)
|
||||
cdata.set10('HAVE_GSTACK', gstack.found())
|
||||
cdata.set('HAVE_GSTACK', gstack.found())
|
||||
endif
|
||||
|
||||
subdir('po')
|
||||
|
|
|
|||
|
|
@ -594,7 +594,7 @@ static bool device_supports_required_mSBC_transport_modes(
|
|||
|
||||
/* Check if USB ALT6 is really available on the device */
|
||||
if (device->adapter->bus_type == BUS_TYPE_USB && !msbc_alt1_ok && msbc_ok) {
|
||||
#if HAVE_LIBUSB
|
||||
#ifdef HAVE_LIBUSB
|
||||
if (device->adapter->source_id == SOURCE_ID_USB) {
|
||||
msbc_ok = check_usb_altsetting_6(backend, device->adapter->vendor_id,
|
||||
device->adapter->product_id);
|
||||
|
|
|
|||
|
|
@ -5,24 +5,14 @@ foreach dep: bluez5_deps
|
|||
endif
|
||||
endforeach
|
||||
|
||||
if not get_option('bluez5-backend-hsp-native').disabled()
|
||||
cdata.set('HAVE_BLUEZ_5_BACKEND_HSP_NATIVE', 1)
|
||||
cdata.set('HAVE_BLUEZ_5_BACKEND_NATIVE', 1)
|
||||
endif
|
||||
if not get_option('bluez5-backend-hfp-native').disabled()
|
||||
cdata.set('HAVE_BLUEZ_5_BACKEND_HFP_NATIVE', 1)
|
||||
cdata.set('HAVE_BLUEZ_5_BACKEND_NATIVE', 1)
|
||||
endif
|
||||
if not get_option('bluez5-backend-ofono').disabled()
|
||||
cdata.set('HAVE_BLUEZ_5_BACKEND_OFONO', 1)
|
||||
endif
|
||||
if not get_option('bluez5-backend-hsphfpd').disabled()
|
||||
cdata.set('HAVE_BLUEZ_5_BACKEND_HSPHFPD', 1)
|
||||
endif
|
||||
|
||||
if dependency('bluez', version: '< 6', required: false).found()
|
||||
cdata.set('HAVE_BLUEZ_5_HCI', 1)
|
||||
endif
|
||||
cdata.set('HAVE_BLUEZ_5_BACKEND_NATIVE',
|
||||
not get_option('bluez5-backend-hsp-native').disabled() or
|
||||
not get_option('bluez5-backend-hfp-native').disabled())
|
||||
cdata.set('HAVE_BLUEZ_5_BACKEND_HSP_NATIVE', not get_option('bluez5-backend-hsp-native').disabled())
|
||||
cdata.set('HAVE_BLUEZ_5_BACKEND_HFP_NATIVE', not get_option('bluez5-backend-hfp-native').disabled())
|
||||
cdata.set('HAVE_BLUEZ_5_BACKEND_OFONO', not get_option('bluez5-backend-ofono').disabled())
|
||||
cdata.set('HAVE_BLUEZ_5_BACKEND_HSPHFPD', not get_option('bluez5-backend-hsphfpd').disabled())
|
||||
cdata.set('HAVE_BLUEZ_5_HCI', dependency('bluez', version: '< 6', required: false).found())
|
||||
|
||||
bluez5_sources = [
|
||||
'plugin.c',
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ plugin_init (GstPlugin *plugin)
|
|||
gst_element_register (plugin, "pipewiresink", GST_RANK_NONE,
|
||||
GST_TYPE_PIPEWIRE_SINK);
|
||||
|
||||
#if HAVE_GSTREAMER_DEVICE_PROVIDER
|
||||
#ifdef HAVE_GSTREAMER_DEVICE_PROVIDER
|
||||
if (!gst_device_provider_register (plugin, "pipewiredeviceprovider",
|
||||
GST_RANK_PRIMARY + 1, GST_TYPE_PIPEWIRE_DEVICE_PROVIDER))
|
||||
return FALSE;
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ if avahi_dep.found()
|
|||
'module-zeroconf-discover/avahi-poll.c',
|
||||
]
|
||||
pipewire_module_protocol_pulse_deps += avahi_dep
|
||||
cdata.set('HAVE_AVAHI', 1)
|
||||
cdata.set('HAVE_AVAHI', true)
|
||||
endif
|
||||
|
||||
pipewire_module_protocol_pulse = shared_library('pipewire-module-protocol-pulse',
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#if HAVE_SYS_VFS_H
|
||||
#ifdef HAVE_SYS_VFS_H
|
||||
#include <sys/vfs.h>
|
||||
#endif
|
||||
#if HAVE_SYS_MOUNT_H
|
||||
#ifdef HAVE_SYS_MOUNT_H
|
||||
#include <sys/mount.h>
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
#include <fcntl.h>
|
||||
#include <sys/file.h>
|
||||
#include <ctype.h>
|
||||
#if HAVE_PWD_H
|
||||
#ifdef HAVE_PWD_H
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
#if defined(__FreeBSD__)
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/file.h>
|
||||
#if HAVE_PWD_H
|
||||
#ifdef HAVE_PWD_H
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -5105,7 +5105,7 @@ static void impl_clear(struct impl *impl)
|
|||
pw_map_for_each(&impl->modules, impl_unload_module, impl);
|
||||
pw_map_clear(&impl->modules);
|
||||
|
||||
#if HAVE_DBUS
|
||||
#ifdef HAVE_DBUS
|
||||
if (impl->dbus_name) {
|
||||
dbus_release_name(impl->dbus_name);
|
||||
impl->dbus_name = NULL;
|
||||
|
|
@ -5276,7 +5276,7 @@ struct pw_protocol_pulse *pw_protocol_pulse_new(struct pw_context *context,
|
|||
pw_context_add_listener(context, &impl->context_listener,
|
||||
&context_events, impl);
|
||||
|
||||
#if HAVE_DBUS
|
||||
#ifdef HAVE_DBUS
|
||||
impl->dbus_name = dbus_request_name(context, "org.pulseaudio.Server");
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <dirent.h>
|
||||
#if HAVE_PWD_H
|
||||
#ifdef HAVE_PWD_H
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
#ifdef __FreeBSD__
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#if HAVE_SYS_RANDOM_H
|
||||
#ifdef HAVE_SYS_RANDOM_H
|
||||
#include <sys/random.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#if !HAVE_SIGABBREV_NP
|
||||
#ifndef HAVE_SIGABBREV_NP
|
||||
#include <stddef.h>
|
||||
#include <signal.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -36,10 +36,10 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#if HAVE_PIDFD_OPEN
|
||||
#ifdef HAVE_PIDFD_OPEN
|
||||
#include <sys/syscall.h>
|
||||
#endif
|
||||
#if HAVE_LIBCAP
|
||||
#ifdef HAVE_LIBCAP
|
||||
#include <sys/capability.h>
|
||||
#endif
|
||||
#include <sys/epoll.h>
|
||||
|
|
@ -177,7 +177,7 @@ static void restore_env(struct pwtest_test *t)
|
|||
|
||||
static void pwtest_backtrace(pid_t p)
|
||||
{
|
||||
#if HAVE_GSTACK
|
||||
#ifdef HAVE_GSTACK
|
||||
char pid[11];
|
||||
pid_t parent, child;
|
||||
int status;
|
||||
|
|
@ -820,7 +820,7 @@ static int monitor_test_forked(struct pwtest_test *t, pid_t pid, int read_fds[_F
|
|||
size_t nevents = 0;
|
||||
int r;
|
||||
|
||||
#if HAVE_PIDFD_OPEN
|
||||
#ifdef HAVE_PIDFD_OPEN
|
||||
pidfd = syscall(SYS_pidfd_open, pid, 0);
|
||||
#else
|
||||
errno = ENOSYS;
|
||||
|
|
@ -1168,7 +1168,7 @@ static void list_tests(struct pwtest_context *ctx)
|
|||
static bool is_debugger_attached(void)
|
||||
{
|
||||
bool rc = false;
|
||||
#if HAVE_LIBCAP
|
||||
#ifdef HAVE_LIBCAP
|
||||
int status;
|
||||
int pid = fork();
|
||||
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ PWTEST(context_support)
|
|||
SPA_TYPE_INTERFACE_Loop,
|
||||
SPA_TYPE_INTERFACE_LoopUtils,
|
||||
SPA_TYPE_INTERFACE_Log,
|
||||
#if HAVE_DBUS
|
||||
#ifdef HAVE_DBUS
|
||||
SPA_TYPE_INTERFACE_DBus,
|
||||
#endif
|
||||
SPA_TYPE_INTERFACE_CPU
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
PWTEST(compat_sigabbrev_np)
|
||||
{
|
||||
#if !HAVE_SIGABBREV_NP
|
||||
#ifndef HAVE_SIGABBREV_NP
|
||||
pwtest_str_eq(sigabbrev_np(SIGABRT), "ABRT");
|
||||
pwtest_str_eq(sigabbrev_np(SIGSEGV), "SEGV");
|
||||
pwtest_str_eq(sigabbrev_np(SIGSTOP), "STOP");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue