lol

Merge pull request #223304 from wegank/wayland-exotic

wayland: build libraries on darwin

authored by

Weijia Wang and committed by
GitHub
eab7f911 0a1c5be4

+79 -1
+74
pkgs/development/libraries/wayland/darwin.patch
··· 1 + diff --git a/meson.build b/meson.build 2 + index 35c3b95..f27e472 100644 3 + --- a/meson.build 4 + +++ b/meson.build 5 + @@ -16,7 +16,7 @@ config_h.set_quoted('PACKAGE', meson.project_name()) 6 + config_h.set_quoted('PACKAGE_VERSION', meson.project_version()) 7 + 8 + cc_args = [] 9 + -if host_machine.system() != 'freebsd' 10 + +if host_machine.system() not in ['darwin', 'freebsd'] 11 + cc_args += ['-D_POSIX_C_SOURCE=200809L'] 12 + endif 13 + add_project_arguments(cc_args, language: 'c') 14 + @@ -52,7 +52,7 @@ foreach f: have_funcs 15 + endforeach 16 + config_h.set10('HAVE_XUCRED_CR_PID', cc.has_member('struct xucred', 'cr_pid', prefix : '#include <sys/ucred.h>')) 17 + have_broken_msg_cmsg_cloexec = false 18 + -if host_machine.system() == 'freebsd' 19 + +if host_machine.system() in ['darwin', 'freebsd'] 20 + have_broken_msg_cmsg_cloexec = not cc.compiles(''' 21 + #include <sys/param.h> /* To get __FreeBSD_version. */ 22 + #if __FreeBSD_version < 1300502 || \ 23 + @@ -69,7 +69,7 @@ endif 24 + config_h.set10('HAVE_BROKEN_MSG_CMSG_CLOEXEC', have_broken_msg_cmsg_cloexec) 25 + 26 + if get_option('libraries') 27 + - if host_machine.system() == 'freebsd' 28 + + if host_machine.system() in ['darwin', 'freebsd'] 29 + # When building for FreeBSD, epoll(7) is provided by a userspace 30 + # wrapper around kqueue(2). 31 + epoll_dep = dependency('epoll-shim') 32 + diff --git a/src/event-loop.c b/src/event-loop.c 33 + index 37cf95d..49a38cb 100644 34 + --- a/src/event-loop.c 35 + +++ b/src/event-loop.c 36 + @@ -48,6 +48,13 @@ 37 + 38 + #define TIMER_REMOVED -2 39 + 40 + +#ifdef __APPLE__ 41 + +struct itimerspec { 42 + + struct timespec it_interval; 43 + + struct timespec it_value; 44 + +}; 45 + +#endif 46 + + 47 + struct wl_event_loop; 48 + struct wl_event_source_interface; 49 + struct wl_event_source_timer; 50 + diff --git a/src/wayland-os.c b/src/wayland-os.c 51 + index a9066ca..483fe64 100644 52 + --- a/src/wayland-os.c 53 + +++ b/src/wayland-os.c 54 + @@ -69,17 +69,19 @@ wl_os_socket_cloexec(int domain, int type, int protocol) 55 + { 56 + int fd; 57 + 58 + +#ifdef SOCK_CLOEXEC 59 + fd = socket(domain, type | SOCK_CLOEXEC, protocol); 60 + if (fd >= 0) 61 + return fd; 62 + if (errno != EINVAL) 63 + return -1; 64 + +#endif 65 + 66 + fd = socket(domain, type, protocol); 67 + return set_cloexec_or_close(fd); 68 + } 69 + 70 + -#if defined(__FreeBSD__) 71 + +#if defined(__APPLE__) || defined(__FreeBSD__) 72 + int 73 + wl_os_socket_peercred(int sockfd, uid_t *uid, gid_t *gid, pid_t *pid) 74 + {
+5 -1
pkgs/development/libraries/wayland/default.nix
··· 8 8 , wayland-scanner 9 9 , expat 10 10 , libxml2 11 - , withLibraries ? stdenv.isLinux 11 + , withLibraries ? stdenv.isLinux || stdenv.isDarwin 12 12 , withTests ? stdenv.isLinux 13 13 , libffi 14 14 , epoll-shim ··· 40 40 url = "https://gitlab.freedesktop.org/wayland/wayland/-/releases/${version}/downloads/${pname}-${version}.tar.xz"; 41 41 sha256 = "1b0ixya9bfw5c9jx8mzlr7yqnlyvd3jv5z8wln9scdv8q5zlvikd"; 42 42 }; 43 + 44 + patches = [ 45 + ./darwin.patch 46 + ]; 43 47 44 48 postPatch = lib.optionalString withDocumentation '' 45 49 patchShebangs doc/doxygen/gen-doxygen.py