espeak-ng: Fix cross-compiled issues (#445958)

This commit is contained in:
Martin Weinelt
2025-09-25 21:35:52 +00:00
committed by GitHub
2 changed files with 17 additions and 57 deletions
+17 -16
View File
@@ -28,16 +28,17 @@
sonicSupport ? true,
speechPlayerSupport ? true,
ucdSupport ? false,
buildPackages,
}:
let
version = "1.52.0";
version = "1.52.0.1-unstable-2025-09-09";
src = fetchFromGitHub {
owner = "espeak-ng";
repo = "espeak-ng";
tag = version;
hash = "sha256-mmh5QPSVD5YQ0j16R+bEL5vcyWLtTNOJ/irBNzWY3ro=";
rev = "0d451f8c1c6ae837418b823bd9c4cbc574ea9ff5";
hash = "sha256-wpPi+YjSLhsEWfE3KEbL4A7o48qtz9fLRZ/u4xGOM2g=";
};
ucd-tools = stdenv.mkDerivation {
@@ -59,22 +60,14 @@ in
stdenv.mkDerivation rec {
pname = "espeak-ng";
version = "1.52.0";
src = fetchFromGitHub {
owner = "espeak-ng";
repo = "espeak-ng";
tag = version;
hash = "sha256-mmh5QPSVD5YQ0j16R+bEL5vcyWLtTNOJ/irBNzWY3ro=";
};
inherit version src;
patches = [
# https://github.com/espeak-ng/espeak-ng/pull/2274
./libsonic.patch
(fetchpatch {
name = "espeak-ng-text-to-phonemes-with-terminator.patch";
url = "https://github.com/espeak-ng/espeak-ng/commit/2108b1e8ae02f49cc909894a1024efdfde6682fd.patch";
hash = "sha256-XjEc1r7F88xZOfeUey0R6Xv6vu4Wy8GtWxXFG2NTf9g=";
name = "libsonic.patch";
url = "https://github.com/espeak-ng/espeak-ng/commit/83e646e711af608fafa8c01dd812cd29e073f644.patch";
hash = "sha256-UHuURyqRy/JVYYJH5EI5J2cpBfCNeTE24sMmheb+D2Q=";
})
]
++ lib.optionals mbrolaSupport [
@@ -98,6 +91,10 @@ stdenv.mkDerivation rec {
ronn
makeWrapper
which
]
# Provide a native espeak-ng when cross compiling so intonations can be built
++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
buildPackages.espeak-ng
];
buildInputs =
@@ -113,6 +110,10 @@ stdenv.mkDerivation rec {
(lib.cmakeBool "USE_LIBSONIC" sonicSupport)
(lib.cmakeBool "USE_MBROLA" mbrolaSupport)
(lib.cmakeBool "USE_SPEECHPLAYER" speechPlayerSupport)
]
# Point CMake to the native builds binary dir when cross compiling
++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
"-DNativeBuild_DIR=${buildPackages.espeak-ng}/bin/"
];
postInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
@@ -127,7 +128,7 @@ stdenv.mkDerivation rec {
meta = {
description = "Speech synthesizer that supports more than hundred languages and accents";
homepage = "https://github.com/espeak-ng/espeak-ng";
changelog = "https://github.com/espeak-ng/espeak-ng/blob/${src.tag}/ChangeLog.md";
changelog = "https://github.com/espeak-ng/espeak-ng/blob/${src.rev}/ChangeLog.md";
license = lib.licenses.gpl3Plus;
maintainers = with lib.maintainers; [ aske ];
platforms = lib.platforms.all;
@@ -1,41 +0,0 @@
diff --git a/cmake/deps.cmake b/cmake/deps.cmake
index b63ced21..2cd1727b 100644
--- a/cmake/deps.cmake
+++ b/cmake/deps.cmake
@@ -13,20 +13,22 @@ endif(PTHREAD_LIB)
if (MBROLA_BIN)
set(HAVE_MBROLA ON)
endif(MBROLA_BIN)
-if (SONIC_LIB AND SONIC_INC)
- set(HAVE_LIBSONIC ON)
-else()
- FetchContent_Declare(sonic-git
- GIT_REPOSITORY https://github.com/waywardgeek/sonic.git
- GIT_TAG fbf75c3d6d846bad3bb3d456cbc5d07d9fd8c104
- )
- FetchContent_MakeAvailable(sonic-git)
- FetchContent_GetProperties(sonic-git)
- add_library(sonic OBJECT ${sonic-git_SOURCE_DIR}/sonic.c)
- target_include_directories(sonic PUBLIC ${sonic-git_SOURCE_DIR})
- set(HAVE_LIBSONIC ON)
- set(SONIC_LIB sonic)
- set(SONIC_INC ${sonic-git_SOURCE_DIR})
+if (USE_LIBSONIC)
+ if (SONIC_LIB AND SONIC_INC)
+ set(HAVE_LIBSONIC ON)
+ else()
+ FetchContent_Declare(sonic-git
+ GIT_REPOSITORY https://github.com/waywardgeek/sonic.git
+ GIT_TAG fbf75c3d6d846bad3bb3d456cbc5d07d9fd8c104
+ )
+ FetchContent_MakeAvailable(sonic-git)
+ FetchContent_GetProperties(sonic-git)
+ add_library(sonic OBJECT ${sonic-git_SOURCE_DIR}/sonic.c)
+ target_include_directories(sonic PUBLIC ${sonic-git_SOURCE_DIR})
+ set(HAVE_LIBSONIC ON)
+ set(SONIC_LIB sonic)
+ set(SONIC_INC ${sonic-git_SOURCE_DIR})
+ endif()
endif()
if (PCAUDIO_LIB AND PCAUDIO_INC)
set(HAVE_LIBPCAUDIO ON)