From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id oDc/JSUNEmO5tgAAbAwnHQ (envelope-from ) for ; Fri, 02 Sep 2022 16:03:17 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id yPpUJCUNEmPGqgAAG6o9tA (envelope-from ) for ; Fri, 02 Sep 2022 16:03:17 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id DFFB0C917 for ; Fri, 2 Sep 2022 16:03:16 +0200 (CEST) Received: from localhost ([::1]:33744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oU7GO-0004td-2g for larch@yhetil.org; Fri, 02 Sep 2022 10:03:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oU7GB-0004qA-L2 for guix-patches@gnu.org; Fri, 02 Sep 2022 10:03:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:57595) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oU7GA-00018t-47 for guix-patches@gnu.org; Fri, 02 Sep 2022 10:03:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oU7G9-0005rS-UL for guix-patches@gnu.org; Fri, 02 Sep 2022 10:03:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#57280] [PATCH 0/3] Add documentation-files argument to emacs build system. Resent-From: Andrew Tropin Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 02 Sep 2022 14:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57280 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Liliana Marie Prikler Cc: 57280@debbugs.gnu.org Received: via spool by 57280-submit@debbugs.gnu.org id=B57280.166212737822521 (code B ref 57280); Fri, 02 Sep 2022 14:03:01 +0000 Received: (at 57280) by debbugs.gnu.org; 2 Sep 2022 14:02:58 +0000 Received: from localhost ([127.0.0.1]:47344 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oU7G5-0005rA-5p for submit@debbugs.gnu.org; Fri, 02 Sep 2022 10:02:57 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:53675) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oU7G1-0005qq-O4 for 57280@debbugs.gnu.org; Fri, 02 Sep 2022 10:02:55 -0400 Received: (Authenticated sender: andrew@trop.in) by mail.gandi.net (Postfix) with ESMTPSA id 8CFFA240006; Fri, 2 Sep 2022 14:02:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop.in; s=gm1; t=1662127367; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0EwNg86zb8Hcd8tLlcqYfiY3MrnpAWmw2At2YJsKIdE=; b=Soucy1jp9lYK1WJ4rMx9PNwF519Ug5ojckCFjWOB4AIs0LuXMMKpJVNkPpX+5YTEljFC/7 Gn9reidZTcI5Wnzl7QEJGxHWT0uodvxBnc65+fvU4qVmqPdD4USA1xn1GHXnStsw2oybOM VoWtAgTXCmdoPfanTGvpqjiSLHGLXKps6Z1s6gBZQ9R9jRN9T9rZBhmUqEq1j3mWjY1xfr tyGnxZNW3SwZi4kfEw17sdyhZ+dZGOkHwEZXqEj7xoJooVcUVCdD4wovzMU5I0YVNg5RLo MccTWaKYAk0KiElVhnEfIFyELm2jm7xqCxDxNGmQ5Badi1itkI/FpgNR9uFx9g== From: Andrew Tropin In-Reply-To: <64cd6f7171047bfe95ba9621c4616b9288b7dba9.camel@gmail.com> References: <87v8q8u54p.fsf@trop.in> <64cd6f7171047bfe95ba9621c4616b9288b7dba9.camel@gmail.com> Date: Fri, 02 Sep 2022 17:02:42 +0300 Message-ID: <87czcd3md9.fsf@trop.in> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1662127397; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=0EwNg86zb8Hcd8tLlcqYfiY3MrnpAWmw2At2YJsKIdE=; b=lnGxW51lamcrhyZqKR8ekW09Nq5bJz4o3B98szMZ07ufrlEjBLqbvfVr+MKWRl7S+OvUss BKvyBsb1zwilcSJu5XokcBIN6OALdnVLaP0qQesWq5uAbLx6MqQkhzOdjt8KJFaPrxTotB ja4nWSl4oWegRkKm0aAe4i+1HjXzrLM1eWxA18mWnNrlCq9bCIU9EBLHSsdtT23LdOH+xE baPkjqkqCOKi01OMWo6n8DpkQaxvRw8SsyM51q16BCmP/KmIBQDdtRw+QN5+hoMbG8/0Gg X2EsP0z3xuFdNQX/YefnBMVNP9gZp3AzJSGH9Ud5Ms4Yj03XrqTf0vvqokc4FQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1662127397; a=rsa-sha256; cv=none; b=EWOEUz7PD5khD0np8Oiv6wGJNUT+fCTeSE3mnZjxsaEFs/R4qHDPBcRY3jyrlxujpC6uw5 hkonKAZ0v7bb3Fsqla1/+4PbMVWoXvH6pGjEtsRaQVpYBtLRqe0BzVh+2Z73u6zditWhXZ GMAglgUea/aDPiBhYHRzj2YfIK7jntV7Lcj0Txvtd4wSSU1czw/hgcaTt+qFHdEZ0FKvF2 FPMdyd7Tbg5NEE1TC8mCseSkvjAv7psTXWJCl5HOnXjnLgAQs3LoAtiuu30Ce5Joneav0Q uzhOXp2TcI70FGo++kpHWRWDHp/zfJ8r8Zx3fqjZHZGIyWwjuQzJ9j++Ysv+zw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=Soucy1jp; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -0.07 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=Soucy1jp; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: DFFB0C917 X-Spam-Score: -0.07 X-Migadu-Scanner: scn0.migadu.com X-TUID: hVpP9JkwG6g+ --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2022-08-31 12:07, Liliana Marie Prikler wrote: > Am Mittwoch, dem 31.08.2022 um 12:36 +0300 schrieb Andrew Tropin: >> > I think if we want to go this more generic route, we'd have to >> > redesign this a little.=C2=A0 For instance, (build-texinfo- >> > documentation) should take >> > regular expressions as remaining arguments.=C2=A0=20 >>=20 >> What can be a good place (module) for such build phases? > I was thinking (guix build utils). Of course, one could introduce a > new module, but doing that would come with even more downsides in terms > of UX (or PX if we're pedantic). Ok, I prepared more generic version of the patch. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=v3-0001-build-system-emacs-Add-build-documentation-phase.patch Content-Transfer-Encoding: quoted-printable From=204a706908491daafc0493ab15297665eb2b9fce4e Mon Sep 17 00:00:00 2001 From: Andrew Tropin Date: Fri, 2 Sep 2022 08:23:18 +0300 Subject: [PATCH v3] build-system: emacs: Add build-documentation phase. Allows to build info files from texinfo, org or other markup files. * guix/build-system/emacs.scm (default-texinfo, default-pandoc): New variab= le. (lower)[build-inputs]: Add texinfo and pandoc. * guix/build/emacs-build-system.scm (build-documentantion): New variable. * guix/build/emacs-utils.scm (build-documentantion-texinfo, build-documentation-org, convert-documentation): New variable. * gnu/packages/emacs-xyz.scm (emacs-orderless)[arguments]: Remove custom documentation build phase. (emacs-org)[arguments]: Remove build-documentation as it already builds documentation with make. =2D-- gnu/packages/emacs-xyz.scm | 21 ++++++------- guix/build-system/emacs.scm | 16 +++++++++- guix/build/emacs-build-system.scm | 42 +++++++++++++++++++++++++- guix/build/emacs-utils.scm | 49 +++++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+), 14 deletions(-) diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm index 074d4d1c4c..f6fb76258b 100644 =2D-- a/gnu/packages/emacs-xyz.scm +++ b/gnu/packages/emacs-xyz.scm @@ -2974,6 +2974,7 @@ (define-public emacs-auctex #:exclude '("^tests/" "^latex/README") #:phases (modify-phases %standard-phases + (delete 'build-documentation) (add-after 'unpack 'configure (lambda* (#:key inputs #:allow-other-keys) (emacs-substitute-variables "preview.el" @@ -9155,17 +9156,6 @@ (define-public emacs-orderless (base32 "0m9nyz80j0qnn14drbgk8vn5yr7sv0z6yiz8w95ahcw2qwlgyjs7")) (file-name (git-file-name name version)))) (build-system emacs-build-system) =2D (arguments =2D `(#:phases =2D (modify-phases %standard-phases =2D (add-after 'install 'makeinfo =2D (lambda* (#:key outputs #:allow-other-keys) =2D (invoke "makeinfo" "orderless.texi") =2D (install-file "orderless.info" =2D (string-append (assoc-ref outputs "out") =2D "/share/info"))))))) =2D (native-inputs =2D (list texinfo)) (home-page "https://github.com/oantolin/orderless") (synopsis "Emacs completion style that matches multiple regexps in any= order") (description "This package provides an orderless completion style that @@ -13250,6 +13240,7 @@ (define-public emacs-org #:phases (modify-phases %standard-phases (delete 'build) + (delete 'build-documentation) (add-before 'check 'make (lambda _ (invoke "make" (string-append "ORGVERSION=3D" ,version)))) @@ -17846,7 +17837,13 @@ (define-public emacs-esxml `(#:emacs ,emacs ;need libxml ;; XXX: Only the two following files are meant to be packaged. ;; Byte-compiling the others Elisp files leads to build errors anyw= ay. =2D #:include (list "esxml.el" "esxml-query.el"))) + #:include (list "esxml.el" "esxml-query.el") + #:phases (modify-phases %standard-phases + (add-before 'build-documentation 'fix-readme-org + (lambda _ + (substitute* "README.org" + ;; Fix malformed src block + (("^#\\+BEGIN_SRC\\s$") "#+BEGIN_SRC html"))))))) (propagated-inputs (list emacs-kv)) (home-page "https://github.com/tali713/esxml/") diff --git a/guix/build-system/emacs.scm b/guix/build-system/emacs.scm index 3df68789ff..61746f26a5 100644 =2D-- a/guix/build-system/emacs.scm +++ b/guix/build-system/emacs.scm @@ -56,6 +56,18 @@ (define (default-emacs) (let ((emacs-mod (resolve-interface '(gnu packages emacs)))) (module-ref emacs-mod 'emacs-minimal))) =20 +(define (default-texinfo) + "Return the default texinfo package." + ;; Lazily resolve the binding to avoid a circular dependency. + (let ((texinfo-mod (resolve-interface '(gnu packages texinfo)))) + (module-ref texinfo-mod 'texinfo))) + +(define (default-pandoc) + "Return the default pandoc package." + ;; Lazily resolve the binding to avoid a circular dependency. + (let ((pandoc-mod (resolve-interface '(gnu packages haskell-xyz)))) + (module-ref pandoc-mod 'pandoc))) + (define* (lower name #:key source inputs native-inputs outputs system target (emacs (default-emacs)) @@ -77,7 +89,9 @@ (define private-keywords ;; Keep the standard inputs of 'gnu-build-system'. ,@(standard-packages))) (build-inputs `(("emacs" ,emacs) =2D ,@native-inputs)) + ,@native-inputs + ("pandoc" ,(default-pandoc)) + ("texinfo" ,(default-texinfo)))) (outputs outputs) (build emacs-build) (arguments (strip-keyword-arguments private-keywords arguments)))= )) diff --git a/guix/build/emacs-build-system.scm b/guix/build/emacs-build-sys= tem.scm index 6a6918bfdd..fe03fa975c 100644 =2D-- a/guix/build/emacs-build-system.scm +++ b/guix/build/emacs-build-system.scm @@ -274,6 +274,45 @@ (define (match-stripped-file action regex) (install-file? file stat #:verbose? #t))) #f)))) =20 +(define* (build-documentation #:key outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (library-root (with-directory-excursion (elpa-directory out) + (find-root-library-file + (store-directory->elpa-name-version out)))) + (texi-file-name (if library-root + (string-append library-root ".texi") + #f)) + + (readme-regexp (make-regexp "README.*" regexp/icase)) + (readme-files (find-files "." readme-regexp)) + (readme-file (match readme-files + ((file . _) file) + (_ #f))) + + (texi-regexp (string-append library-root "\\.texi")) + (texinfo-files (find-files "." texi-regexp))) + + (if (null? texinfo-files) + (cond + ((and readme-file (string-suffix? ".org" readme-file)) + ((build-documentation-org #:files (list readme-file)))) + ((and readme-file texi-file-name) + ((convert-documentation #:mapping + `((,readme-file . ,texi-file-name)))) + ((build-documentation-texinfo + #:files (list texi-file-name) + ;; Some README.md can have missing levels of subheadings or + ;; incorrect links, this is why --force is used. Examples of = such + ;; READMEs: emacs-avy, emacs-git-gutter, emacs-f. + #:command '("makeinfo" "--no-split" "--force")))) + (else #t)) + + ((build-documentation-texinfo #:files texinfo-files))) + + (for-each (lambda (f) + (install-file f (string-append out %install-dir))) + (find-files "." "\\.info$")))) + (define* (move-doc #:key outputs #:allow-other-keys) "Move info files from the ELPA package directory to the info directory." (let* ((out (assoc-ref outputs "out")) @@ -357,7 +396,8 @@ (define %standard-phases ;; The .el files are byte compiled directly in the store. (add-after 'ensure-package-description 'build build) (add-after 'build 'validate-compiled-autoloads validate-compiled-autol= oads) =2D (add-after 'validate-compiled-autoloads 'move-doc move-doc))) + (add-after 'validate-compiled-autoloads 'move-doc move-doc) + (add-before 'move-doc 'build-documentation build-documentation))) =20 (define* (emacs-build #:key inputs (phases %standard-phases) #:allow-other-keys #:rest args) diff --git a/guix/build/emacs-utils.scm b/guix/build/emacs-utils.scm index 8ee547f2b3..b7e0a3e939 100644 =2D-- a/guix/build/emacs-utils.scm +++ b/guix/build/emacs-utils.scm @@ -36,6 +36,10 @@ (define-module (guix build emacs-utils) emacs-batch-error? emacs-batch-error-message =20 + build-documentation-texinfo + build-documentation-org + convert-documentation + emacs-generate-autoloads emacs-byte-compile-directory emacs-header-parse @@ -100,6 +104,51 @@ (define (emacs-batch-script expr) (message (read-string (car error-pipe))))))) output)) =20 + +;;; +;;; Helpers for generating frequently used phases. +;;; + +(define* (build-documentation-texinfo + #:key + (files '()) + (command '("makeinfo" "--no-split"))) + "Don't forget to add texinfo into list of inputs for the package." + (lambda* (#:key outputs #:allow-other-keys) + (for-each (lambda (f) (apply invoke (append command (list f)))) files)= )) + +(define* (build-documentation-org + #:key + (files '())) + "This is a preferred way over pandoc, because it keeps the meta informat= ion +from in-buffer org settings. Don't forget to add texinfo and emacs into l= ist +of inputs for the package." + (lambda* (#:key outputs #:allow-other-keys) + (for-each (lambda (f) + (emacs-batch-script + `(progn + (require 'ox-texinfo) + (find-file ,f) + (let ((org-export-use-babel nil) + (org-texinfo-info-process + '("makeinfo --force --no-split %f"))) + (org-texinfo-export-to-info))))) files))) + +(define* (convert-documentation + #:key + (mapping '()) + (command '("pandoc"))) + "Don't forget to add pandoc into list of inputs for the package." + (lambda* (#:key outputs #:allow-other-keys) + (for-each (lambda (p) (apply invoke + (append command + (list (car p) "-o" (cdr p))))) + mapping))) + +;;; +;;; Helpers for generating frequently used phases ends here. +;;; + (define (emacs-generate-autoloads name directory) "Generate autoloads for Emacs package NAME placed in DIRECTORY." (let* ((file (string-append directory "/" name "-autoloads.el")) =2D-=20 2.37.2 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Picked (guix build emacs-utils) for now, it's done to avoid huge rebuilds, while testing, later we can move it to (guix build utils). Also, temporary added pandoc and texinfo to native-inputs for emacs-build-system, otherwise I would need to update inputs for almost every emacs-* package. Need to figure out what to do with this. > >> Attaching the latest version of the documentation-files patch I have > Looking at this patch, perhaps we'd also have to allow customizing > command line options. Also, as for installing, I think this should be > handled by the install phase, which already has includes > "^[^/]*\\.info$" and "^doc/.*\\.info$" by default. Thus, you only need > to build documentation before the install phase. That's right, but in the new iteration (v3) of build-documentation phase I use find-root-library-file, which expects to be executed when elpa directory is already available, so I can't do it before install phase and need to manually install info files. Also, current build phases order is a little confusing, a lot of builds happens after install phase, directly in output directory: `set-SOURCE-DATE-EPOCH' `set-paths' `install-locale' `unpack' `expand-load-path' `patch-usr-bin-file' `patch-source-shebangs' `patch-generated-file-shebangs' `check' `install' `make-autoloads' `enable-autoloads-compilation' `patch-el-files' `ensure-package-description' `build' `validate-compiled-autoloads' `build-documentation' `move-doc' `patch-shebangs' `strip' `validate-runpath' `validate-documentation-location' `delete-info-dir-file' `patch-dot-desktop-files' `make-dynamic-linker-cache' `install-license-files' `reset-gzip-timestamps' `compress-documentation' What if instead of install phase we will use create-tmp-lisp-and-documentation-directories phase (or something more meaningful) to make a temporary directory, where we will build all the stuff and after that, at the end of the build process will install everything from this temporary directory to the store? This way emacs-build-system will become more usual and easier to understand and predict. =2D-=20 Best regards, Andrew Tropin --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmMSDQIACgkQIgjSCVjB 3rDC3w/8CZ4uWjdlz42ocrqmC4VfzurB26Snvrq344qMuuwjgyZneTCAnKfn54mF VdRiB1WB2o0V8LWJK6XZLl19TJ/1X67BX9r84PQ2NLl39FEr3TTHt5iq1jDhW3jA DGnQnkY5conf2Oq5NAEE5byZ3itUECroE4yJXmk0Nwvcu6uUzBKuEC65IF/Emm/d 8NN5mVrJnOBtddvokHhCx1InvOWD6925lkT7zZLkTVDkd3nI1LQulZKjBmSqwMtO mnsfGZyHLG8wFH44WPQiUTUZE3LThE5rBfSMWqZmDZriDZocwDxvw7dPqelegRYU AQXZeQtMefN5lJCKsNHn12biMT8xnZalUgI5TEeY+XzOLexqIEL4iW2gAEwV8LNP nf9mAFqauD8HtGeaVjm20asXcb0mQdIepdZD0Ue5AbZkBKnkVuhc9jheOTQI5MBH YODnvNkJHk5C2JTM2NHgZbCCOUgnwaU2XVwLcKbKE8RJfRjpe6KHmairMQ1ZRwGc ZNtn5yzqYrzAWFx+IEG4MoOCYSWqc0E28mo8PQBnoknBuOesHTzJyohkPkJLzsIN GJCI+YbWJ+/WT8095LyOE8WAE2vdV0g2GHZ9UndWQkQWOyC9SzayczYraLH1DegR yR6T7dPMkqYhetzfhcr28B5K0S9zie9XSWvuJ4mPz+GFbg6K6cY= =CSHW -----END PGP SIGNATURE----- --==-=-=--