1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014 Federico Beffa <beffa@fbengineering.ch>
4 ;;; Copyright © 2015 Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>
5 ;;; Copyright © 2016, 2017 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2016, 2017 Ben Woodcroft <donttrustben@gmail.com>
7 ;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
8 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
10 ;;; This file is part of GNU Guix.
12 ;;; GNU Guix is free software; you can redistribute it and/or modify it
13 ;;; under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 3 of the License, or (at
15 ;;; your option) any later version.
17 ;;; GNU Guix is distributed in the hope that it will be useful, but
18 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25 (define-module (gnu packages libffi)
26 #:use-module (gnu packages)
27 #:use-module (guix licenses)
28 #:use-module (guix packages)
29 #:use-module (guix download)
30 #:use-module (gnu packages check)
31 #:use-module (gnu packages pkg-config)
32 #:use-module (gnu packages python)
33 #:use-module (gnu packages ruby)
34 #:use-module (guix build-system gnu)
35 #:use-module (guix build-system python)
36 #:use-module (guix build-system ruby))
45 (string-append "ftp://sourceware.org/pub/libffi/"
46 name "-" version ".tar.gz"))
49 "0dya49bnhianl0r65m65xndz6ls2jn1xngyn72gd28ls3n7bnvnh"))
50 (patches (search-patches "libffi-3.2.1-complex-alpha.patch"))))
51 (build-system gnu-build-system)
54 (modify-phases %standard-phases
55 (add-after 'install 'post-install
56 (lambda* (#:key outputs #:allow-other-keys)
57 (define out (assoc-ref outputs "out"))
58 (symlink (string-append out "/lib/libffi-3.2.1/include")
59 (string-append out "/include"))
61 (outputs '("out" "debug"))
62 (synopsis "Foreign function call interface library")
64 "The libffi library provides a portable, high level programming interface
65 to various calling conventions. This allows a programmer to call any
66 function specified by a call interface description at run-time.
68 FFI stands for Foreign Function Interface. A foreign function interface is
69 the popular name for the interface that allows code written in one language
70 to call code written in another language. The libffi library really only
71 provides the lowest, machine dependent layer of a fully featured foreign
72 function interface. A layer must exist above libffi that handles type
73 conversions for values passed between the two languages.")
74 (home-page "http://sources.redhat.com/libffi/")
76 ;; See <https://github.com/atgreen/libffi/blob/master/LICENSE>.
79 (define-public python-cffi
86 (uri (pypi-uri "cffi" version))
88 (base32 "07fiy4wqg8g08x38r04ydjr8n6g0g74gb8si8b6jhymijalq746z"))))
89 (build-system python-build-system)
90 (outputs '("out" "doc"))
92 `(("libffi" ,libffi)))
93 (propagated-inputs ; required at run-time
94 `(("python-pycparser" ,python-pycparser)))
96 `(("pkg-config" ,pkg-config)
97 ("python-sphinx" ,python-sphinx)
98 ("python-pytest" ,python-pytest)))
100 `(#:modules ((ice-9 ftw)
103 (guix build python-build-system))
105 (modify-phases %standard-phases
110 (getenv "PYTHONPATH")
111 ":" (getcwd) "/build/"
112 (car (scandir "build" (cut string-prefix? "lib." <>)))))
114 ;; XXX The "normal" approach of setting CC and friends does
115 ;; not work here. Is this the correct way of doing things?
116 (substitute* "testing/embedding/test_basic.py"
117 (("c = distutils\\.ccompiler\\.new_compiler\\(\\)")
118 (string-append "c = distutils.ccompiler.new_compiler();"
119 "c.set_executables(compiler='gcc',"
120 "compiler_so='gcc',linker_exe='gcc',"
121 "linker_so='gcc -shared')")))
122 (substitute* "testing/cffi0/test_ownlib.py"
123 (("'cc testownlib") "'gcc testownlib"))
124 (invoke "py.test" "-v" "c/" "testing/")
126 (add-before 'check 'disable-failing-test
127 ;; This is assumed to be a libffi issue:
128 ;; https://bitbucket.org/cffi/cffi/issues/312/tests-failed-with-armv8
130 (substitute* "testing/cffi0/test_ownlib.py"
131 (("ret.left") "ownlib.left"))
133 (add-after 'install 'install-doc
134 (lambda* (#:key outputs (make-flags '()) #:allow-other-keys)
135 (let* ((doc (string-append (assoc-ref outputs "doc")
136 "/share/doc/" ,name "-" ,version))
137 (html (string-append doc "/html")))
138 (with-directory-excursion "doc"
139 (apply invoke "make" "html" make-flags)
141 (copy-recursively "build/html" html))
143 (home-page "https://cffi.readthedocs.org")
144 (synopsis "Foreign function interface for Python")
146 "Foreign Function Interface for Python calling C code.")
149 (define-public python2-cffi
150 (package-with-python2 python-cffi))
152 (define-public ruby-ffi
158 (uri (rubygems-uri "ffi" version))
161 "17lvnpmllg4mlzf25lxbmfzk4l6rsddlxwwdkbs4d9v5gv154529"))))
162 (build-system ruby-build-system)
163 ;; FIXME: Before running tests the build system attempts to build libffi
165 (arguments `(#:tests? #f))
167 `(("ruby-rake-compiler" ,ruby-rake-compiler)
168 ("ruby-rspec" ,ruby-rspec)
169 ("ruby-rubygems-tasks" ,ruby-rubygems-tasks)))
171 `(("libffi" ,libffi)))
172 (synopsis "Ruby foreign function interface library")
173 (description "Ruby-FFI is a Ruby extension for programmatically loading
174 dynamic libraries, binding functions within them, and calling those functions
175 from Ruby code. Moreover, a Ruby-FFI extension works without changes on Ruby
177 (home-page "http://wiki.github.com/ffi/ffi")