build-sys: Fix macOS build

* Enable macOS specific modules (module-bonjour-publish,
  module-coreaudio-detect and module-coreaudio-device)
* Correctly set `PA_SOEXT` (.so, .dylib and .dll)
* Build `poll-posix.c` and `semaphore-osx.c`
* Drop linker flag `-Wl,-z,nodelete` on Darwin
* Drop linker flag `-Wl,--no-undefined` on Darwin
* Prefer to `clock_gettime` over compat impl for old Darwin
* Disable SCM credential on Darwin

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/746>
This commit is contained in:
Shunsuke Shimizu 2022-08-29 04:13:55 +09:00 committed by PulseAudio Marge Bot
parent e4517da353
commit 47a6918739
6 changed files with 53 additions and 26 deletions

View file

@ -150,7 +150,13 @@ cdata.set_quoted('PA_MACHINE_ID', join_paths(sysconfdir, 'machine-id'))
cdata.set_quoted('PA_MACHINE_ID_FALLBACK', join_paths(localstatedir, 'lib', 'dbus', 'machine-id'))
cdata.set_quoted('PA_SRCDIR', join_paths(meson.current_source_dir(), 'src'))
cdata.set_quoted('PA_BUILDDIR', meson.current_build_dir())
if host_machine.system() == 'windows'
cdata.set_quoted('PA_SOEXT', '.dll')
elif host_machine.system() == 'darwin'
cdata.set_quoted('PA_SOEXT', '.dylib')
else
cdata.set_quoted('PA_SOEXT', '.so')
endif
cdata.set_quoted('PA_DEFAULT_CONFIG_DIR', pulsesysconfdir)
cdata.set('PA_DEFAULT_CONFIG_DIR_UNQUOTED', pulsesysconfdir)
cdata.set_quoted('PA_BINARY', join_paths(bindir, 'pulseaudio'))
@ -426,7 +432,7 @@ cdata.set('MESON_BUILD', 1)
# so we request the nodelete flag to be enabled.
# On other systems, we don't really know how to do that, but it's welcome if somebody can tell.
# Windows doesn't support this flag.
if host_machine.system() != 'windows'
if host_machine.system() != 'windows' and host_machine.system() != 'darwin'
nodelete_link_args = ['-Wl,-z,nodelete']
else
nodelete_link_args = []

View file

@ -182,9 +182,14 @@ if host_machine.system() == 'windows'
else
libpulsecommon_sources += [
'pulsecore/mutex-posix.c',
'pulsecore/semaphore-posix.c',
'pulsecore/thread-posix.c'
'pulsecore/poll-posix.c',
'pulsecore/thread-posix.c',
]
if host_machine.system() == 'darwin'
libpulsecommon_sources += ['pulsecore/semaphore-osx.c']
else
libpulsecommon_sources += ['pulsecore/semaphore-posix.c']
endif
endif
# FIXME: Do SIMD things

View file

@ -8,15 +8,12 @@ all_modules = [
[ 'module-always-sink', 'module-always-sink.c' ],
[ 'module-always-source', 'module-always-source.c' ],
[ 'module-augment-properties', 'module-augment-properties.c' ],
# [ 'module-bonjour-publish', 'macosx/module-bonjour-publish.c' ],
[ 'module-card-restore', 'module-card-restore.c' ],
[ 'module-cli', 'module-cli.c', [], [], [], libcli ],
[ 'module-cli-protocol-tcp', 'module-protocol-stub.c', [], ['-DUSE_PROTOCOL_CLI', '-DUSE_TCP_SOCKETS'], [], libprotocol_cli ],
[ 'module-cli-protocol-unix', 'module-protocol-stub.c', [], ['-DUSE_PROTOCOL_CLI', '-DUSE_UNIX_SOCKETS'], [], libprotocol_cli ],
[ 'module-combine', 'module-combine.c' ],
[ 'module-combine-sink', 'module-combine-sink.c', [], [], [libatomic_ops_dep] ],
# [ 'module-coreaudio-detect', 'macosx/module-coreaudio-detect.c' ],
# [ 'module-coreaudio-device', 'macosx/module-coreaudio-device.c' ],
[ 'module-default-device-restore', 'module-default-device-restore.c', [], [], [], libprotocol_native ],
[ 'module-detect', 'module-detect.c' ],
[ 'module-device-manager', 'module-device-manager.c', [], [], [], libprotocol_native ],
@ -78,6 +75,16 @@ if host_machine.system() != 'windows'
]
endif
if host_machine.system() == 'darwin'
bonjour_dep = dependency('appleframeworks', modules : ['CoreFoundation'])
coreaudio_dep = dependency('appleframeworks', modules : ['CoreAudio'])
all_modules += [
[ 'module-bonjour-publish', 'macosx/module-bonjour-publish.c', [], [], [bonjour_dep] ],
[ 'module-coreaudio-detect', 'macosx/module-coreaudio-detect.c', [], [], [coreaudio_dep] ],
[ 'module-coreaudio-device', 'macosx/module-coreaudio-device.c', [], [], [coreaudio_dep] ],
]
endif
# Modules enabled by headers
if cc.has_header('linux/input.h')
@ -298,6 +305,12 @@ all_modules += [
# FIXME: meson doesn't support multiple RPATH arguments currently
rpath_dirs = join_paths(privlibdir) + ':' + join_paths(modlibexecdir)
if host_machine.system() != 'windows' and host_machine.system() != 'darwin'
no_undefined_args = ['-Wl,--no-undefined']
else
no_undefined_args = []
endif
foreach m : all_modules
name = m[0]
sources = m[1]
@ -315,7 +328,7 @@ foreach m : all_modules
install_rpath : rpath_dirs,
install_dir : modlibexecdir,
dependencies : [thread_dep, libpulse_dep, libpulsecommon_dep, libpulsecore_dep, libintl_dep, platform_dep, platform_socket_dep] + extra_deps,
link_args : [nodelete_link_args, '-Wl,--no-undefined' ],
link_args : [nodelete_link_args, no_undefined_args],
link_with : extra_libs,
name_prefix : '',
implicit_include_directories : false)

View file

@ -70,11 +70,15 @@ if glib_dep.found()
libpulse_headers += 'glib-mainloop.h'
endif
if host_machine.system() != 'windows' and host_machine.system() != 'darwin'
run_target('update-map-file',
command : [ join_paths(meson.source_root(), 'scripts/generate-map-file.sh'), 'map-file',
[ libpulse_headers, 'simple.h', join_paths(meson.build_root(), 'src', 'pulse', 'version.h') ] ])
versioning_link_args = '-Wl,-version-script=' + join_paths(meson.source_root(), 'src', 'pulse', 'map-file')
versioning_link_args = ['-Wl,-version-script=' + join_paths(meson.source_root(), 'src', 'pulse', 'map-file')]
else
versioning_link_args = []
endif
libpulse = shared_library('pulse',
libpulse_sources,

View file

@ -65,19 +65,7 @@ pa_usec_t pa_rtclock_age(const struct timeval *tv) {
struct timeval *pa_rtclock_get(struct timeval *tv) {
#if defined(OS_IS_DARWIN)
uint64_t val, abs_time = mach_absolute_time();
Nanoseconds nanos;
nanos = AbsoluteToNanoseconds(*(AbsoluteTime *) &abs_time);
val = *(uint64_t *) &nanos;
tv->tv_sec = val / PA_NSEC_PER_SEC;
tv->tv_usec = (val % PA_NSEC_PER_SEC) / PA_NSEC_PER_USEC;
return tv;
#elif defined(HAVE_CLOCK_GETTIME)
#if defined(HAVE_CLOCK_GETTIME)
struct timespec ts;
#ifdef CLOCK_MONOTONIC
@ -97,6 +85,17 @@ struct timeval *pa_rtclock_get(struct timeval *tv) {
tv->tv_sec = ts.tv_sec;
tv->tv_usec = ts.tv_nsec / PA_NSEC_PER_USEC;
return tv;
#elif defined(OS_IS_DARWIN)
uint64_t val, abs_time = mach_absolute_time();
Nanoseconds nanos;
nanos = AbsoluteToNanoseconds(*(AbsoluteTime *) &abs_time);
val = *(uint64_t *) &nanos;
tv->tv_sec = val / PA_NSEC_PER_SEC;
tv->tv_usec = (val % PA_NSEC_PER_SEC) / PA_NSEC_PER_USEC;
return tv;
#elif defined(OS_IS_WIN32)
if (counter_freq > 0) {

View file

@ -34,7 +34,7 @@
typedef struct pa_creds pa_creds;
typedef struct pa_cmsg_ancil_data pa_cmsg_ancil_data;
#if defined(SCM_CREDENTIALS) || defined(SCM_CREDS)
#if (defined(SCM_CREDENTIALS) || defined(SCM_CREDS)) && !defined(OS_IS_DARWIN)
#define HAVE_CREDS 1