Commit | Line | Data |
---|---|---|
233e7676 | 1 | ;;; GNU Guix --- Functional package management for GNU |
d43547f1 | 2 | ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org> |
0751fddd | 3 | ;;; Copyright © 2014 Federico Beffa <beffa@fbengineering.ch> |
838b232e | 4 | ;;; Copyright © 2015 Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> |
0751fddd | 5 | ;;; Copyright © 2016, 2017 Efraim Flashner <efraim@flashner.co.il> |
838b232e | 6 | ;;; Copyright © 2016, 2017 Ben Woodcroft <donttrustben@gmail.com> |
0751fddd | 7 | ;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com> |
667e6f1e | 8 | ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr> |
c44899a2 | 9 | ;;; |
233e7676 | 10 | ;;; This file is part of GNU Guix. |
c44899a2 | 11 | ;;; |
233e7676 | 12 | ;;; GNU Guix is free software; you can redistribute it and/or modify it |
c44899a2 LC |
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. | |
16 | ;;; | |
233e7676 | 17 | ;;; GNU Guix is distributed in the hope that it will be useful, but |
c44899a2 LC |
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. | |
21 | ;;; | |
22 | ;;; You should have received a copy of the GNU General Public License | |
233e7676 | 23 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
c44899a2 | 24 | |
1ffa7090 | 25 | (define-module (gnu packages libffi) |
1602fcea | 26 | #:use-module (gnu packages) |
4a44e743 | 27 | #:use-module (guix licenses) |
c44899a2 | 28 | #:use-module (guix packages) |
87f5d366 | 29 | #:use-module (guix download) |
ac257f12 | 30 | #:use-module (gnu packages check) |
0751fddd EF |
31 | #:use-module (gnu packages pkg-config) |
32 | #:use-module (gnu packages python) | |
838b232e | 33 | #:use-module (gnu packages ruby) |
0751fddd | 34 | #:use-module (guix build-system gnu) |
838b232e EF |
35 | #:use-module (guix build-system python) |
36 | #:use-module (guix build-system ruby)) | |
c44899a2 LC |
37 | |
38 | (define-public libffi | |
667e6f1e | 39 | (package |
c44899a2 | 40 | (name "libffi") |
bfcb7bcb | 41 | (version "3.2.1") |
c44899a2 | 42 | (source (origin |
667e6f1e TGR |
43 | (method url-fetch) |
44 | (uri | |
45 | (string-append "ftp://sourceware.org/pub/libffi/" | |
46 | name "-" version ".tar.gz")) | |
47 | (sha256 | |
48 | (base32 | |
49 | "0dya49bnhianl0r65m65xndz6ls2jn1xngyn72gd28ls3n7bnvnh")) | |
50 | (patches (search-patches "libffi-3.2.1-complex-alpha.patch")))) | |
c44899a2 | 51 | (build-system gnu-build-system) |
667e6f1e TGR |
52 | (arguments |
53 | `(#:phases | |
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")) | |
60 | #t))))) | |
9bf62d9b | 61 | (outputs '("out" "debug")) |
089b0634 | 62 | (synopsis "Foreign function call interface library") |
c44899a2 LC |
63 | (description |
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. | |
67 | ||
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/") | |
75 | ||
7bf837fd | 76 | ;; See <https://github.com/atgreen/libffi/blob/master/LICENSE>. |
667e6f1e | 77 | (license expat))) |
c44899a2 | 78 | |
0751fddd EF |
79 | (define-public python-cffi |
80 | (package | |
81 | (name "python-cffi") | |
b7375305 | 82 | (version "1.11.4") |
0751fddd EF |
83 | (source |
84 | (origin | |
85 | (method url-fetch) | |
86 | (uri (pypi-uri "cffi" version)) | |
87 | (sha256 | |
b7375305 | 88 | (base32 "07fiy4wqg8g08x38r04ydjr8n6g0g74gb8si8b6jhymijalq746z")))) |
0751fddd EF |
89 | (build-system python-build-system) |
90 | (outputs '("out" "doc")) | |
91 | (inputs | |
92 | `(("libffi" ,libffi))) | |
93 | (propagated-inputs ; required at run-time | |
94 | `(("python-pycparser" ,python-pycparser))) | |
95 | (native-inputs | |
96 | `(("pkg-config" ,pkg-config) | |
97 | ("python-sphinx" ,python-sphinx) | |
98 | ("python-pytest" ,python-pytest))) | |
99 | (arguments | |
100 | `(#:modules ((ice-9 ftw) | |
101 | (srfi srfi-26) | |
102 | (guix build utils) | |
103 | (guix build python-build-system)) | |
104 | #:phases | |
105 | (modify-phases %standard-phases | |
106 | (replace 'check | |
107 | (lambda _ | |
108 | (setenv "PYTHONPATH" | |
109 | (string-append | |
110 | (getenv "PYTHONPATH") | |
111 | ":" (getcwd) "/build/" | |
112 | (car (scandir "build" (cut string-prefix? "lib." <>))))) | |
113 | ||
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")) | |
fc38e317 TGR |
124 | (invoke "py.test" "-v" "c/" "testing/") |
125 | #t)) | |
0751fddd EF |
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 | |
129 | (lambda _ | |
130 | (substitute* "testing/cffi0/test_ownlib.py" | |
131 | (("ret.left") "ownlib.left")) | |
132 | #t)) | |
133 | (add-after 'install 'install-doc | |
fc38e317 TGR |
134 | (lambda* (#:key outputs (make-flags '()) #:allow-other-keys) |
135 | (let* ((doc (string-append (assoc-ref outputs "doc") | |
136 | "/share/doc/" ,name "-" ,version)) | |
0751fddd EF |
137 | (html (string-append doc "/html"))) |
138 | (with-directory-excursion "doc" | |
fc38e317 | 139 | (apply invoke "make" "html" make-flags) |
0751fddd EF |
140 | (mkdir-p html) |
141 | (copy-recursively "build/html" html)) | |
0751fddd EF |
142 | #t)))))) |
143 | (home-page "https://cffi.readthedocs.org") | |
144 | (synopsis "Foreign function interface for Python") | |
145 | (description | |
146 | "Foreign Function Interface for Python calling C code.") | |
147 | (license expat))) | |
148 | ||
149 | (define-public python2-cffi | |
150 | (package-with-python2 python-cffi)) | |
838b232e EF |
151 | |
152 | (define-public ruby-ffi | |
153 | (package | |
154 | (name "ruby-ffi") | |
a26040c5 | 155 | (version "1.9.23") |
838b232e EF |
156 | (source (origin |
157 | (method url-fetch) | |
158 | (uri (rubygems-uri "ffi" version)) | |
159 | (sha256 | |
160 | (base32 | |
a26040c5 | 161 | "0zw6pbyvmj8wafdc7l5h7w20zkp1vbr2805ql5d941g2b20pk4zr")))) |
838b232e EF |
162 | (build-system ruby-build-system) |
163 | ;; FIXME: Before running tests the build system attempts to build libffi | |
164 | ;; from sources. | |
165 | (arguments `(#:tests? #f)) | |
166 | (native-inputs | |
167 | `(("ruby-rake-compiler" ,ruby-rake-compiler) | |
168 | ("ruby-rspec" ,ruby-rspec) | |
169 | ("ruby-rubygems-tasks" ,ruby-rubygems-tasks))) | |
170 | (inputs | |
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 | |
176 | and JRuby.") | |
177 | (home-page "http://wiki.github.com/ffi/ffi") | |
178 | (license bsd-3))) |