From patchwork Mon Dec 3 13:47:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gesthuizen X-Patchwork-Id: 378 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 9FF6D167E4; Mon, 3 Dec 2018 13:49:19 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) by mira.cbaines.net (Postfix) with ESMTPS id BD6CE167E2 for ; Mon, 3 Dec 2018 13:49:18 +0000 (GMT) Received: from localhost ([::1]:48589 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gTob7-0008EM-J6 for patchwork@mira.cbaines.net; Mon, 03 Dec 2018 08:49:17 -0500 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 X-Loop: help-debbugs@gnu.org Subject: [bug#33598] Optimizations for emacs-clang-format and emacs-clang-rename Resent-From: Tim Gesthuizen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 03 Dec 2018 13:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 33598 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 33598@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.154384489510455 (code B ref -1); Mon, 03 Dec 2018 13:49:01 +0000 Received: (at submit) by debbugs.gnu.org; 3 Dec 2018 13:48:15 +0000 Received: from localhost ([127.0.0.1]:58774 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gToa6-0002iW-PV for submit@debbugs.gnu.org; Mon, 03 Dec 2018 08:48:15 -0500 Received: from eggs.gnu.org ([208.118.235.92]:53662) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gToa4-0002iJ-WB for submit@debbugs.gnu.org; Mon, 03 Dec 2018 08:48:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gToZx-0006sA-Us for submit@debbugs.gnu.org; Mon, 03 Dec 2018 08:48:07 -0500 Received: from lists.gnu.org ([2001:4830:134:3::11]:58918) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gToZx-0006rz-QV for submit@debbugs.gnu.org; Mon, 03 Dec 2018 08:48:05 -0500 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s2048; t=1543844876; bh=WYYiiPIet14MZbOzZ3GVdbTKhjp6+K7ndgZ5GDA5B8M=; h=To:From:Subject:Date:From:Subject; b=ZhMUc/UiNRtYbL+sxUTFxKi2TcnGEfCciXLbjS3puT0FGI8L6TVC/5DuA2ZnpcJ9YGgAuAliEYZaERHW+tqY4rF1HlADZT1tK3sNfMxhMcCECNlGJYHFtWI/x7/plhvStlqny1Z5MzrkvIkIk86Eb0y7lKGdepN5OqERXwWZYoOfEZkvMHN5lK20s+BEVqFetkt/mULf9K/+EB1ASGNAd+lp6f6G9n0x8SQwM877E4WI7wLvmXdqTMGNOfTVEG4irCM71eyYu3w4kDS3heX89GXGrEUcj7PLQmJpUF92niIPlfgag7ncFfuyHxqtKuWUE47hT8Ejk0tvzTCDSSKj7g== X-YMail-OSG: 54t.iskVM1nRJHqaNuHCrHrG._gwRxTSQllR4Vu9rhJNNQT_i6uLTgc4aOgZ2DR ZUbjiPxRxLjxvp1JK4R43SooEaJcuVP0ZutOFn337HZqD.e7VUfdfM99IWfPl1TVBopDQouL3YWa O9kuA8GhjLP61K2eOTpYNrYTLKNvLSXEAM8zR0tgaHvTNSUlJbPXvcZ0q6g6xMeE2Y4I5OmZZ3m0 BWdMNDCjwxQVgkgpRICD7D4IVTHVKOMryRRgE2WQhiM7xPmuzQXf6paGCUcXSlxmXhSADvr.JTUl C.k901J17Bx0sB6RcO1_aQDpf9k4yqzOZZTgGEB9D69ddm3Npafrr_d_zmpW4xUDmdUPOHyRK_i0 uMHCZb5cy99zF2nKHRS6njHxUcReElkXvBngCXgi5_p0oyLD31CzHy3U8rIyJCWeCqDhtadIXu34 pZChYYGFLGtSNcfBh9PGkJl1ZVENg1QL78.yUgWn1L22Wc.LTwqL1M0h253Xn7IUon1XY2gE7Zrj 53v0.Q5qfa8p0tFA5PKj3T_jddfg46U8GHtGs2h9zI842kpYbSVSHV4WIuwxzaq1xJk9Zly5A2Ju sqoExAXhdDzDZ90G_edeSdpnEOqDtDJagKKY9Q5Rm2lqicC56dTv3bZLZGnnotD21Io5iH5GavgZ eIMGEyVvp3w18Ah6zR5Wcx1dKlMNvAuB.OM99RMviOeBKShG9rrKc5eBYeA6AePzGdltWgR55F0s BpfFRwdawunwnihkJAOX2t9Kh2QvL8ssDnBqf09LvCD66Q74rqBek4RDMG7zH.fbwQAW8NCOvOmr ujk2Lnp3p370MvLcLNZ6hnclFrDpDMMPo7T1o6PyLOmJfSjkgU62aDt0Zqx02PRzKmFFcE7pASjM BUcPn47kRMMiP7C.9Iayc3uDm5AIbKjKi_QxAfbvlBTQjx1F7elvccR0caqn40Nan8YlklZ4OHY2 GTi6ros6BmTf6u9yLefBX7ebilO8CeafYw6E92Xnomfy_P8Mcj698rBDy6cgr48JU2RuXazfjeOb e4rA72XFjLK70K75pxI7UH3QojnDDaBvO8GfuALHq78Qhy57bhThNHt.w7.GjZJIjswmUPy1__T4 6qImGlzGm Received: from sonic.gate.mail.ne1.yahoo.com by sonic302.consmr.mail.ir2.yahoo.com with HTTP; Mon, 3 Dec 2018 13:47:56 +0000 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 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches 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. From 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 build 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 definitions. * 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))) +;;; Returns a package definition that packages an emacs-lisp file from the +;;; 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 subst 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 clang))) + (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 ,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/" ,target-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{clang-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}.")) (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/" ,target-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}.")) -- 2.19.2