ALL: Switch Fluidsynth to its embedded OS abstraction layer

This commit is contained in:
Le Philousophe
2025-11-01 21:40:52 +00:00
parent 8d85777165
commit f776860e70
14 changed files with 138 additions and 409 deletions
+1 -1
View File
@@ -94,6 +94,6 @@ local_package(libsdl2)
local_package(libsdl2_net)
# No fluidsynth
helpers_package(fluidsynth)
define_aliases(ppc-amigaos, amigaosdist, --enable-plugins --default-dynamic --enable-detection-dynamic)
@@ -1,13 +0,0 @@
Index: glib-2.84.4/meson.build
===================================================================
--- glib-2.84.4.orig/meson.build
+++ glib-2.84.4/meson.build
@@ -982,7 +982,7 @@ endif
osx_ldflags = []
glib_have_carbon = false
glib_have_cocoa = false
-if host_system == 'darwin'
+if false and host_system == 'darwin'
add_languages('objc', native: false, required: true)
objcc = meson.get_compiler('objc')
if not objcc.compiles('''#include <AvailabilityMacros.h>
@@ -1,15 +0,0 @@
Index: glib-2.84.4/meson.build
===================================================================
--- glib-2.84.4.orig/meson.build
+++ glib-2.84.4/meson.build
@@ -2232,6 +2232,10 @@ pcre2_options = [
'test=false',
]
+if host_system == 'ios'
+ pcre2_options += 'jit=disabled'
+endif
+
# Pick up pcre from the system, or if "--force-fallback-for libpcre2-8" was specified
pcre2 = dependency('libpcre2-8', version: pcre2_req, required: false, default_options: pcre2_options)
if not pcre2.found()
@@ -1,265 +0,0 @@
From 29e8fda3fc8736fe5054af134568030c0dd64455 Mon Sep 17 00:00:00 2001
From: Roman Shpuntov <roman.shpuntov@gmail.com>
Date: Tue, 4 Feb 2020 20:05:06 +0700
Subject: [PATCH 2/2] Add tvos device support
---
gio/gtestdbus.c | 7 ++++++-
gio/tests/gdbus-non-socket.c | 8 ++++++--
gio/tests/gschema-compile.c | 2 ++
gio/tests/socket.c | 5 ++++-
glib/gbacktrace.c | 12 +++++++++++-
glib/gspawn.c | 26 ++++++++++++++++++++++++++
glib/gtestutils.c | 6 ++++++
glib/tests/spawn-multithreaded.c | 4 ++++
meson.build | 4 ++++
9 files changed, 69 insertions(+), 5 deletions(-)
Index: glib-2.84.4/gio/gtestdbus.c
===================================================================
--- glib-2.84.4.orig/gio/gtestdbus.c
+++ glib-2.84.4/gio/gtestdbus.c
@@ -239,6 +239,7 @@ watcher_init (void)
static gsize started = 0;
static GIOChannel *channel = NULL;
int errsv;
+ pid_t child = -1;
if (g_once_init_enter (&started))
{
@@ -262,7 +263,11 @@ watcher_init (void)
fflush (stdout);
fflush (stderr);
- switch (fork ())
+#if HAVE_FORK == 1
+ child = fork ();
+#endif
+
+ switch (child)
{
case -1:
errsv = errno;
Index: glib-2.84.4/gio/tests/gdbus-non-socket.c
===================================================================
--- glib-2.84.4.orig/gio/tests/gdbus-non-socket.c
+++ glib-2.84.4/gio/tests/gdbus-non-socket.c
@@ -135,7 +135,7 @@ test_non_socket (void)
GDBusConnection *connection;
GError *error;
gchar *guid;
- pid_t first_child;
+ pid_t first_child = -1;
GVariant *ret;
const gchar *str;
gboolean ok;
@@ -152,7 +152,11 @@ test_non_socket (void)
g_assert (G_IS_INPUT_STREAM (g_io_stream_get_input_stream (streams[1])));
g_assert (G_IS_OUTPUT_STREAM (g_io_stream_get_output_stream (streams[1])));
- switch ((first_child = fork ()))
+#if HAVE_FORK == 1
+ first_child = fork ();
+#endif
+
+ switch (first_child)
{
case -1:
g_assert_not_reached ();
Index: glib-2.84.4/gio/tests/gschema-compile.c
===================================================================
--- glib-2.84.4.orig/gio/tests/gschema-compile.c
+++ glib-2.84.4/gio/tests/gschema-compile.c
@@ -27,7 +27,9 @@ test_schema_do_compile (gpointer data)
};
gchar *envp[] = { NULL };
+#if HAVE_FORK == 1
execve (argv[0], (char **) argv, envp);
+#endif
g_assert_not_reached ();
}
Index: glib-2.84.4/gio/tests/socket.c
===================================================================
--- glib-2.84.4.orig/gio/tests/socket.c
+++ glib-2.84.4/gio/tests/socket.c
@@ -1460,7 +1460,7 @@ test_unix_connection_ancillary_data (voi
gint pv[2], sv[3];
gint status, fd, len;
char buffer[1024];
- pid_t pid;
+ pid_t pid = -1;
status = pipe (pv);
g_assert_cmpint (status, ==, 0);
@@ -1468,7 +1468,10 @@ test_unix_connection_ancillary_data (voi
status = socketpair (PF_UNIX, SOCK_STREAM, 0, sv);
g_assert_cmpint (status, ==, 0);
+#if HAVE_FORK == 1
pid = fork ();
+#endif
+
g_assert_cmpint (pid, >=, 0);
/* Child: close its copy of the write end of the pipe, receive it
Index: glib-2.84.4/glib/gbacktrace.c
===================================================================
--- glib-2.84.4.orig/glib/gbacktrace.c
+++ glib-2.84.4/glib/gbacktrace.c
@@ -249,7 +249,7 @@ void
g_on_error_stack_trace (const gchar *prg_name)
{
#if defined(G_OS_UNIX)
- pid_t pid;
+ pid_t pid = -1;
gchar buf[16];
gchar buf2[64];
const gchar *args[5] = { DEBUGGER, NULL, NULL, NULL, NULL };
@@ -272,7 +272,10 @@ g_on_error_stack_trace (const gchar *prg
args[2] = buf;
#endif
+#if HAVE_FORK == 1
pid = fork ();
+#endif
+
if (pid == 0)
{
stack_trace (args);
@@ -397,9 +400,15 @@ stack_trace (const char * const *args)
_exit (0);
}
+#if HAVE_FORK == 1
pid = fork ();
+#else
+ pid = -1;
+#endif
+
if (pid == 0)
{
+#if HAVE_FORK == 1
/* Save stderr for printing failure below */
int old_err = dup (2);
if (old_err != -1)
@@ -427,6 +436,7 @@ stack_trace (const char * const *args)
}
perror ("exec " DEBUGGER " failed");
_exit (0);
+#endif
}
else if (pid == (pid_t) -1)
{
Index: glib-2.84.4/glib/gtestutils.c
===================================================================
--- glib-2.84.4.orig/glib/gtestutils.c
+++ glib-2.84.4/glib/gtestutils.c
@@ -3941,7 +3941,13 @@ g_test_trap_fork (guint64 usec_ti
errsv = errno;
g_error ("failed to create pipes to fork test program: %s", g_strerror (errsv));
}
+
+#if HAVE_FORK == 1
test_trap_last_pid = fork ();
+#else
+ test_trap_last_pid = -1;
+#endif
+
errsv = errno;
if (test_trap_last_pid < 0)
g_error ("failed to fork test program: %s", g_strerror (errsv));
Index: glib-2.84.4/glib/tests/spawn-multithreaded.c
===================================================================
--- glib-2.84.4.orig/glib/tests/spawn-multithreaded.c
+++ glib-2.84.4/glib/tests/spawn-multithreaded.c
@@ -87,7 +87,11 @@ get_a_child (gint ttl)
return pid;
#else
+#if HAVE_FORK == 1
pid = fork ();
+#else
+ pid = -1;
+#endif
if (pid < 0)
exit (1);
Index: glib-2.84.4/meson.build
===================================================================
--- glib-2.84.4.orig/meson.build
+++ glib-2.84.4/meson.build
@@ -2486,6 +2486,10 @@ main (void)
exit (__getcmdline ());
}'''
+if host_system != 'windows' and cc.has_function('fork', prefix : '#include <unistd.h>')
+ glib_conf.set('HAVE_FORK', 1)
+endif
+
if cc_can_run
rres = cc.run(cmdline_test_code, name : '/proc/self/cmdline')
have_proc_self_cmdline = rres.compiled() and rres.returncode() == 0
Index: glib-2.84.4/glib/gspawn-posix.c
===================================================================
--- glib-2.84.4.orig/glib/gspawn-posix.c
+++ glib-2.84.4/glib/gspawn-posix.c
@@ -1474,8 +1474,10 @@ fork_exec (gboolean interme
if (source_fds_collide_with_pipe (&child_pid_report_pipe, source_fds, n_fds, error))
goto cleanup_and_fail;
}
-
+
+#if HAVE_FORK == 1
pid = fork ();
+#endif
if (pid < 0)
{
@@ -1528,7 +1530,11 @@ fork_exec (gboolean interme
*/
GPid grandchild_pid;
+#if HAVE_FORK == 1
grandchild_pid = fork ();
+#else
+ grandchild_pid = 1;
+#endif
if (grandchild_pid < 0)
{
@@ -1825,11 +1831,15 @@ script_execute (const gchar *file,
--argc;
}
+#if HAVE_FORK == 1
/* Execute the shell. */
if (envp)
execve (argv_buffer[0], argv_buffer, envp);
else
execv (argv_buffer[0], argv_buffer);
+#else
+ return FALSE;
+#endif
return TRUE;
}
@@ -1865,6 +1875,7 @@ g_execute (const gchar *file,
return -1;
}
+#if HAVE_FORK == 1
if (search_path == NULL || strchr (file, '/') != NULL)
{
/* Don't search when it contains a slash. */
@@ -1983,6 +1994,9 @@ g_execute (const gchar *file,
errno = EACCES;
}
+#else
+ errno = ENOSYS;
+#endif
/* Return the error from the last attempt (probably ENOENT). */
return -1;
}
+13 -43
View File
@@ -8,45 +8,10 @@ HELPERS_DIR=$PACKAGE_DIR/../..
do_make_bdir
do_pkg_fetch libffi
autoreconf -fi
do_configure --disable-builddir --disable-docs
do_make
# Install only includes and library (no man pages, nor info)
do_make -C include install
do_make install-pkgconfigDATA install-toolexeclibLTLIBRARIES
cd ..
do_pkg_fetch glib2.0
do_patch glib
# Only keep glib and gthread
# tools doesn't produce anything but is needed for the build
sed -i -e "/subdir('/{/'glib'/{p;d}; /'gthread'/{p;d}; /'tools'/{p;d}; s/^/#/}" meson.build
do_meson
ninja
ninja install
# We are in build directory
cd ../..
# Debian version is quite old
# Debian version doesn't support the embedded OS abstraction layer
do_http_fetch fluidsynth \
"https://github.com/FluidSynth/fluidsynth/archive/v${FLUIDSYNTH_VERSION}.tar.gz" 'tar xzf'
# Fluidsynth doesn't link correctly against static glib, fix this
sed -i -e '/add_executable ( fluidsynth/,/)/{
/)/a target_link_options ( fluidsynth PRIVATE ${PC_GLIB2_STATIC_LDFLAGS_OTHER} )
}' src/CMakeLists.txt
# Fluidsynth adds frameworks manually and it fails to build on iOS/AppleTV
sed -i -e '/-Wl,-framework/s/^/#/' cmake_admin/FindGLib2.cmake
# Fluidsynth is completly bugguy at finding dependencies
sed -i -e 's/"\${PC_G\([A-Z]\+\)2_INCLUDEDIR}"/${PC_G\12_INCLUDE_DIRS}/' cmake_admin/FindGLib2.cmake
sed -i -e 's/"\${PC_G\([A-Z]\+\)2_LIBDIR}"/${PC_G\12_LIBRARY_DIRS}/' cmake_admin/FindGLib2.cmake
# Don't install fluidsynth binary
# Still build it to ensure we have a working setup with all static libraries
sed -i -e 's/install\(.*\) fluidsynth /install\1 /g' src/CMakeLists.txt
@@ -54,19 +19,24 @@ sed -i -e 's/install\(.*\) fluidsynth /install\1 /g' src/CMakeLists.txt
# -DCMAKE_SYSTEM_NAME=Windows for Windows
# Lighten Fluidsynth the most we can
# DLS support will be enabled only if C++17 is available
do_cmake \
-Denable-aufile=off -Denable-dbus=off \
-Denable-network=off -Denable-jack=off \
-Dosal=embedded -Denable-native-dls=on \
-Denable-alsa=off -Denable-aufile=off \
-Denable-dbus=off -Denable-jack=off \
-Denable-ladspa=off -Denable-libinstpatch=off \
-Denable-libsndfile=off -Denable-midishare=off \
-Denable-opensles=off -Denable-oboe=off \
-Denable-oss=off -Denable-dsound=off \
-Denable-network=off -Denable-oss=off \
-Denable-dsound=off -Denable-wasapi=off \
-Denable-waveout=off -Denable-winmidi=off \
-Denable-sdl2=off -Denable-pulseaudio=off \
-Denable-readline=off -Denable-lash=off \
-Denable-alsa=off -Denable-systemd=off \
-Denable-sdl3=off -Denable-pulseaudio=off \
-Denable-pipewire=off -Denable-readline=off \
-Denable-threads=off -Denable-openmp=off \
-Denable-systemd=off \
-Denable-coreaudio=off -Denable-coremidi=off \
-Denable-framework=off "$@"
-Denable-framework=off \
"$@"
do_make
do_make install
+1 -1
View File
@@ -48,6 +48,6 @@ helpers_package(fribidi)
COPY --from=android-helpers /lib-helpers/packages/libsdl2-net lib-helpers/packages/libsdl2-net
helpers_package(libsdl2-net)
helpers_package(fluidlite, -DBIN_INSTALL_DIR=bin/\$TARGET/\$API -DLIB_INSTALL_DIR=lib/\$TARGET/\$API)
helpers_package(fluidsynth)
helpers_package(sonivox)
-1
View File
@@ -157,7 +157,6 @@ ports_package(libsdl2_net)
# Lighten glib build by removing Objective C and Cocoa and fix intl detection
m4_ifdef(`USE_FLUIDLITE',m4_dnl
helpers_package(fluidlite),m4_dnl
COPY --from=apple-common /lib-helpers/packages/fluidsynth lib-helpers/packages/fluidsynth
helpers_package(fluidsynth, -DCMAKE_SYSTEM_NAME=Darwin -DLIB_SUFFIX= -DCMAKE_FRAMEWORK_PATH=${TARGET_DIR}/SDK/MacOSX`'MACOSX_SDK_VERSION`'.sdk/usr/lib))
helpers_package(retrowave, -DCMAKE_SYSTEM_NAME=Darwin)
-2
View File
@@ -144,6 +144,4 @@ helpers_package(fribidi)
COPY --from=apple-common /lib-helpers/packages/libsdl2-net lib-helpers/packages/libsdl2-net
helpers_package(libsdl2-net)
# Lighten glib build by removing Objective C and Cocoa and fix intl detection
COPY --from=apple-common /lib-helpers/packages/fluidsynth lib-helpers/packages/fluidsynth
helpers_package(fluidsynth, -DCMAKE_SYSTEM_NAME=Darwin -DLIB_SUFFIX=)
+1 -1
View File
@@ -105,7 +105,7 @@ local_mxe_package(sdl2)
mxe_package(sdl2_net)
local_mxe_package(fluidlite)
local_mxe_package(fluidsynth-embedded)
local_mxe_package(winsparkle)
@@ -1,51 +0,0 @@
From 849751658e68ae734dcf493153d012da63c2652a Mon Sep 17 00:00:00 2001
From: Le Philousophe <lephilousophe@users.noreply.github.com>
Date: Fri, 5 May 2023 22:58:29 +0200
Subject: [PATCH] Fix static build
---
CMakeLists.txt | 3 ++-
include/{fluidlite.h => fluidlite.h.in} | 6 ++++++
2 files changed, 8 insertions(+), 1 deletion(-)
rename include/{fluidlite.h => fluidlite.h.in} (95%)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4aead6c..530651f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,10 +33,11 @@ include(CheckIncludeFile)
check_include_file(fcntl.h HAVE_FCNTL_H)
list(APPEND HEADERS
- include/fluidlite.h
+ ${PROJECT_BINARY_DIR}/fluidlite.h
)
configure_file(src/version.cmake ${PROJECT_BINARY_DIR}/fluidlite/version.h @ONLY)
+configure_file(include/fluidlite.h.in ${PROJECT_BINARY_DIR}/fluidlite.h)
list(APPEND SCOPED_HEADERS
include/fluidlite/types.h
diff --git a/include/fluidlite.h b/include/fluidlite.h.in
similarity index 95%
rename from include/fluidlite.h
rename to include/fluidlite.h.in
index a159ddd..5e6ea4b 100644
--- a/include/fluidlite.h
+++ b/include/fluidlite.h.in
@@ -27,6 +27,12 @@
extern "C" {
#endif
+#cmakedefine01 FLUIDLITE_BUILD_SHARED
+
+#if (FLUIDLITE_BUILD_SHARED == 0) && !defined(FLUIDLITE_STATIC)
+#define FLUIDLITE_STATIC
+#endif
+
#if defined(FLUIDLITE_STATIC)
#define FLUIDSYNTH_API
--
2.34.1
@@ -1,16 +0,0 @@
PKG := fluidlite
$(PKG)_WEBSITE := https://github.com/divideconcept/FluidLite
$(PKG)_DESCR := Fluidlite
$(PKG)_IGNORE :=
$(PKG)_VERSION := 4a01cf1
$(PKG)_CHECKSUM := e0f7b6789021ef55c6f51ca5b82a1f9274564b4936ae6960f5db64ff4d6ef1ea
$(PKG)_GH_CONF := divideconcept/FluidLite/branches/master
$(PKG)_DEPS := cc
define $(PKG)_BUILD
cd '$(BUILD_DIR)' && '$(TARGET)-cmake' '$(SOURCE_DIR)' \
-DFLUIDLITE_BUILD_SHARED=OFF \
$($(PKG)_CONFIGURE_OPTS)
$(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)' VERBOSE=1
$(MAKE) -C '$(BUILD_DIR)' -j 1 install VERBOSE=1
endef
@@ -0,0 +1,70 @@
commit 04fc2f30d2a27c5f707830708cb345bdad4eeee1
Author: Tony Theodore <tonyt@logyst.com>
Date: Sun Sep 8 18:22:33 2019 +1000
Allow optional build of bins, docs, and tests
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 350a1dce..e88c1a9c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -105,6 +105,11 @@ option ( enable-native-dls "compile native DLS support (requires C++17)" on )
set ( osal "glib" CACHE STRING "OS abstraction to use, provided by src/utils/fluid_sys_${osal}.*" )
+# Options for build components
+option ( build-bins "build binary programs" on )
+option ( build-docs "build docs" on )
+option ( build-tests "build tests" on )
+
# Platform specific options
if ( CMAKE_SYSTEM MATCHES "Linux" )
option ( enable-systemd "compile systemd support (if it is available)" on )
@@ -887,8 +892,12 @@ endif ()
# Process subdirectories
add_subdirectory ( src )
-add_subdirectory ( test )
-add_subdirectory ( doc )
+if ( build-tests )
+ add_subdirectory ( test )
+endif ()
+if ( build-docs )
+ add_subdirectory ( doc )
+endif ()
# pkg-config support
set ( prefix "${CMAKE_INSTALL_PREFIX}" )
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 15017af9..fd9ba9e8 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -473,6 +473,8 @@ target_link_libraries ( libfluidsynth PRIVATE libfluidsynth-OBJ )
# ************ CLI program ************
+if ( build-bins )
+ set ( fluidsynth_bin "fluidsynth" )
set ( fluidsynth_SOURCES fluidsynth.c )
if ( WASAPI_SUPPORT )
@@ -558,15 +560,17 @@ if ( MINGW AND enable-unicode )
target_link_options( fluidsynth PRIVATE -municode )
endif()
+endif ( build-bins )
+
if ( MACOSX_FRAMEWORK )
- install ( TARGETS fluidsynth libfluidsynth
+ install ( TARGETS ${fluidsynth_bin} libfluidsynth
EXPORT FluidSynthTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
FRAMEWORK DESTINATION "${FRAMEWORK_INSTALL_PREFIX}/${FRAMEWORK_INSTALL_DIR}"
ARCHIVE DESTINATION "${FRAMEWORK_INSTALL_PREFIX}/${FRAMEWORK_INSTALL_DIR}"
)
else ( MACOSX_FRAMEWORK )
- install ( TARGETS fluidsynth libfluidsynth
+ install ( TARGETS ${fluidsynth_bin} libfluidsynth
EXPORT FluidSynthTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
@@ -0,0 +1,37 @@
PKG := fluidsynth-embedded
$(PKG)_WEBSITE := $(fluidsynth_WEBSITE)
$(PKG)_DESCR := FluidSynth (with embedded OSAL)
$(PKG)_IGNORE := $(fluidsynth_IGNORE)
$(PKG)_VERSION := 2.5.0
$(PKG)_CHECKSUM := e4ae831ce02f38b5594ab4dacb11c1a4067ca65ea183523655ebdc9c1b2b92a1
$(PKG)_GH_CONF := $(fluidsynth_GH_CONF)
$(PKG)_FILE := fluidsynth-$$(filter-out $$(PKG)-,$$($$(PKG)_TAG_PREFIX))$($(PKG)_VERSION)$$($$(PKG)_TAG_SUFFIX)$$($$(PKG)_ARCHIVE_EXT)
$(PKG)_DEPS := cc mman-win32 gcem
# Use test file and patches provided by MXE
$(PKG)_TEST_FILE = $(fluidsynth_TEST_FILE)
$(PKG)_BUILD = $(fluidsynth_BUILD)
$(eval define $(PKG)_BUILD$(newline)\
$(subst -gcc,-g++,$(value fluidsynth_BUILD))$(newline)\
endef)
$(PKG)_CONFIGURE_OPTS = \
-Dosal=embedded -Denable-native-dls=on \
-Denable-alsa=off -Denable-aufile=off \
-Denable-dbus=off -Denable-jack=off \
-Denable-ladspa=off -Denable-libinstpatch=off \
-Denable-libsndfile=off -Denable-midishare=off \
-Denable-opensles=off -Denable-oboe=off \
-Denable-network=off -Denable-oss=off \
-Denable-dsound=off -Denable-wasapi=off \
-Denable-waveout=off -Denable-winmidi=off \
-Denable-sdl3=off -Denable-pulseaudio=off \
-Denable-pipewire=off -Denable-readline=off \
-Denable-threads=off -Denable-openmp=off \
-Denable-systemd=off \
-Denable-coreaudio=off -Denable-coremidi=off \
-Denable-framework=off
# Don't remove following comment: it's used to trigger automatic detection of cmake based packages
# We could manually add dependency but if it changes, we could expect that heuristic won't
# $(TARGET)-cmake
@@ -0,0 +1,15 @@
PKG := gcem
$(PKG)_WEBSITE := https://github.com/kthohr/gcem
$(PKG)_DESCR := GCEM
$(PKG)_IGNORE :=
$(PKG)_VERSION := 012ae73
$(PKG)_CHECKSUM := 05337e85ff2c662d2b7ca8521d80cbfc72786bfcc8d079de07ad389934f6cc7c
$(PKG)_GH_CONF := kthohr/gcem/branches/master
$(PKG)_DEPS :=
$(PKG)_TYPE := source-only
define $(PKG)_BUILD
cd '$(BUILD_DIR)' && $(TARGET)-cmake '$(SOURCE_DIR)'
$(MAKE) -C '$(BUILD_DIR)' -j '$(JOBS)'
$(MAKE) -C '$(BUILD_DIR)' -j 1 install
endef