Files
nixpkgs/pkgs/development/libraries/silgraphite/graphite2.nix
T
Ihar Hrachyshka 567e8dfd8e treewide: clean up 'meta = with' pattern
This commit was created by a combination of scripts and tools:
- an ast-grep script to prefix things in meta with `lib.`,
- a modified nixf-diagnose / nixf combination to remove unused `with
lib;`, and
- regular nixfmt.

Co-authored-by: Wolfgang Walther <walther@technowledgy.de>
2025-12-10 18:09:49 +01:00

110 lines
2.9 KiB
Nix

{
lib,
stdenv,
llvmPackages,
fetchpatch,
fetchurl,
pkg-config,
freetype,
cmake,
static ? stdenv.hostPlatform.isStatic,
testers,
}:
stdenv.mkDerivation (finalAttrs: {
version = "1.3.14";
pname = "graphite2";
src = fetchurl {
url =
with finalAttrs;
"https://github.com/silnrsi/graphite/releases/download/${version}/${pname}-${version}.tgz";
sha256 = "1790ajyhk0ax8xxamnrk176gc9gvhadzy78qia4rd8jzm89ir7gr";
};
outputs = [
"out"
"dev"
];
nativeBuildInputs = [
pkg-config
cmake
];
buildInputs = [
freetype
]
++ lib.optional (stdenv.targetPlatform.useLLVM or false) (
llvmPackages.compiler-rt.override {
doFakeLibgcc = true;
}
);
patches = [
# Fix build with gcc15
(fetchpatch {
url = "https://src.fedoraproject.org/rpms/graphite2/raw/deba28323b0a3b7a3dcfd06df1efc2195b102ed7/f/graphite2-1.3.14-gcc15.patch";
hash = "sha256-vkkGkHkcsj1mD3OHCHLWWgpcmFDv8leC4YQm+TsbIUw=";
})
]
++ lib.optionals stdenv.hostPlatform.isDarwin [ ./macosx.patch ];
postPatch = ''
# disable broken 'nametabletest' test, fails on gcc-13:
# https://github.com/silnrsi/graphite/pull/74
substituteInPlace tests/CMakeLists.txt \
--replace 'add_subdirectory(nametabletest)' '#add_subdirectory(nametabletest)'
# support cross-compilation by using target readelf binary:
substituteInPlace Graphite.cmake \
--replace 'readelf' "${stdenv.cc.targetPrefix}readelf"
# headers are located in the dev output:
substituteInPlace CMakeLists.txt \
--replace-fail ' ''${CMAKE_INSTALL_PREFIX}/include' " ${placeholder "dev"}/include"
# Fix the build with CMake 4.
#
# See: <https://github.com/silnrsi/graphite/issues/98>
badCmakeFiles=(
CMakeLists.txt
src/CMakeLists.txt
tests/{bittwiddling,json,sparsetest,utftest}/CMakeLists.txt
gr2fonttest/CMakeLists.txt
)
for file in "''${badCmakeFiles[@]}"; do
substituteInPlace "$file" \
--replace-fail \
'CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0 FATAL_ERROR)' \
'CMAKE_MINIMUM_REQUIRED(VERSION 3.10 FATAL_ERROR)'
done
'';
cmakeFlags = lib.optionals static [
"-DBUILD_SHARED_LIBS=OFF"
];
# Remove a test that fails to statically link (undefined reference to png and
# freetype symbols)
postConfigure = lib.optionalString static ''
sed -e '/freetype freetype.c/d' -i ../tests/examples/CMakeLists.txt
'';
doCheck = true;
passthru.tests = {
pkg-config = testers.hasPkgConfigModules {
package = finalAttrs.finalPackage;
};
};
meta = {
description = "Advanced font engine";
homepage = "https://graphite.sil.org/";
license = lib.licenses.lgpl21;
maintainers = [ lib.maintainers.raskin ];
pkgConfigModules = [ "graphite2" ];
mainProgram = "gr2fonttest";
platforms = lib.platforms.unix ++ lib.platforms.windows;
};
})