gtk_doc: replace catalog lookup hack

In the previous commit, we added a setup hook to docbook dtd and xsl
packages, that adds derivation’s catalog file to an environment variable.
That should, in theory, remove the need for declaring their catalogs manually.
Unfortunately, xmlcatalog utility expects exactly one catalog file, completely
disregarding the environment variable in non-interactive context. In the same
spirit, the design of gtk-doc m4 files only admits a single catalog file,
resulting in another ugly hack.
This commit is contained in:
Jan Tojnar 2017-10-07 00:07:40 +02:00
parent 99af040ee1
commit 407db7b019
No known key found for this signature in database
GPG Key ID: 7FAB2A15F7A607A4
2 changed files with 36 additions and 17 deletions

View File

@ -1,4 +1,4 @@
{ stdenv, fetchurl, pkgconfig, perl, python, libxml2Python, libxslt, which { stdenv, fetchurl, autoreconfHook, pkgconfig, perl, python, libxml2Python, libxslt, which
, docbook_xml_dtd_43, docbook_xsl, gnome_doc_utils, dblatex, gettext, itstool }: , docbook_xml_dtd_43, docbook_xsl, gnome_doc_utils, dblatex, gettext, itstool }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
@ -10,29 +10,20 @@ stdenv.mkDerivation rec {
sha256 = "0hpxcij9xx9ny3gs9p0iz4r8zslw8wqymbyababiyl7603a6x90y"; sha256 = "0hpxcij9xx9ny3gs9p0iz4r8zslw8wqymbyababiyl7603a6x90y";
}; };
patches = [
./respect-xml-catalog-files-var.patch
];
outputDevdoc = "out"; outputDevdoc = "out";
# maybe there is a better way to pass the needed dtd and xsl files nativeBuildInputs = [ autoreconfHook ];
# "-//OASIS//DTD DocBook XML V4.1.2//EN" and "http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl"
preConfigure = ''
mkdir -p $out/nix-support
cat > $out/nix-support/catalog.xml << EOF
<?xml version="1.0"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<nextCatalog catalog="${docbook_xsl}/xml/xsl/docbook/catalog.xml" />
<nextCatalog catalog="${docbook_xml_dtd_43}/xml/dtd/docbook/catalog.xml" />
</catalog>
EOF
configureFlags="--with-xml-catalog=$out/nix-support/catalog.xml --disable-scrollkeeper";
'';
buildInputs = buildInputs =
[ pkgconfig perl python libxml2Python libxslt docbook_xml_dtd_43 docbook_xsl [ pkgconfig perl python libxml2Python libxslt docbook_xml_dtd_43 docbook_xsl
gnome_doc_utils dblatex gettext which itstool gnome_doc_utils dblatex gettext which itstool
]; ];
configureFlags = "--disable-scrollkeeper";
meta = with stdenv.lib; { meta = with stdenv.lib; {
homepage = https://www.gtk.org/gtk-doc; homepage = https://www.gtk.org/gtk-doc;
description = "Tools to extract documentation embedded in GTK+ and GNOME source code"; description = "Tools to extract documentation embedded in GTK+ and GNOME source code";

View File

@ -0,0 +1,28 @@
diff --git a/m4/gtkdoc_jh_check_xml_catalog.m4 b/m4/gtkdoc_jh_check_xml_catalog.m4
index 618c1c9..1842a0d 100644
--- a/m4/gtkdoc_jh_check_xml_catalog.m4
+++ b/m4/gtkdoc_jh_check_xml_catalog.m4
@@ -10,7 +10,21 @@ AC_DEFUN([JH_CHECK_XML_CATALOG],
AC_MSG_RESULT([found])
ifelse([$3],,,[$3])
else
- AC_MSG_RESULT([not found])
- ifelse([$4],,[AC_MSG_ERROR([could not find ifelse([$2],,[$1],[$2]) in XML catalog])],[$4])
+ jh_check_xml_catalog_saved_ifs="$IFS"
+ IFS=' '
+ for f in $XML_CATALOG_FILES; do
+ if [[ -f "$f" ]] && \
+ AC_RUN_LOG([$XMLCATALOG --noout "$f" "$1" >&2]); then
+ jh_found_xmlcatalog=true
+ AC_MSG_RESULT([found])
+ ifelse([$3],,,[$3])
+ break
+ fi
+ done
+ IFS="$jh_check_xml_catalog_saved_ifs"
+ if ! $jh_found_xmlcatalog; then
+ AC_MSG_RESULT([not found])
+ ifelse([$4],,[AC_MSG_ERROR([could not find ifelse([$2],,[$1],[$2]) in XML catalog])],[$4])
+ fi
fi
])