From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35301) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gTob1-0008C2-67 for guix-patches@gnu.org; Mon, 03 Dec 2018 08:49:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gToat-0007PC-MJ for guix-patches@gnu.org; Mon, 03 Dec 2018 08:49:11 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:54516) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gToas-0007Ob-3V for guix-patches@gnu.org; Mon, 03 Dec 2018 08:49:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gToar-0002js-Ud for guix-patches@gnu.org; Mon, 03 Dec 2018 08:49:01 -0500 Subject: [bug#33598] Optimizations for emacs-clang-format and emacs-clang-rename Resent-Message-ID: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35033) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gToZu-0007lO-O9 for guix-patches@gnu.org; Mon, 03 Dec 2018 08:48:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gToZq-0006mY-DZ for guix-patches@gnu.org; Mon, 03 Dec 2018 08:48:02 -0500 Received: from sonic302-20.consmr.mail.ir2.yahoo.com ([87.248.110.83]:41594) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gToZp-0006kU-TL for guix-patches@gnu.org; Mon, 03 Dec 2018 08:47:58 -0500 Received: from p5B221942.dip0.t-ipconnect.de (EHLO [192.168.178.27]) ([91.34.25.66]) by smtp420.mail.ir2.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID cba66bd63d721f1f75562a94154c2dd5 for ; Mon, 03 Dec 2018 13:47:51 +0000 (UTC) From: Tim Gesthuizen Message-ID: Date: Mon, 3 Dec 2018 14:47:48 +0100 MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="8ri8gw03ePRZ0hyv10xG8hsXguz2jEw8I" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 33598@debbugs.gnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --8ri8gw03ePRZ0hyv10xG8hsXguz2jEw8I Content-Type: multipart/mixed; boundary="6e0XEx4XazlYAWzA3EeHjBTXO8ymJwMtx"; protected-headers="v1" From: Tim Gesthuizen To: guix-patches@gnu.org Message-ID: Subject: Optimizations for emacs-clang-format and emacs-clang-rename --6e0XEx4XazlYAWzA3EeHjBTXO8ymJwMtx Content-Type: multipart/mixed; boundary="------------F8CB051DF55FEC9A30074256" Content-Language: en-US This is a multi-part message in MIME format. --------------F8CB051DF55FEC9A30074256 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, the attached patches add optimizations to emacs-clang-format and emacs-clang-rename: - Only package the required elisp file in the source - Add a function for generating package definitions of packages containing a single elisp file from the clang source. The patches make clear that the elisp file is the only thing required for building the package and should save some disk space as the packages do not need the full clang source tree. Tim. --------------F8CB051DF55FEC9A30074256 Content-Type: text/x-patch; name="0001-gnu-Shrink-source-for-emacs-clang-format.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-gnu-Shrink-source-for-emacs-clang-format.patch" =46rom 5d85956a30ff1bed8f7c529d4b760bb609ac4ab7 Mon Sep 17 00:00:00 2001 From: Tim Gesthuizen Date: Fri, 30 Nov 2018 14:49:51 +0100 Subject: [PATCH 1/3] gnu: Shrink source for emacs-clang-format. To build emacs-clang-format only the `clang-format.el` file is needed. In= order to save disk space and make clear that this is the only file needed= modify the downloaded source to only contain `clang-format.el`. * gnu/packages/emacs.scm (emacs-clang-format): Add source snippet. * gnu/packages/emacs.scm (emacs-clang-format): Modify phases. --- gnu/packages/llvm.scm | 58 ++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index dace546a4..e7dd6477a 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -461,28 +461,46 @@ code analysis tools.") (license license:bsd-3))) =20 (define-public emacs-clang-format - (package - (inherit clang) - (name "emacs-clang-format") - (build-system emacs-build-system) - (inputs - `(("clang" ,clang))) - (arguments - `(#:phases - (modify-phases %standard-phases - (add-after 'unpack 'configure - (lambda* (#:key inputs #:allow-other-keys) - (let ((clang (assoc-ref inputs "clang"))) - (copy-file "tools/clang-format/clang-format.el" "clang-fo= rmat.el") - (emacs-substitute-variables "clang-format.el" - ("clang-format-executable" - (string-append clang "/bin/clang-format")))) - #t))))) - (synopsis "Format code using clang-format") - (description "This package allows to filter code through @code{clang= -format} + (let ((target-file "clang-format.el")) + (package + (inherit clang) + (name "emacs-clang-format") + (source (let ((orig (package-source clang))) + (origin + (method (origin-method orig)) + (uri (origin-uri orig)) + (sha256 (origin-sha256 orig)) + (modules '((guix build utils) + (srfi srfi-1) + (ice-9 ftw))) + (snippet + `(begin + ;; Copy target file to source root and delete all = other files + (copy-file (string-append "tools/clang-format/" ,t= arget-file) + ,target-file) + (map delete-file-recursively + (fold delete + (scandir ".") + '("." ".." ,target-file))) + #t))))) + (build-system emacs-build-system) + (inputs + `(("clang" ,clang))) + (arguments + `(#:phases + (modify-phases %standard-phases + (add-after 'unpack 'configure + (lambda* (#:key inputs #:allow-other-keys) + (let ((clang (assoc-ref inputs "clang"))) + (emacs-substitute-variables ,target-file + ("clang-format-executable" + (string-append clang "/bin/clang-format")))) + #t))))) + (synopsis "Format code using clang-format") + (description "This package allows to filter code through @code{cla= ng-format} to fix its formatting. @code{clang-format} is a tool that formats C/C++/Obj-C code according to a set of style options, see -@url{http://clang.llvm.org/docs/ClangFormatStyleOptions.html}."))) +@url{http://clang.llvm.org/docs/ClangFormatStyleOptions.html}.")))) =20 (define-public emacs-clang-rename (package --=20 2.19.2 --------------F8CB051DF55FEC9A30074256 Content-Type: text/x-patch; name="0002-gnu-Shrink-source-for-emacs-clang-rename.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0002-gnu-Shrink-source-for-emacs-clang-rename.patch" =46rom 29a1992253908ea191ef0227462972f78ce20da3 Mon Sep 17 00:00:00 2001 From: Tim Gesthuizen Date: Fri, 30 Nov 2018 15:01:10 +0100 Subject: [PATCH 2/3] gnu: Shrink source for emacs-clang-rename. To build emacs-clang-rename only the `clang-rename.el` file is needed. In= order to save disk space and make clear that this is the only file needed= modify the downloaded source to only contain `clang-rename.el`. * gnu/packages/emacs.scm (emacs-clang-rename): Add source snippet. * gnu/packages/emacs.scm (emacs-clang-rename): Modify phases. --- gnu/packages/llvm.scm | 59 ++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index e7dd6477a..3eb0fb29f 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -503,23 +503,42 @@ C/C++/Obj-C code according to a set of style option= s, see @url{http://clang.llvm.org/docs/ClangFormatStyleOptions.html}.")))) =20 (define-public emacs-clang-rename - (package - (inherit clang) - (name "emacs-clang-rename") - (build-system emacs-build-system) - (inputs - `(("clang" ,clang))) - (arguments - `(#:phases - (modify-phases %standard-phases - (add-after 'unpack 'configure - (lambda* (#:key inputs #:allow-other-keys) - (let ((clang (assoc-ref inputs "clang"))) - (copy-file "tools/clang-rename/clang-rename.el" "clang-re= name.el") - (emacs-substitute-variables "clang-rename.el" - ("clang-rename-binary" - (string-append clang "/bin/clang-rename")))) - #t))))) - (synopsis "Rename every occurrence of a symbol using clang-rename") - (description "This package renames every occurrence of a symbol at p= oint -using @code{clang-rename}."))) + (let ((target-file "clang-rename.el")) + (package + (inherit clang) + (name "emacs-clang-rename") + (source (let ((orig (package-source clang))) + (origin + (method (origin-method orig)) + (uri (origin-uri orig)) + (sha256 (origin-sha256 orig)) + (file-name (string-append name + (package-version clang))) + (modules '((guix build utils) + (srfi srfi-1) + (ice-9 ftw))) + (snippet + `(begin + (copy-file (string-append "tools/clang-rename/" ,ta= rget-file) + ,target-file) + (map delete-file-recursively + (fold delete + (scandir ".") + '("." ".." ,target-file))) + #t))))) + (build-system emacs-build-system) + (inputs + `(("clang" ,clang))) + (arguments + `(#:phases + (modify-phases %standard-phases + (add-after 'unpack 'configure + (lambda* (#:key inputs #:allow-other-keys) + (let ((clang (assoc-ref inputs "clang"))) + (emacs-substitute-variables ,target-file + ("clang-rename-binary" + (string-append clang "/bin/clang-rename")))) + #t))))) + (synopsis "Rename every occurrence of a symbol using clang-rename")= + (description "This package renames every occurrence of a symbol at = point +using @code{clang-rename}.")))) --=20 2.19.2 --------------F8CB051DF55FEC9A30074256 Content-Type: text/x-patch; name="0003-gnu-Add-package-from-clang-elisp-file.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0003-gnu-Add-package-from-clang-elisp-file.patch" =46rom e4fdd028c0e71118073aee34c5976a4948b46511 Mon Sep 17 00:00:00 2001 From: Tim Gesthuizen Date: Fri, 30 Nov 2018 15:13:51 +0100 Subject: [PATCH 3/3] gnu: Add package-from-clang-elisp-file emacs-clang-format and emacs-clang-rename both are packages that are buil= d by extracting a single elisp file and building it as an emacs package. This concept is encapsulated in the package-from-clang-elisp-file function. This reduces repeating of concepts in the two package definitio= ns. * gnu/packages/llvm.scm (package-from-clang-elisp-file): New function * gnu/packages/llvm.scm (emacs-clang-format): Use new function * gnu/packages/llvm.scm (emacs-clang-rename): Use new function --- gnu/packages/llvm.scm | 138 +++++++++++++++++++----------------------- 1 file changed, 61 insertions(+), 77 deletions(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index 3eb0fb29f..ad71c967a 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -460,85 +460,69 @@ code analysis tools.") "This package provides a Python binding to LLVM for use in Numba.")= (license license:bsd-3))) =20 +;;; Returns a package definition that packages an emacs-lisp file from t= he +;;; clang source. The package has the name PKGNAME and packages the file= +;;; SRC-FILE from the clang source in its root directory with the name +;;; TARGET-FILE where SUBST substitutions will be performed on the elisp= file +;;; and SYN and DESC as the package synopsis an description. +(define (package-from-clang-elisp-file pkgname src-file target-file subs= t syn desc) + (package + (inherit clang) + (name pkgname) + (source (let ((orig (package-source clang))) + (origin + (method (origin-method orig)) + (uri (origin-uri orig)) + (sha256 (origin-sha256 orig)) + (file-name (string-append pkgname "-" (package-version c= lang))) + (modules '((guix build utils) + (srfi srfi-1) + (ice-9 ftw))) + (snippet + `(begin + ;; Copy target file to source root and delete all ot= her files + (copy-file (string-append ,src-file) + ,target-file) + (map delete-file-recursively + (fold delete + (scandir ".") + '("." ".." ,target-file))) + #t))))) + (build-system emacs-build-system) + (inputs + `(("clang" ,clang))) + (arguments + `(#:phases + (modify-phases %standard-phases + (add-after 'unpack 'configure + (lambda* (#:key inputs #:allow-other-keys) + (let ((clang (assoc-ref inputs "clang"))) + (emacs-substitute-variables ,target-file + ,subst)) + #t))))) + (synopsis syn) + (description desc))) + (define-public emacs-clang-format - (let ((target-file "clang-format.el")) - (package - (inherit clang) - (name "emacs-clang-format") - (source (let ((orig (package-source clang))) - (origin - (method (origin-method orig)) - (uri (origin-uri orig)) - (sha256 (origin-sha256 orig)) - (modules '((guix build utils) - (srfi srfi-1) - (ice-9 ftw))) - (snippet - `(begin - ;; Copy target file to source root and delete all = other files - (copy-file (string-append "tools/clang-format/" ,t= arget-file) - ,target-file) - (map delete-file-recursively - (fold delete - (scandir ".") - '("." ".." ,target-file))) - #t))))) - (build-system emacs-build-system) - (inputs - `(("clang" ,clang))) - (arguments - `(#:phases - (modify-phases %standard-phases - (add-after 'unpack 'configure - (lambda* (#:key inputs #:allow-other-keys) - (let ((clang (assoc-ref inputs "clang"))) - (emacs-substitute-variables ,target-file - ("clang-format-executable" - (string-append clang "/bin/clang-format")))) - #t))))) - (synopsis "Format code using clang-format") - (description "This package allows to filter code through @code{cla= ng-format} + (package-from-clang-elisp-file + "emacs-clang-format" + "tools/clang-format/clang-format.el" + "clang-format.el" + '("clang-format-executable" + (string-append clang "/bin/clang-format")) + "Format code using clang-format" + "This package allows to filter code through @code{clang-format} to fix its formatting. @code{clang-format} is a tool that formats C/C++/Obj-C code according to a set of style options, see -@url{http://clang.llvm.org/docs/ClangFormatStyleOptions.html}.")))) +@url{http://clang.llvm.org/docs/ClangFormatStyleOptions.html}.")) =20 (define-public emacs-clang-rename - (let ((target-file "clang-rename.el")) - (package - (inherit clang) - (name "emacs-clang-rename") - (source (let ((orig (package-source clang))) - (origin - (method (origin-method orig)) - (uri (origin-uri orig)) - (sha256 (origin-sha256 orig)) - (file-name (string-append name - (package-version clang))) - (modules '((guix build utils) - (srfi srfi-1) - (ice-9 ftw))) - (snippet - `(begin - (copy-file (string-append "tools/clang-rename/" ,ta= rget-file) - ,target-file) - (map delete-file-recursively - (fold delete - (scandir ".") - '("." ".." ,target-file))) - #t))))) - (build-system emacs-build-system) - (inputs - `(("clang" ,clang))) - (arguments - `(#:phases - (modify-phases %standard-phases - (add-after 'unpack 'configure - (lambda* (#:key inputs #:allow-other-keys) - (let ((clang (assoc-ref inputs "clang"))) - (emacs-substitute-variables ,target-file - ("clang-rename-binary" - (string-append clang "/bin/clang-rename")))) - #t))))) - (synopsis "Rename every occurrence of a symbol using clang-rename")= - (description "This package renames every occurrence of a symbol at = point -using @code{clang-rename}.")))) + (package-from-clang-elisp-file + "emacs-clang-rename" + "tools/clang-rename/clang-rename.el" + "clang-rename.el" + '("clang-rename-binary" + (string-append clang "/bin/clang-rename")) + "Rename every occurrence of a symbol using clang-rename" + "This package renames every occurrence of a symbol at point +using @code{clang-rename}.")) --=20 2.19.2 --------------F8CB051DF55FEC9A30074256-- --6e0XEx4XazlYAWzA3EeHjBTXO8ymJwMtx-- --8ri8gw03ePRZ0hyv10xG8hsXguz2jEw8I Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEKUiC5+8BRKEri5fa0uWPaa77GdUFAlwFNAUACgkQ0uWPaa77 GdUkugf9G0EIc6l1RM8mKKUNbggh/Orn4I9NLU6d/7X+2Pihco6q4LRTcJW2GxtN xm9oO5yCKW5G9bm2GmhiCewZ1lkoO3uR/xPMa0LLObGmeijQ8YwkSd1gUN0KPUyV MEjKCL+NKiXZfl1v2atUAAg52J8qJ3I4sWlglLnuPdVV8iute4LFbRfuP6FvrFOv t3N1G3wx162Bqd7yQjhT2Bwaqa+6FkoXP6IPkZKYY18uMDdv5EkmYAXj5puPwjX5 /P/sPnGzJz0+3j2lmu+LsM5UoVZUmfZFtga7CQc17PHSVRoOn8BifQezQNF8G81G n7H2NWgt0ROsiaTvpcp7lBPLizQ1Ig== =AB+f -----END PGP SIGNATURE----- --8ri8gw03ePRZ0hyv10xG8hsXguz2jEw8I--