gnu: hdf-java: Fix build.
[jackhill/guix/guix.git] / gnu / packages / llvm.scm
CommitLineData
3e4249ce 1;;; GNU Guix --- Functional package management for GNU
fc9dbf41 2;;; Copyright © 2014, 2016, 2018 Eric Bavier <bavier@member.fsf.org>
1204c510 3;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
286bea0d 4;;; Copyright © 2015, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
ee077430 5;;; Copyright © 2016 Dennis Mungai <dmngaie@gmail.com>
9f0ce5ec 6;;; Copyright © 2016, 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
584da12d 7;;; Copyright © 2017 Roel Janssen <roel@gnu.org>
d199a4c7 8;;; Copyright © 2018, 2019 Marius Bakke <mbakke@fastmail.com>
148df605 9;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
0627f93d 10;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
7628ff1f
TG
11;;; Copyright © 2018 Tim Gesthuizen <tim.gesthuizen@yahoo.de>
12;;; Copyright © 2018 Pierre Neidhardt <mail@ambrevar.xyz>
3e4249ce
EB
13;;;
14;;; This file is part of GNU Guix.
15;;;
16;;; GNU Guix is free software; you can redistribute it and/or modify it
17;;; under the terms of the GNU General Public License as published by
18;;; the Free Software Foundation; either version 3 of the License, or (at
19;;; your option) any later version.
20;;;
21;;; GNU Guix is distributed in the hope that it will be useful, but
22;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24;;; GNU General Public License for more details.
25;;;
26;;; You should have received a copy of the GNU General Public License
27;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
28
29(define-module (gnu packages llvm)
30 #:use-module (guix packages)
ac00973c 31 #:use-module ((guix licenses) #:prefix license:)
3e4249ce
EB
32 #:use-module (guix download)
33 #:use-module (guix utils)
34 #:use-module (guix build-system gnu)
35 #:use-module (guix build-system cmake)
7628ff1f 36 #:use-module (guix build-system emacs)
8892cac3 37 #:use-module (guix build-system python)
3e4249ce 38 #:use-module (gnu packages)
fd6ae1b9
LC
39 #:use-module (gnu packages gcc)
40 #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker
ee077430
EB
41 #:use-module (gnu packages compression)
42 #:use-module (gnu packages libffi)
3e4249ce
EB
43 #:use-module (gnu packages perl)
44 #:use-module (gnu packages python)
45 #:use-module (gnu packages xml))
46
47(define-public llvm
48 (package
49 (name "llvm")
d199a4c7 50 (version "7.0.1")
3e4249ce
EB
51 (source
52 (origin
53 (method url-fetch)
3bdcc668 54 (uri (string-append "https://llvm.org/releases/"
3e4249ce
EB
55 version "/llvm-" version ".src.tar.xz"))
56 (sha256
57 (base32
d199a4c7 58 "16s196wqzdw4pmri15hadzqgdi926zln3an2viwyq0kini6zr3d3"))))
3e4249ce
EB
59 (build-system cmake-build-system)
60 (native-inputs
3ebc0905 61 `(("python" ,python-2) ;bytes->str conversion in clang>=3.7 needs python-2
3e4249ce 62 ("perl" ,perl)))
ee077430 63 (inputs
44e8559d
EB
64 `(("libffi" ,libffi)))
65 (propagated-inputs
66 `(("zlib" ,zlib))) ;to use output from llvm-config
3e4249ce 67 (arguments
22d0e9b7 68 `(#:configure-flags '("-DCMAKE_SKIP_BUILD_RPATH=FALSE"
ee077430 69 "-DCMAKE_BUILD_WITH_INSTALL_RPATH=FALSE"
ab78618f 70 "-DBUILD_SHARED_LIBS:BOOL=TRUE"
22897187 71 "-DLLVM_ENABLE_FFI:BOOL=TRUE"
fc9dbf41 72 "-DLLVM_REQUIRES_RTTI=1" ; For some third-party utilities
22897187 73 "-DLLVM_INSTALL_UTILS=ON") ; Needed for rustc.
0935fb27
EB
74
75 ;; Don't use '-g' during the build, to save space.
ab78618f
EB
76 #:build-type "Release"
77 #:phases (modify-phases %standard-phases
78 (add-before 'build 'shared-lib-workaround
79 ;; Even with CMAKE_SKIP_BUILD_RPATH=FALSE, llvm-tblgen
80 ;; doesn't seem to get the correct rpath to be able to run
81 ;; from the build directory. Set LD_LIBRARY_PATH as a
82 ;; workaround.
83 (lambda _
84 (setenv "LD_LIBRARY_PATH"
85 (string-append (getcwd) "/lib"))
86 #t)))))
ac97dce1 87 (home-page "https://www.llvm.org")
3e4249ce
EB
88 (synopsis "Optimizing compiler infrastructure")
89 (description
e881752c
AK
90 "LLVM is a compiler infrastructure designed for compile-time, link-time,
91runtime, and idle-time optimization of programs from arbitrary programming
92languages. It currently supports compilation of C and C++ programs, using
93front-ends derived from GCC 4.0.1. A new front-end for the C family of
94languages is in development. The compiler infrastructure includes mirror sets
95of programming tools as well as libraries with equivalent functionality.")
ac00973c 96 (license license:ncsa)))
3e4249ce 97
6b26f915
LC
98(define* (clang-runtime-from-llvm llvm hash
99 #:optional (patches '()))
b81f5693
AW
100 (package
101 (name "clang-runtime")
102 (version (package-version llvm))
103 (source
104 (origin
105 (method url-fetch)
3bdcc668 106 (uri (string-append "https://llvm.org/releases/"
b81f5693 107 version "/compiler-rt-" version ".src.tar.xz"))
6b26f915
LC
108 (sha256 (base32 hash))
109 (patches (map search-patch patches))))
b81f5693
AW
110 (build-system cmake-build-system)
111 (native-inputs (package-native-inputs llvm))
112 (inputs
113 `(("llvm" ,llvm)))
114 (arguments
115 `(;; Don't use '-g' during the build to save space.
3b956a33
EB
116 #:build-type "Release"
117 #:tests? #f)) ; Tests require gtest
ac97dce1 118 (home-page "https://compiler-rt.llvm.org")
b81f5693
AW
119 (synopsis "Runtime library for Clang/LLVM")
120 (description
121 "The \"clang-runtime\" library provides the implementations of run-time
122functions for C and C++ programs. It also provides header files that allow C
123and C++ source code to interface with the \"sanitization\" passes of the clang
124compiler. In LLVM this library is called \"compiler-rt\".")
ac00973c 125 (license license:ncsa)
9e6b9ea4 126
ac97dce1 127 ;; <https://compiler-rt.llvm.org/> doesn't list MIPS as supported.
9e6b9ea4 128 (supported-systems (delete "mips64el-linux" %supported-systems))))
b81f5693 129
3b956a33 130(define* (clang-from-llvm llvm clang-runtime hash
9bdbabe9 131 #:key (patches '()))
3e4249ce
EB
132 (package
133 (name "clang")
134 (version (package-version llvm))
135 (source
136 (origin
137 (method url-fetch)
3bdcc668 138 (uri (string-append "https://llvm.org/releases/"
3e4249ce 139 version "/cfe-" version ".src.tar.xz"))
fd6ae1b9 140 (sha256 (base32 hash))
3b956a33 141 (patches (map search-patch patches))))
3e4249ce
EB
142 ;; Using cmake allows us to treat llvm as an external library. There
143 ;; doesn't seem to be any way to do this with clang's autotools-based
144 ;; build system.
145 (build-system cmake-build-system)
146 (native-inputs (package-native-inputs llvm))
147 (inputs
148 `(("libxml2" ,libxml2)
c92f1c0a 149 ("gcc-lib" ,gcc "lib")
3e4249ce
EB
150 ,@(package-inputs llvm)))
151 (propagated-inputs
b81f5693
AW
152 `(("llvm" ,llvm)
153 ("clang-runtime" ,clang-runtime)))
fd6ae1b9
LC
154 (arguments
155 `(#:configure-flags
156 (list "-DCLANG_INCLUDE_TESTS=True"
157
158 ;; Find libgcc_s, crtbegin.o, and crtend.o.
159 (string-append "-DGCC_INSTALL_PREFIX="
160 (assoc-ref %build-inputs "gcc-lib"))
161
162 ;; Use a sane default include directory.
163 (string-append "-DC_INCLUDE_DIRS="
164 (assoc-ref %build-inputs "libc")
165 "/include"))
166
94585e88
LC
167 ;; Don't use '-g' during the build to save space.
168 #:build-type "Release"
169
fd6ae1b9
LC
170 #:phases (modify-phases %standard-phases
171 (add-after
172 'unpack 'set-glibc-file-names
173 (lambda* (#:key inputs #:allow-other-keys)
b81f5693
AW
174 (let ((libc (assoc-ref inputs "libc"))
175 (compiler-rt (assoc-ref inputs "clang-runtime")))
9bdbabe9
MB
176 (case (string->number ,(version-major
177 (package-version clang-runtime)))
d199a4c7 178 ((or 6 7)
9bdbabe9
MB
179 ;; Link to libclang_rt files from clang-runtime.
180 (substitute* "lib/Driver/ToolChain.cpp"
181 (("getDriver\\(\\)\\.ResourceDir")
182 (string-append "\"" compiler-rt "\"")))
183
184 ;; Make "LibDir" refer to <glibc>/lib so that it
185 ;; uses the right dynamic linker file name.
186 (substitute* "lib/Driver/ToolChains/Linux.cpp"
187 (("(^[[:blank:]]+LibDir = ).*" _ declaration)
188 (string-append declaration "\"" libc "/lib\";\n"))
189
190 ;; Make sure libc's libdir is on the search path, to
191 ;; allow crt1.o & co. to be found.
192 (("@GLIBC_LIBDIR@")
193 (string-append libc "/lib"))))
194 ((3)
195 (substitute* "lib/Driver/Tools.cpp"
196 ;; Patch the 'getLinuxDynamicLinker' function so that
197 ;; it uses the right dynamic linker file name.
198 (("/lib64/ld-linux-x86-64.so.2")
199 (string-append libc
200 ,(glibc-dynamic-linker))))
201
202 ;; Link to libclang_rt files from clang-runtime.
203 ;; This substitution needed slight adjustment in 3.8.
204 (if (< 3.8 (string->number ,(version-major+minor
205 (package-version
206 clang-runtime))))
207 (substitute* "lib/Driver/Tools.cpp"
208 (("TC\\.getDriver\\(\\)\\.ResourceDir")
209 (string-append "\"" compiler-rt "\"")))
210 (substitute* "lib/Driver/ToolChain.cpp"
211 (("getDriver\\(\\)\\.ResourceDir")
212 (string-append "\"" compiler-rt "\""))))
213
214 ;; Make sure libc's libdir is on the search path, to
215 ;; allow crt1.o & co. to be found.
216 (substitute* "lib/Driver/ToolChains.cpp"
217 (("@GLIBC_LIBDIR@")
218 (string-append libc "/lib")))))
1c7372a5
PN
219 #t)))
220 (add-after 'install 'install-clean-up-/share/clang
221 (lambda* (#:key outputs #:allow-other-keys)
222 (let* ((out (assoc-ref outputs "out"))
223 (compl-dir (string-append
224 out "/etc/bash_completion.d")))
225 (with-directory-excursion (string-append out
226 "/share/clang")
ad8a4a66
PN
227 (for-each
228 (lambda (file)
229 (when (file-exists? file)
230 (delete-file file)))
231 ;; Delete extensions for proprietary text editors.
232 '("clang-format-bbedit.applescript"
233 "clang-format-sublime.py"
234 ;; Delete Emacs extensions: see their respective Emacs
235 ;; Guix package instead.
236 "clang-rename.el" "clang-format.el"))
1c7372a5 237 ;; Install bash completion.
ad8a4a66
PN
238 (when (file-exists? "bash-autocomplete.sh")
239 (mkdir-p compl-dir)
240 (rename-file "bash-autocomplete.sh"
241 (string-append compl-dir "/clang")))))
1c7372a5 242 #t)))))
ef11ac87
LC
243
244 ;; Clang supports the same environment variables as GCC.
245 (native-search-paths
246 (list (search-path-specification
247 (variable "CPATH")
248 (files '("include")))
249 (search-path-specification
250 (variable "LIBRARY_PATH")
251 (files '("lib" "lib64")))))
252
ac97dce1 253 (home-page "https://clang.llvm.org")
3e4249ce
EB
254 (synopsis "C language family frontend for LLVM")
255 (description
256 "Clang is a compiler front end for the C, C++, Objective-C and
257Objective-C++ programming languages. It uses LLVM as its back end. The Clang
258project includes the Clang front end, the Clang static analyzer, and several
259code analysis tools.")
ac00973c 260 (license license:ncsa)))
1204c510 261
9f0ce5ec
RW
262(define-public libcxx
263 (package
264 (name "libcxx")
265 (version (package-version llvm))
266 (source
267 (origin
268 (method url-fetch)
269 (uri (string-append "http://llvm.org/releases/"
270 version "/libcxx-" version ".src.tar.xz"))
271 (sha256
272 (base32
8c72f13f 273 "1wdrxg365ig0kngx52pd0n820sncp24blb0zpalc579iidhh4002"))))
9f0ce5ec
RW
274 (build-system cmake-build-system)
275 (native-inputs
276 `(("clang" ,clang)
277 ("llvm" ,llvm)))
278 (home-page "https://libcxx.llvm.org")
279 (synopsis "C++ standard library")
280 (description
281 "This package provides an implementation of the C++ standard library for
282use with Clang, targeting C++11, C++14 and above.")
283 (license license:expat)))
284
b81f5693
AW
285(define-public clang-runtime
286 (clang-runtime-from-llvm
287 llvm
d199a4c7 288 "065ybd8fsc4h2hikbdyricj6pyv4r7r7kpcikhb2y5zf370xybkq"))
b81f5693 289
1204c510 290(define-public clang
b81f5693 291 (clang-from-llvm llvm clang-runtime
d199a4c7
MB
292 "067lwggnbg0w1dfrps790r5l6k8n5zwhlsw7zb6zvmfpwpfn4nx4"
293 #:patches '("clang-7.0-libc-search-path.patch")))
294
295(define-public llvm-6
296 (package
297 (inherit llvm)
298 (version "6.0.1")
299 (source (origin
300 (method url-fetch)
301 (uri (string-append "https://llvm.org/releases/"
302 version "/llvm-" version ".src.tar.xz"))
303 (sha256
304 (base32
305 "1qpls3vk85lydi5b4axl0809fv932qgsqgdgrk098567z4jc7mmn"))))))
306
307(define-public clang-runtime-6
308 (clang-runtime-from-llvm
309 llvm-6
310 "1fcr3jn24yr8lh36nc0c4ikli4744i2q9m1ik67p1jymwwaixkgl"))
311
312(define-public clang-6
313 (clang-from-llvm llvm-6 clang-runtime
148df605 314 "0rxn4rh7rrnsqbdgp4gzc8ishbkryhpl1kd3mpnxzpxxhla3y93w"
9bdbabe9 315 #:patches '("clang-6.0-libc-search-path.patch")))
3b956a33 316
584da12d
RJ
317(define-public llvm-3.9.1
318 (package (inherit llvm)
319 (name "llvm")
320 (version "3.9.1")
321 (source
322 (origin
323 (method url-fetch)
3bdcc668 324 (uri (string-append "https://llvm.org/releases/"
584da12d
RJ
325 version "/llvm-" version ".src.tar.xz"))
326 (sha256
327 (base32
328 "1vi9sf7rx1q04wj479rsvxayb6z740iaz3qniwp266fgp5a07n8z"))))))
329
330(define-public clang-runtime-3.9.1
331 (clang-runtime-from-llvm
332 llvm-3.9.1
6b26f915
LC
333 "16gc2gdmp5c800qvydrdhsp0bzb97s8wrakl6i8a4lgslnqnf2fk"
334 '("clang-runtime-asan-build-fixes.patch"
0627f93d 335 "clang-runtime-esan-build-fixes.patch"
1a2d8d06 336 "clang-3.5-libsanitizer-ustat-fix.patch")))
584da12d
RJ
337
338(define-public clang-3.9.1
339 (clang-from-llvm llvm-3.9.1 clang-runtime-3.9.1
340 "0qsyyb40iwifhhlx9a3drf8z6ni6zwyk3bvh0kx2gs6yjsxwxi76"
9bdbabe9
MB
341 #:patches '("clang-3.8-libc-search-path.patch")))
342
343(define-public llvm-3.8
344 (package (inherit llvm)
345 (name "llvm")
346 (version "3.8.1")
347 (source
348 (origin
349 (method url-fetch)
350 (uri (string-append "https://llvm.org/releases/"
351 version "/llvm-" version ".src.tar.xz"))
352 (sha256
353 (base32
354 "1ybmnid4pw2hxn12ax5qa5kl1ldfns0njg8533y3mzslvd5cx0kf"))))))
355
356(define-public clang-runtime-3.8
357 (clang-runtime-from-llvm
358 llvm-3.8
359 "0p0y85c7izndbpg2l816z7z7558axq11d5pwkm4h11sdw7d13w0d"
0627f93d 360 '("clang-runtime-asan-build-fixes.patch"
1a2d8d06 361 "clang-3.5-libsanitizer-ustat-fix.patch")))
9bdbabe9
MB
362
363(define-public clang-3.8
364 (clang-from-llvm llvm-3.8 clang-runtime-3.8
365 "1prc72xmkgx8wrzmrr337776676nhsp1qd3mw2bvb22bzdnq7lsc"
366 #:patches '("clang-3.8-libc-search-path.patch")))
584da12d 367
3b956a33
EB
368(define-public llvm-3.7
369 (package (inherit llvm)
370 (version "3.7.1")
371 (source
372 (origin
373 (method url-fetch)
3bdcc668 374 (uri (string-append "https://llvm.org/releases/"
3b956a33
EB
375 version "/llvm-" version ".src.tar.xz"))
376 (sha256
377 (base32
378 "1masakdp9g2dan1yrazg7md5am2vacbkb3nahb3dchpc1knr8xxy"))))))
379
380(define-public clang-runtime-3.7
381 (clang-runtime-from-llvm
382 llvm-3.7
6b26f915 383 "10c1mz2q4bdq9bqfgr3dirc6hz1h3sq8573srd5q5lr7m7j6jiwx"
0627f93d 384 '("clang-runtime-asan-build-fixes.patch"
1a2d8d06 385 "clang-3.5-libsanitizer-ustat-fix.patch")))
3b956a33
EB
386
387(define-public clang-3.7
388 (clang-from-llvm llvm-3.7 clang-runtime-3.7
9bdbabe9
MB
389 "0x065d0w9b51xvdjxwfzjxng0gzpbx45fgiaxpap45ragi61dqjn"
390 #:patches '("clang-3.5-libc-search-path.patch")))
3ebc0905
EB
391
392(define-public llvm-3.6
393 (package (inherit llvm)
394 (version "3.6.2")
395 (source
396 (origin
397 (method url-fetch)
3bdcc668 398 (uri (string-append "https://llvm.org/releases/"
3ebc0905
EB
399 version "/llvm-" version ".src.tar.xz"))
400 (sha256
401 (base32
402 "153vcvj8gvgwakzr4j0kndc0b7wn91c2g1vy2vg24s6spxcc23gn"))))))
403
404(define-public clang-runtime-3.6
405 (clang-runtime-from-llvm
406 llvm-3.6
6b26f915
LC
407 "11qx8d3pbfqjaj2x207pvlvzihbs1z2xbw4crpz7aid6h1yz6bqg"
408 '("clang-runtime-asan-build-fixes.patch")))
3ebc0905
EB
409
410(define-public clang-3.6
411 (clang-from-llvm llvm-3.6 clang-runtime-3.6
9bdbabe9
MB
412 "1wwr8s6lzr324hv4s1k6na4j5zv6n9kdhi14s4kb9b13d93814df"
413 #:patches '("clang-3.5-libc-search-path.patch")))
1204c510
MW
414
415(define-public llvm-3.5
416 (package (inherit llvm)
a53c486d 417 (version "3.5.2")
1204c510
MW
418 (source
419 (origin
420 (method url-fetch)
3bdcc668 421 (uri (string-append "https://llvm.org/releases/"
1204c510 422 version "/llvm-" version ".src.tar.xz"))
6ba4eca2
RW
423 (patches
424 (search-patches "llvm-3.5-fix-clang-build-with-gcc5.patch"))
1204c510
MW
425 (sha256
426 (base32
a53c486d 427 "0xf5q17kkxsrm2gsi93h4pwlv663kji73r2g4asb97klsmb626a4"))))))
1204c510 428
b81f5693
AW
429(define-public clang-runtime-3.5
430 (clang-runtime-from-llvm
431 llvm-3.5
6b26f915 432 "1hsdnzzdr5kglz6fnv3lcsjs222zjsy14y8ax9dy6zqysanplbal"
286bea0d
LC
433 '("clang-runtime-asan-build-fixes.patch"
434 "clang-3.5-libsanitizer-ustat-fix.patch")))
b81f5693 435
1204c510 436(define-public clang-3.5
b81f5693 437 (clang-from-llvm llvm-3.5 clang-runtime-3.5
9bdbabe9
MB
438 "0846h8vn3zlc00jkmvrmy88gc6ql6014c02l4jv78fpvfigmgssg"
439 #:patches '("clang-3.5-libc-search-path.patch")))
921cb13a
RW
440
441(define-public llvm-for-extempore
442 (package (inherit llvm-3.7)
7355634d 443 (name "llvm-for-extempore")
921cb13a
RW
444 (source
445 (origin
446 (inherit (package-source llvm-3.7))
39162ee4
RW
447 (patches (list (search-patch "llvm-for-extempore.patch")))))
448 ;; Extempore refuses to build on architectures other than x86_64
449 (supported-systems '("x86_64-linux"))))
8892cac3
RW
450
451(define-public python-llvmlite
452 (package
453 (name "python-llvmlite")
f9325407 454 (version "0.27.1")
8892cac3
RW
455 (source
456 (origin
457 (method url-fetch)
458 (uri (pypi-uri "llvmlite" version))
459 (sha256
460 (base32
f9325407 461 "1aq003zbyjnz4q1118h6qx5lfimc8s5fvgskl75j12gxd6pc78a8"))))
8892cac3
RW
462 (build-system python-build-system)
463 (inputs
464 `(("llvm"
465 ,(package
466 (inherit llvm)
467 (source (origin
468 (inherit (package-source llvm))
469 (patches
470 (list
471 (origin
472 (method url-fetch)
473 (uri (string-append "https://raw.githubusercontent.com/numba/"
474 "llvmlite/v" version "/conda-recipes/"
f9325407 475 "D47188-svml-VF.patch"))
8892cac3
RW
476 (sha256
477 (base32
f9325407 478 "0wxhgb61k17f0zg2m0726sf3hppm41f8jar2kkg2n8sl5cnjj9mr")))
8892cac3
RW
479 (origin
480 (method url-fetch)
481 (uri (string-append "https://raw.githubusercontent.com/numba/"
482 "llvmlite/v" version "/conda-recipes/"
483 "twine_cfg_undefined_behavior.patch"))
484 (sha256
485 (base32
7a20877a 486 "07h71n2m1mn9zcfgw04zglffknplb233zqbcd6pckq0wygkrxflp")))))))))))
8892cac3
RW
487 (home-page "http://llvmlite.pydata.org")
488 (synopsis "Wrapper around basic LLVM functionality")
489 (description
490 "This package provides a Python binding to LLVM for use in Numba.")
491 (license license:bsd-3)))
7628ff1f 492
67eebb19
LC
493(define (package-elisp-from-package source-package package-name
494 source-files)
495 "Return a package definition named PACKAGE-NAME that packages the Emacs Lisp
496SOURCE-FILES found in SOURCE-PACKAGE."
497 (let ((orig (package-source source-package)))
498 (package
499 (inherit source-package)
500 (name package-name)
501 (build-system emacs-build-system)
502 (source (origin
503 (method (origin-method orig))
504 (uri (origin-uri orig))
505 (sha256 (origin-sha256 orig))
506 (file-name (string-append package-name "-"
507 (package-version source-package)))
508 (modules '((guix build utils)
509 (srfi srfi-1)
510 (ice-9 ftw)))
511 (snippet
512 `(let* ((source-files (quote ,source-files))
513 (basenames (map basename source-files)))
514 (map copy-file
515 source-files basenames)
516 (map delete-file-recursively
517 (fold delete
518 (scandir ".")
519 (append '("." "..") basenames)))
520 #t)))))))
521
7628ff1f
TG
522(define-public emacs-clang-format
523 (package
524 (inherit clang)
525 (name "emacs-clang-format")
526 (build-system emacs-build-system)
527 (inputs
528 `(("clang" ,clang)))
529 (arguments
530 `(#:phases
531 (modify-phases %standard-phases
532 (add-after 'unpack 'configure
533 (lambda* (#:key inputs #:allow-other-keys)
534 (let ((clang (assoc-ref inputs "clang")))
535 (copy-file "tools/clang-format/clang-format.el" "clang-format.el")
536 (emacs-substitute-variables "clang-format.el"
537 ("clang-format-executable"
538 (string-append clang "/bin/clang-format"))))
539 #t)))))
540 (synopsis "Format code using clang-format")
541 (description "This package allows to filter code through @code{clang-format}
542to fix its formatting. @code{clang-format} is a tool that formats
543C/C++/Obj-C code according to a set of style options, see
3bdcc668 544@url{https://clang.llvm.org/docs/ClangFormatStyleOptions.html}.")))
51002b72
PN
545
546(define-public emacs-clang-rename
547 (package
548 (inherit clang)
549 (name "emacs-clang-rename")
550 (build-system emacs-build-system)
551 (inputs
552 `(("clang" ,clang)))
553 (arguments
554 `(#:phases
555 (modify-phases %standard-phases
556 (add-after 'unpack 'configure
557 (lambda* (#:key inputs #:allow-other-keys)
558 (let ((clang (assoc-ref inputs "clang")))
559 (copy-file "tools/clang-rename/clang-rename.el" "clang-rename.el")
560 (emacs-substitute-variables "clang-rename.el"
561 ("clang-rename-binary"
562 (string-append clang "/bin/clang-rename"))))
563 #t)))))
564 (synopsis "Rename every occurrence of a symbol using clang-rename")
565 (description "This package renames every occurrence of a symbol at point
566using @code{clang-rename}.")))