From beec284f12caec18995be40c7a1cb9e254f83ec7 Mon Sep 17 00:00:00 2001 From: Tim Gesthuizen Date: Fri, 30 Nov 2018 14:49:51 +0100 Subject: [PATCH 1/5] 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 7eb785c36..cf7c44600 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -480,28 +480,46 @@ code analysis tools.") (license license:bsd-3))) (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-format.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/" ,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} 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 address@hidden://clang.llvm.org/docs/ClangFormatStyleOptions.html}."))) address@hidden://clang.llvm.org/docs/ClangFormatStyleOptions.html}.")))) (define-public emacs-clang-rename (package -- 2.20.1