[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] build-sys: Fix macOS build

PulseAudio Marge Bot (@pulseaudio-merge-bot) gitlab at gitlab.freedesktop.org
Wed Dec 7 10:59:24 UTC 2022



PulseAudio Marge Bot pushed to branch master at PulseAudio / pulseaudio


Commits:
47a69187 by Shunsuke Shimizu at 2022-12-07T10:57:01+00:00
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>

- - - - -


6 changed files:

- meson.build
- src/meson.build
- src/modules/meson.build
- src/pulse/meson.build
- src/pulsecore/core-rtclock.c
- src/pulsecore/creds.h


Changes:

=====================================
meson.build
=====================================
@@ -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())
-cdata.set_quoted('PA_SOEXT', '.so')
+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 = []


=====================================
src/meson.build
=====================================
@@ -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
 


=====================================
src/modules/meson.build
=====================================
@@ -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)


=====================================
src/pulse/meson.build
=====================================
@@ -70,11 +70,15 @@ if glib_dep.found()
   libpulse_headers += 'glib-mainloop.h'
 endif
 
-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') ] ])
+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,


=====================================
src/pulsecore/core-rtclock.c
=====================================
@@ -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) {


=====================================
src/pulsecore/creds.h
=====================================
@@ -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
 



View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/47a6918739cb06dafa970d0b528bed1951d95039

-- 
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/47a6918739cb06dafa970d0b528bed1951d95039
You're receiving this email because of your account on gitlab.freedesktop.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20221207/91a8a07b/attachment-0001.htm>


More information about the pulseaudio-commits mailing list