fix: libwayland simplified recipe (23 lines) + durability patch
Removed 229-line fragile Python heredoc. Replaced with: - Proper redox.patch (105 lines, applies to wayland-1.24.0) - Clean meson build (-Dc_args=-Wno-error) - Patch handles: SFD/TFD checks, signalfd/timerfd compat, MSG_NOSIGNAL, open_memstream stub
This commit is contained in:
@@ -17,213 +17,7 @@ DYNAMIC_INIT
|
|||||||
|
|
||||||
RELIBC_INCLUDE_STAGE="${COOKBOOK_ROOT}/recipes/core/relibc/target/${TARGET}/stage/usr/include"
|
RELIBC_INCLUDE_STAGE="${COOKBOOK_ROOT}/recipes/core/relibc/target/${TARGET}/stage/usr/include"
|
||||||
if [ ! -f "${RELIBC_INCLUDE_STAGE}/sys/signalfd.h" ]; then
|
if [ ! -f "${RELIBC_INCLUDE_STAGE}/sys/signalfd.h" ]; then
|
||||||
RELIBC_INCLUDE_STAGE="${COOKBOOK_ROOT}/recipes/core/relibc/target/${TARGET}/stage.tmp/usr/include"
|
script = """
|
||||||
fi
|
DYNAMIC_INIT
|
||||||
|
cookbook_meson -Ddocumentation=false -Dtests=false -Ddtd_validation=false -Dc_args=-Wno-error
|
||||||
if [ -d "${RELIBC_INCLUDE_STAGE}" ]; then
|
|
||||||
mkdir -p "${COOKBOOK_SYSROOT}/include" "${COOKBOOK_SYSROOT}/usr/include"
|
|
||||||
cp -a "${RELIBC_INCLUDE_STAGE}/." "${COOKBOOK_SYSROOT}/include/"
|
|
||||||
cp -a "${RELIBC_INCLUDE_STAGE}/." "${COOKBOOK_SYSROOT}/usr/include/"
|
|
||||||
mkdir -p "${COOKBOOK_SYSROOT}/include/sys" "${COOKBOOK_SYSROOT}/usr/include/sys"
|
|
||||||
for header in signalfd.h timerfd.h eventfd.h; do
|
|
||||||
if [ -f "${RELIBC_INCLUDE_STAGE}/sys/${header}" ]; then
|
|
||||||
cp -f "${RELIBC_INCLUDE_STAGE}/sys/${header}" \
|
|
||||||
"${COOKBOOK_SYSROOT}/include/sys/${header}"
|
|
||||||
cp -f "${RELIBC_INCLUDE_STAGE}/sys/${header}" \
|
|
||||||
"${COOKBOOK_SYSROOT}/usr/include/sys/${header}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
python - <<'PY'
|
|
||||||
import os
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
source_root = Path(os.environ["COOKBOOK_SOURCE"])
|
|
||||||
|
|
||||||
meson = source_root / "meson.build"
|
|
||||||
meson_text = meson.read_text()
|
|
||||||
meson_text = meson_text.replace(
|
|
||||||
'''\tscanner_dep = dependency('wayland-scanner', native: true, version: meson.project_version())
|
|
||||||
\twayland_scanner_for_build = find_program(scanner_dep.get_variable(pkgconfig: 'wayland_scanner'))''',
|
|
||||||
'''\twayland_scanner_for_build = find_program('wayland-scanner', native: true)''',
|
|
||||||
)
|
|
||||||
meson_text = meson_text.replace(
|
|
||||||
"{ 'header': 'sys/signalfd.h', 'symbol': 'SFD_CLOEXEC' }",
|
|
||||||
"{ 'header': 'signal.h', 'symbol': 'SIG_BLOCK' }",
|
|
||||||
)
|
|
||||||
meson_text = meson_text.replace(
|
|
||||||
"{ 'header': 'sys/timerfd.h', 'symbol': 'TFD_CLOEXEC' }",
|
|
||||||
"{ 'header': 'time.h', 'symbol': 'CLOCK_MONOTONIC' }",
|
|
||||||
)
|
|
||||||
meson.write_text(meson_text)
|
|
||||||
|
|
||||||
src_meson = source_root / "src/meson.build"
|
|
||||||
src_meson_text = src_meson.read_text()
|
|
||||||
src_meson_text = src_meson_text.replace(
|
|
||||||
'''\tscanner_dep = dependency('wayland-scanner', native: true, version: meson.project_version())
|
|
||||||
\twayland_scanner_for_build = find_program(scanner_dep.get_variable(pkgconfig: 'wayland_scanner'))''',
|
|
||||||
'''\twayland_scanner_for_build = find_program('wayland-scanner', native: true)''',
|
|
||||||
)
|
|
||||||
src_meson.write_text(src_meson_text)
|
|
||||||
|
|
||||||
event_loop = source_root / "src/event-loop.c"
|
|
||||||
event_text = event_loop.read_text()
|
|
||||||
event_text = event_text.replace(
|
|
||||||
'#include <sys/signalfd.h>',
|
|
||||||
'// #include <sys/signalfd.h> /* Redox compat */',
|
|
||||||
)
|
|
||||||
event_text = event_text.replace(
|
|
||||||
'#include <sys/timerfd.h>',
|
|
||||||
'// #include <sys/timerfd.h> /* Redox compat */',
|
|
||||||
)
|
|
||||||
event_loop.write_text(event_text)
|
|
||||||
event_loop.write_text(event_text)
|
|
||||||
|
|
||||||
server = source_root / "src/wayland-server.c"
|
|
||||||
server_text = server.read_text()
|
|
||||||
server_text = server_text.replace(
|
|
||||||
'''#include <fcntl.h>
|
|
||||||
#include <sys/eventfd.h>''',
|
|
||||||
'''#include <fcntl.h>
|
|
||||||
#ifdef __redox__
|
|
||||||
|
|
||||||
#ifndef EFD_CLOEXEC
|
|
||||||
#define EFD_CLOEXEC O_CLOEXEC
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EFD_NONBLOCK
|
|
||||||
#define EFD_NONBLOCK O_NONBLOCK
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EFD_SEMAPHORE
|
|
||||||
#define EFD_SEMAPHORE 0x1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int eventfd(unsigned int initval, int flags)
|
|
||||||
{
|
|
||||||
const int supported = EFD_CLOEXEC | EFD_NONBLOCK | EFD_SEMAPHORE;
|
|
||||||
int oflag = O_RDWR;
|
|
||||||
char path[64];
|
|
||||||
|
|
||||||
if ((flags & ~supported) != 0) {
|
|
||||||
errno = EINVAL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (flags & EFD_CLOEXEC)
|
|
||||||
oflag |= O_CLOEXEC;
|
|
||||||
if (flags & EFD_NONBLOCK)
|
|
||||||
oflag |= O_NONBLOCK;
|
|
||||||
|
|
||||||
snprintf(path, sizeof(path), "/scheme/event/eventfd/%u/%d",
|
|
||||||
initval, (flags & EFD_SEMAPHORE) ? 1 : 0);
|
|
||||||
return open(path, oflag);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#include <sys/eventfd.h>
|
|
||||||
#endif''',
|
|
||||||
)
|
|
||||||
server_text = server_text.replace(
|
|
||||||
'''#include <fcntl.h>
|
|
||||||
#ifdef __redox__
|
|
||||||
#ifndef EFD_CLOEXEC
|
|
||||||
#define EFD_CLOEXEC O_CLOEXEC
|
|
||||||
#endif
|
|
||||||
#ifndef EFD_NONBLOCK
|
|
||||||
#define EFD_NONBLOCK O_NONBLOCK
|
|
||||||
#endif
|
|
||||||
int eventfd(unsigned int initval, int flags);
|
|
||||||
#else
|
|
||||||
#include <sys/eventfd.h>
|
|
||||||
#endif''',
|
|
||||||
'''#include <fcntl.h>
|
|
||||||
#ifdef __redox__
|
|
||||||
#include <sys/eventfd.h>
|
|
||||||
|
|
||||||
int eventfd(unsigned int initval, int flags)
|
|
||||||
{
|
|
||||||
const int supported = EFD_CLOEXEC | EFD_NONBLOCK | EFD_SEMAPHORE;
|
|
||||||
int oflag = O_RDWR;
|
|
||||||
char path[64];
|
|
||||||
|
|
||||||
if ((flags & ~supported) != 0) {
|
|
||||||
errno = EINVAL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (flags & EFD_CLOEXEC)
|
|
||||||
oflag |= O_CLOEXEC;
|
|
||||||
if (flags & EFD_NONBLOCK)
|
|
||||||
oflag |= O_NONBLOCK;
|
|
||||||
|
|
||||||
snprintf(path, sizeof(path), "/scheme/event/eventfd/%u/%d",
|
|
||||||
initval, (flags & EFD_SEMAPHORE) ? 1 : 0);
|
|
||||||
return open(path, oflag);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#include <sys/eventfd.h>
|
|
||||||
#endif''',
|
|
||||||
)
|
|
||||||
server.write_text(server_text)
|
|
||||||
|
|
||||||
connection = source_root / "src/connection.c"
|
|
||||||
connection_text = connection.read_text()
|
|
||||||
connection_text = connection_text.replace(
|
|
||||||
'''#include <ffi.h>
|
|
||||||
|
|
||||||
#include "wayland-util.h"''',
|
|
||||||
'''#include <ffi.h>
|
|
||||||
|
|
||||||
#ifdef __redox__
|
|
||||||
#ifndef MSG_NOSIGNAL
|
|
||||||
#define MSG_NOSIGNAL 0
|
|
||||||
#endif
|
|
||||||
FILE *open_memstream(char **bufp, size_t *sizep);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wayland-util.h"''',
|
|
||||||
)
|
|
||||||
connection_text = connection_text.replace(
|
|
||||||
'''void
|
|
||||||
wl_closure_print(struct wl_closure *closure, struct wl_object *target,
|
|
||||||
int send, int discarded, uint32_t (*n_parse)(union wl_argument *arg),
|
|
||||||
const char *queue_name)
|
|
||||||
{
|
|
||||||
int i;''',
|
|
||||||
'''void
|
|
||||||
wl_closure_print(struct wl_closure *closure, struct wl_object *target,
|
|
||||||
int send, int discarded, uint32_t (*n_parse)(union wl_argument *arg),
|
|
||||||
const char *queue_name)
|
|
||||||
{
|
|
||||||
#ifdef __redox__
|
|
||||||
(void)closure;
|
|
||||||
(void)target;
|
|
||||||
(void)send;
|
|
||||||
(void)discarded;
|
|
||||||
(void)n_parse;
|
|
||||||
(void)queue_name;
|
|
||||||
return;
|
|
||||||
#else
|
|
||||||
int i;''',
|
|
||||||
)
|
|
||||||
connection_text = connection_text.replace(
|
|
||||||
''' if (fclose(f) == 0) {
|
|
||||||
fprintf(stderr, "%s", buffer);
|
|
||||||
free(buffer);
|
|
||||||
}
|
|
||||||
}''',
|
|
||||||
''' if (fclose(f) == 0) {
|
|
||||||
fprintf(stderr, "%s", buffer);
|
|
||||||
free(buffer);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}''',
|
|
||||||
)
|
|
||||||
connection.write_text(connection_text)
|
|
||||||
PY
|
|
||||||
|
|
||||||
COOKBOOK_MESON_FLAGS+=("-Ddocumentation=false" "-Dtests=false" "-Ddtd_validation=false")
|
|
||||||
COOKBOOK_MESON_FLAGS+=("-Dc_args=-DSFD_CLOEXEC=O_CLOEXEC")
|
|
||||||
# Pre-define meson feature checks that fail on Redox (relibc gaps)
|
|
||||||
export CFLAGS="${CFLAGS:-} -DSFD_CLOEXEC=O_CLOEXEC"
|
|
||||||
cookbook_meson
|
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user