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, 2019 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, 2019 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 python-xyz)
34 #:use-module (gnu packages ruby)
35 #:use-module (guix build-system gnu)
36 #:use-module (guix build-system python)
37 #:use-module (guix build-system ruby))
46 (string-append "ftp://sourceware.org/pub/libffi/"
47 name "-" version ".tar.gz"))
50 "0dya49bnhianl0r65m65xndz6ls2jn1xngyn72gd28ls3n7bnvnh"))
51 (patches (search-patches "libffi-3.2.1-complex-alpha.patch"))))
52 (build-system gnu-build-system)
54 `(;; Prevent the build system from passing -march and -mtune to the
55 ;; compiler. See "ax_cc_maxopt.m4" and "ax_gcc_archflag.m4".
56 #:configure-flags '("--enable-portable-binary" "--without-gcc-arch")
58 (modify-phases %standard-phases
59 (add-after 'install 'post-install
60 (lambda* (#:key outputs #:allow-other-keys)
61 (define out (assoc-ref outputs "out"))
62 (symlink (string-append out "/lib/libffi-3.2.1/include")
63 (string-append out "/include"))
65 (outputs '("out" "debug"))
66 (synopsis "Foreign function call interface library")
68 "The libffi library provides a portable, high level programming interface
69 to various calling conventions. This allows a programmer to call any
70 function specified by a call interface description at run-time.
72 FFI stands for Foreign Function Interface. A foreign function interface is
73 the popular name for the interface that allows code written in one language
74 to call code written in another language. The libffi library really only
75 provides the lowest, machine dependent layer of a fully featured foreign
76 function interface. A layer must exist above libffi that handles type
77 conversions for values passed between the two languages.")
78 (home-page "http://sources.redhat.com/libffi/")
80 ;; See <https://github.com/atgreen/libffi/blob/master/LICENSE>.
83 (define-public python-cffi
90 (uri (pypi-uri "cffi" version))
92 (base32 "1x3lrj928dcxx1k8k9gf3s4s3jwvzv8mc3kkyg1g7c3a1sc1f3z9"))
93 (patches (search-patches "python-cffi-x87-stack-clean.patch"))))
94 (build-system python-build-system)
96 `(("libffi" ,libffi)))
97 (propagated-inputs ; required at run-time
98 `(("python-pycparser" ,python-pycparser)))
100 `(("pkg-config" ,pkg-config)
101 ("python-pytest" ,python-pytest)))
103 `(#:modules ((ice-9 ftw)
106 (guix build python-build-system))
108 (modify-phases %standard-phases
113 (getenv "PYTHONPATH")
114 ":" (getcwd) "/build/"
115 (car (scandir "build" (cut string-prefix? "lib." <>)))))
117 ;; XXX The "normal" approach of setting CC and friends does
118 ;; not work here. Is this the correct way of doing things?
119 (substitute* "testing/embedding/test_basic.py"
120 (("c = distutils\\.ccompiler\\.new_compiler\\(\\)")
121 (string-append "c = distutils.ccompiler.new_compiler();"
122 "c.set_executables(compiler='gcc',"
123 "compiler_so='gcc',linker_exe='gcc',"
124 "linker_so='gcc -shared')")))
125 (substitute* "testing/cffi0/test_ownlib.py"
126 (("'cc testownlib") "'gcc testownlib"))
127 (invoke "py.test" "-v" "c/" "testing/")
129 (add-before 'check 'disable-failing-test
130 ;; This is assumed to be a libffi issue:
131 ;; https://bitbucket.org/cffi/cffi/issues/312/tests-failed-with-armv8
133 (substitute* "testing/cffi0/test_ownlib.py"
134 (("ret.left") "ownlib.left"))
136 (home-page "https://cffi.readthedocs.org")
137 (synopsis "Foreign function interface for Python")
139 "Foreign Function Interface for Python calling C code.")
142 (define-public python2-cffi
143 (package-with-python2 python-cffi))
145 (define-public python-cffi-documentation
147 (name "python-cffi-documentation")
148 (version (package-version python-cffi))
149 (source (package-source python-cffi))
150 (build-system gnu-build-system)
153 #:phases (modify-phases %standard-phases
154 (add-after 'unpack 'chdir
155 (lambda _ (chdir "doc") #t))
158 (lambda* (#:key (make-flags '()) #:allow-other-keys)
159 (apply invoke "make" "html" make-flags)))
161 (lambda* (#:key outputs #:allow-other-keys)
162 (let ((out (assoc-ref outputs "out")))
163 (copy-recursively "build/html" (string-append out "/html"))
166 `(("sphinx-build" ,python-sphinx)))
167 (home-page (package-home-page python-cffi))
168 (synopsis "Documentation for the Python CFFI interface")
170 "This package contains HTML documentation for the @code{python-cffi}
172 (license (package-license python-cffi))))
174 (define-public ruby-ffi
180 (uri (rubygems-uri "ffi" version))
183 "0j8pzj8raxbir5w5k6s7a042sb5k02pg0f8s4na1r5lan901j00p"))))
184 (build-system ruby-build-system)
185 ;; FIXME: Before running tests the build system attempts to build libffi
187 (arguments `(#:tests? #f))
189 `(("ruby-rake-compiler" ,ruby-rake-compiler)
190 ("ruby-rspec" ,ruby-rspec)
191 ("ruby-rubygems-tasks" ,ruby-rubygems-tasks)))
193 `(("libffi" ,libffi)))
194 (synopsis "Ruby foreign function interface library")
195 (description "Ruby-FFI is a Ruby extension for programmatically loading
196 dynamic libraries, binding functions within them, and calling those functions
197 from Ruby code. Moreover, a Ruby-FFI extension works without changes on Ruby
199 (home-page "http://wiki.github.com/ffi/ffi")