diff options
author | Autumn | 2022-02-01 15:24:11 -0800 |
---|---|---|
committer | Autumn | 2022-02-01 16:19:52 -0800 |
commit | 0c9ef997e22a06888e78e11af51d8108b4ac0013 (patch) | |
tree | 68d112d2cc29d85439ff39bf7efcb8a5eb55a204 | |
parent | 79709aa14cd14b3ecb35353797d02fdf79fcf072 (diff) | |
download | aur-0c9ef997e22a06888e78e11af51d8108b4ac0013.tar.gz |
make speech-dispatcher an optional dependency
-rw-r--r-- | .SRCINFO | 4 | ||||
-rw-r--r-- | PKGBUILD | 12 | ||||
-rw-r--r-- | libspeechd-dlopen.patch | 159 |
3 files changed, 172 insertions, 3 deletions
@@ -21,13 +21,15 @@ pkgbase = gargoyle depends = libjpeg depends = libpng depends = zlib - depends = speech-dispatcher + optdepends = speech-dispatcher: Text-to-Speech provides = gargoyle conflicts = gargoyle-mod replaces = gargoyle-mod source = gargoyle-2022.1.tar.gz::https://github.com/garglk/garglk/archive/2022.1.tar.gz + source = libspeechd-dlopen.patch source = gargoyle.install sha512sums = 10b9ccc4bb6bed83780f8d7bf2d36650c8f7c4e14204fe5372e972f8d6900c69846d601670db55ec369e313a75c34ef88fd873f158729af0d4d9a6d8c5c6a1e1 + sha512sums = d1381db41a973ccd4ae7bfccb089a48ca851a3c6a4ba8c1e07e8e195e7429b1d96d3bacec6a651aa108e8ecc17d9bc3eb78d368309cf134f80af9b699c3c2d4d sha512sums = 1fa602865745c1c9801178ee9b24be86215f2af4f9ee3f4f3b3c0606a87aba32a67c9c5343b481332c8fc97ff6c1a5e447f074d116c0cc5b255af35098096e6e pkgname = gargoyle @@ -12,23 +12,31 @@ pkgdesc="Interactive Fiction multi-interpreter that supports all major IF format arch=('i686' 'x86_64' 'armv6h' 'armv7h' 'aarch64') url="http://ccxvii.net/gargoyle/" license=('GPL') -depends=('sdl2_mixer' 'sdl2' 'freetype2' 'qt5-base' 'fontconfig' 'libjpeg' 'libpng' 'zlib' 'speech-dispatcher') +depends=('sdl2_mixer' 'sdl2' 'freetype2' 'qt5-base' 'fontconfig' 'libjpeg' 'libpng' 'zlib') makedepends=('cmake' 'pkgconfig' 'desktop-file-utils') +optdepends=('speech-dispatcher: Text-to-Speech') provides=('gargoyle') conflicts=('gargoyle-mod') replaces=('gargoyle-mod') #groups=(inform) source=("${pkgname}-${pkgver}.tar.gz::https://github.com/garglk/garglk/archive/${pkgver}.tar.gz" \ + "libspeechd-dlopen.patch" "gargoyle.install") install=${pkgname}.install sha512sums=('10b9ccc4bb6bed83780f8d7bf2d36650c8f7c4e14204fe5372e972f8d6900c69846d601670db55ec369e313a75c34ef88fd873f158729af0d4d9a6d8c5c6a1e1' + 'd1381db41a973ccd4ae7bfccb089a48ca851a3c6a4ba8c1e07e8e195e7429b1d96d3bacec6a651aa108e8ecc17d9bc3eb78d368309cf134f80af9b699c3c2d4d' '1fa602865745c1c9801178ee9b24be86215f2af4f9ee3f4f3b3c0606a87aba32a67c9c5343b481332c8fc97ff6c1a5e447f074d116c0cc5b255af35098096e6e') +prepare() { + cd "${srcdir}/garglk-${pkgver}" + patch -Np1 -i "${srcdir}/libspeechd-dlopen.patch" +} + build() { cd "${srcdir}/garglk-${pkgver}" mkdir -p build cd build - cmake .. -DWITH_TTS=ON -DCMAKE_INSTALL_PREFIX=/usr + cmake .. -DWITH_TTS=DYNAMIC -DCMAKE_INSTALL_PREFIX=/usr make } diff --git a/libspeechd-dlopen.patch b/libspeechd-dlopen.patch new file mode 100644 index 000000000000..55a8d326ab94 --- /dev/null +++ b/libspeechd-dlopen.patch @@ -0,0 +1,159 @@ +From d50e9abd62ab3942c5a7e2a9950c7fa62a967112 Mon Sep 17 00:00:00 2001 +From: Autumn <autumn@cyfox.net> +Date: Mon, 31 Jan 2022 17:19:46 -0800 +Subject: [PATCH] support loading libspeechd with dlopen + +--- + garglk/CMakeLists.txt | 12 ++++-- + garglk/ttsspeechd.cpp | 97 ++++++++++++++++++++++++++++++++++++++++++- + 2 files changed, 104 insertions(+), 5 deletions(-) + +diff --git a/garglk/CMakeLists.txt b/garglk/CMakeLists.txt +index 253990bb..c34e3c26 100644 +--- a/garglk/CMakeLists.txt ++++ b/garglk/CMakeLists.txt +@@ -16,7 +16,7 @@ else() + set(INTERFACE "QT") + endif() + +-set(WITH_TTS "AUTO" CACHE STRING "Enable text-to-speech support (ON/OFF/AUTO)") ++set(WITH_TTS "AUTO" CACHE STRING "Enable text-to-speech support (ON/OFF/AUTO/DYNAMIC)") + set(GARGLKPRE "" CACHE STRING "Binary prefix") + set(SOUND "SDL" CACHE STRING "Backend to use for sound (SDL, QT, or none)") + +@@ -172,9 +172,15 @@ if(WITH_TTS) + set(TTS_REQUIRED "REQUIRED") + endif() + +- pkg_check_modules(SPEECH_DISPATCHER ${TTS_REQUIRED} IMPORTED_TARGET speech-dispatcher) ++ if(NOT WITH_TTS STREQUAL "DYNAMIC") ++ pkg_check_modules(SPEECH_DISPATCHER ${TTS_REQUIRED} IMPORTED_TARGET speech-dispatcher) ++ endif() + +- if(SPEECH_DISPATCHER_FOUND) ++ if(WITH_TTS STREQUAL "DYNAMIC") ++ target_sources(garglk PRIVATE ttsspeechd.cpp) ++ target_link_libraries(garglk PRIVATE ${CMAKE_DL_LIBS}) ++ target_compile_definitions(garglk PRIVATE "GARGLK_DLOPEN_LIBSPEECHD") ++ elseif(SPEECH_DISPATCHER_FOUND) + target_sources(garglk PRIVATE ttsspeechd.cpp) + target_link_libraries(garglk PRIVATE PkgConfig::SPEECH_DISPATCHER) + else() +diff --git a/garglk/ttsspeechd.cpp b/garglk/ttsspeechd.cpp +index a28f7438..9b86205a 100644 +--- a/garglk/ttsspeechd.cpp ++++ b/garglk/ttsspeechd.cpp +@@ -23,11 +23,65 @@ + + #include <vector> + +-#include <libspeechd.h> +- + #include "glk.h" + #include "garglk.h" + ++#ifdef GARGLK_DLOPEN_LIBSPEECHD ++ ++#include <dlfcn.h> ++#include <iostream> ++ ++/* Redefine some types from libspeechd.h */ ++ ++typedef enum { ++ SPD_IMPORTANT = 1, ++ SPD_MESSAGE = 2, ++ SPD_TEXT = 3, ++ SPD_NOTIFICATION = 4, ++ SPD_PROGRESS = 5 ++} SPDPriority; ++ ++typedef enum { ++ SPD_MODE_SINGLE = 0, ++ SPD_MODE_THREADED = 1 ++} SPDConnectionMode; ++ ++struct SPDConnection; ++ ++/* Prefix names of libspeechd symbols with underscores ++ * in this file to avoid any possible conflicts */ ++ ++#define spd_open _spd_open ++#define spd_set_language _spd_set_language ++#define spd_say _spd_say ++#define spd_cancel _spd_cancel ++#define spd_close _spd_close ++ ++#define LIBSPEECHD_FUNCS \ ++ FUNC( \ ++ spd_open, \ ++ SPDConnection*, \ ++ (const char*, const char*, const char*, SPDConnectionMode) \ ++ ) \ ++ FUNC(spd_set_language, int, (SPDConnection*, const char*)) \ ++ FUNC(spd_say, int, (SPDConnection*, SPDPriority, const char*)) \ ++ FUNC(spd_cancel, int, (SPDConnection*)) \ ++ FUNC(spd_close, void, (SPDConnection*)) ++ ++#define FUNC(name, type, params) \ ++ typedef type(*name##_fn) params; \ ++ static name##_fn name; ++ ++LIBSPEECHD_FUNCS ++ ++#undef FUNC ++ ++#else ++ ++#include <libspeechd.h> ++ ++#endif ++ + static SPDConnection *spd; + static std::vector<glui32> txtbuf; + +@@ -35,6 +89,45 @@ void gli_initialize_tts(void) + { + if (gli_conf_speak) + { ++#ifdef GARGLK_DLOPEN_LIBSPEECHD ++ void *libspeechd = dlopen("libspeechd.so.2", RTLD_LAZY | RTLD_LOCAL); ++ ++ if (libspeechd == nullptr) ++ { ++ std::cerr << ++ "Failed to load libspeechd. " ++ "Text-to-speech will be disabled." << ++ std::endl; ++ return; ++ } ++ ++ /* Firefox checks for ABI compatibility by checking whether the ++ * spd_get_volume symbol exists, so we follow their lead. */ ++ if (dlsym(libspeechd, "spd_get_volume") == nullptr) ++ { ++ std::cerr << ++ "An unsupported version of libspeechd was found. " ++ "Text-to-speech will be disabled." << ++ std::endl; ++ return; ++ } ++ ++#define FUNC(name, type, params) \ ++ name = (name##_fn) dlsym(libspeechd, #name); \ ++ if (name == nullptr) \ ++ { \ ++ std::cerr << \ ++ "The symbol \"" << #name << "\" wasn't found in libspeechd. " \ ++ "Text-to-speech will be disabled." << \ ++ std::endl; \ ++ return; \ ++ } ++ ++ LIBSPEECHD_FUNCS ++ ++#undef FUNC ++#endif ++ + spd = spd_open("gargoyle", "main", nullptr, SPD_MODE_SINGLE); + + if (spd != nullptr && !gli_conf_speak_language.empty()) |