2021-02-05 17:12:51 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, pkg-config, glib, freetype, cairo, libintl
|
2020-09-25 04:45:31 +00:00
|
|
|
, meson, ninja
|
2020-08-20 17:08:02 +00:00
|
|
|
, gobject-introspection
|
2020-04-24 23:36:52 +00:00
|
|
|
, icu, graphite2, harfbuzz # The icu variant uses and propagates the non-icu one.
|
|
|
|
, ApplicationServices, CoreText
|
|
|
|
, withCoreText ? false
|
|
|
|
, withIcu ? false # recommended by upstream as default, but most don't needed and it's big
|
|
|
|
, withGraphite2 ? true # it is small and major distros do include it
|
2020-09-25 04:45:31 +00:00
|
|
|
, python3
|
|
|
|
, gtk-doc, docbook-xsl-nons, docbook_xml_dtd_43
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2021-03-09 03:18:52 +00:00
|
|
|
version = "2.7.4";
|
2021-02-05 17:12:51 +00:00
|
|
|
inherit (lib) optional optionals optionalString;
|
2020-09-25 04:45:31 +00:00
|
|
|
mesonFeatureFlag = opt: b:
|
|
|
|
"-D${opt}=${if b then "enabled" else "disabled"}";
|
2020-04-24 23:36:52 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "harfbuzz${optionalString withIcu "-icu"}-${version}";
|
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "harfbuzz";
|
|
|
|
repo = "harfbuzz";
|
|
|
|
rev = version;
|
2021-03-09 03:18:52 +00:00
|
|
|
sha256 = "sha256-uMkniDNBQ2mxDmeM7K/YQtZ3Avh9RVXYe7XsUErGas8=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
postPatch = ''
|
2020-09-25 04:45:31 +00:00
|
|
|
patchShebangs src/*.py
|
2020-04-24 23:36:52 +00:00
|
|
|
patchShebangs test
|
2021-02-05 17:12:51 +00:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
2020-04-24 23:36:52 +00:00
|
|
|
# ApplicationServices.framework headers have cast-align warnings.
|
|
|
|
substituteInPlace src/hb.hh \
|
|
|
|
--replace '#pragma GCC diagnostic error "-Wcast-align"' ""
|
|
|
|
'';
|
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
outputs = [ "out" "dev" "devdoc" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
outputBin = "dev";
|
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
mesonFlags = [
|
|
|
|
(mesonFeatureFlag "graphite" withGraphite2)
|
|
|
|
(mesonFeatureFlag "icu" withIcu)
|
|
|
|
(mesonFeatureFlag "coretext" withCoreText)
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
nativeBuildInputs = [
|
2020-09-25 04:45:31 +00:00
|
|
|
meson
|
|
|
|
ninja
|
2020-08-20 17:08:02 +00:00
|
|
|
gobject-introspection
|
|
|
|
libintl
|
2021-02-05 17:12:51 +00:00
|
|
|
pkg-config
|
2020-09-25 04:45:31 +00:00
|
|
|
python3
|
|
|
|
gtk-doc
|
|
|
|
docbook-xsl-nons
|
|
|
|
docbook_xml_dtd_43
|
2020-08-20 17:08:02 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildInputs = [ glib freetype cairo ] # recommended by upstream
|
2021-02-05 17:12:51 +00:00
|
|
|
++ lib.optionals withCoreText [ ApplicationServices CoreText ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
propagatedBuildInputs = []
|
|
|
|
++ optional withGraphite2 graphite2
|
|
|
|
++ optionals withIcu [ icu harfbuzz ];
|
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
doCheck = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# Slightly hacky; some pkgs expect them in a single directory.
|
2020-09-25 04:45:31 +00:00
|
|
|
postFixup = optionalString withIcu ''
|
2020-04-24 23:36:52 +00:00
|
|
|
rm "$out"/lib/libharfbuzz.* "$dev/lib/pkgconfig/harfbuzz.pc"
|
|
|
|
ln -s {'${harfbuzz.out}',"$out"}/lib/libharfbuzz.la
|
|
|
|
ln -s {'${harfbuzz.dev}',"$dev"}/lib/pkgconfig/harfbuzz.pc
|
|
|
|
${optionalString stdenv.isDarwin ''
|
|
|
|
ln -s {'${harfbuzz.out}',"$out"}/lib/libharfbuzz.dylib
|
|
|
|
ln -s {'${harfbuzz.out}',"$out"}/lib/libharfbuzz.0.dylib
|
|
|
|
''}
|
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "An OpenType text shaping engine";
|
2020-09-25 04:45:31 +00:00
|
|
|
homepage = "https://harfbuzz.github.io/";
|
2020-04-24 23:36:52 +00:00
|
|
|
maintainers = [ maintainers.eelco ];
|
|
|
|
license = licenses.mit;
|
|
|
|
platforms = with platforms; linux ++ darwin;
|
|
|
|
};
|
|
|
|
}
|