| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 |
|
| 29 | (define-module (gnu packages libffi)
|
| 30 | #:use-module (gnu packages)
|
| 31 | #:use-module (guix licenses)
|
| 32 | #:use-module (guix packages)
|
| 33 | #:use-module (guix gexp)
|
| 34 | #:use-module (guix download)
|
| 35 | #:use-module (guix git-download)
|
| 36 | #:use-module (guix utils)
|
| 37 | #:use-module (gnu packages check)
|
| 38 | #:use-module (gnu packages crypto)
|
| 39 | #:use-module (gnu packages pkg-config)
|
| 40 | #:use-module (gnu packages python)
|
| 41 | #:use-module (gnu packages python-build)
|
| 42 | #:use-module (gnu packages python-xyz)
|
| 43 | #:use-module (gnu packages ruby-check)
|
| 44 | #:use-module (gnu packages ruby-xyz)
|
| 45 | #:use-module (gnu packages sphinx)
|
| 46 | #:use-module (guix build-system gnu)
|
| 47 | #:use-module (guix build-system pyproject)
|
| 48 | #:use-module (guix build-system ruby))
|
| 49 |
|
| 50 | (define-public libffi
|
| 51 | (package
|
| 52 | (name "libffi")
|
| 53 | (version "3.4.6")
|
| 54 | (source (origin
|
| 55 | (method url-fetch)
|
| 56 | (uri
|
| 57 | (string-append "https://github.com/libffi/libffi/releases"
|
| 58 | "/download/v" version "/"
|
| 59 | name "-" version ".tar.gz"))
|
| 60 | (sha256
|
| 61 | (base32
|
| 62 | "0kjsi51phx1pskjhhwa9y5fxdazzxgrl0m421sjsfqy84ggskpmh"))))
|
| 63 | (build-system gnu-build-system)
|
| 64 | (arguments
|
| 65 | `( |
| 66 | |
| 67 | #:configure-flags '("--enable-portable-binary"
|
| 68 | "--without-gcc-arch")))
|
| 69 | (outputs '("out" "debug"))
|
| 70 | (synopsis "Foreign function call interface library")
|
| 71 | (description
|
| 72 | "The libffi library provides a portable, high level programming interface
|
| 73 | to various calling conventions. This allows a programmer to call any
|
| 74 | function specified by a call interface description at run-time.
|
| 75 |
|
| 76 | FFI stands for Foreign Function Interface. A foreign function interface is
|
| 77 | the popular name for the interface that allows code written in one language
|
| 78 | to call code written in another language. The libffi library really only
|
| 79 | provides the lowest, machine dependent layer of a fully featured foreign
|
| 80 | function interface. A layer must exist above libffi that handles type
|
| 81 | conversions for values passed between the two languages.")
|
| 82 | (home-page "https://www.sourceware.org/libffi/")
|
| 83 | (properties `((release-monitoring-url . ,home-page)))
|
| 84 |
|
| 85 | |
| 86 | (license expat)))
|
| 87 |
|
| 88 | |
| 89 | |
| 90 | |
| 91 | (define-public libffi-sans-static-trampolines
|
| 92 | (hidden-package
|
| 93 | (package/inherit libffi
|
| 94 | (arguments
|
| 95 | (substitute-keyword-arguments arguments
|
| 96 | ((#:configure-flags flags #~'())
|
| 97 | #~(append #$flags '("--disable-exec-static-tramp"))))))))
|
| 98 |
|
| 99 | (define-public libffi-next
|
| 100 | (package
|
| 101 | (inherit libffi)
|
| 102 | (name "libffi")
|
| 103 | (version "3.8.0")
|
| 104 | (source (origin
|
| 105 | (method url-fetch)
|
| 106 | (uri
|
| 107 | (string-append "https://github.com/libffi/libffi/releases"
|
| 108 | "/download/v" version "/"
|
| 109 | name "-" version ".tar.gz"))
|
| 110 | (sha256
|
| 111 | (base32
|
| 112 | "1d0d1i1z835d54xppn4n6h7mbcibzz9wlbjriw1hmsvil7cy58vx"))))))
|
| 113 |
|
| 114 | (define-public python-cffi
|
| 115 | (package
|
| 116 | (name "python-cffi")
|
| 117 | (version "1.17.1")
|
| 118 | (source
|
| 119 | (origin
|
| 120 | (method url-fetch)
|
| 121 | (uri (pypi-uri "cffi" version))
|
| 122 | (sha256
|
| 123 | (base32 "0918qn4yfjfgcy7i4imfy9q1cvl3svmm06anakflig1jdh0wcf8w"))))
|
| 124 | (build-system pyproject-build-system)
|
| 125 | (arguments
|
| 126 | (list
|
| 127 | #:test-flags
|
| 128 | #~(list "src/c/" "testing/"
|
| 129 | |
| 130 | |
| 131 | |
| 132 | "--deselect=testing/cffi0/test_ffi_backend.py::TestFFI::test_dlopen_handle"
|
| 133 | "--deselect=testing/cffi1/test_re_python.py::test_dlopen_handle"
|
| 134 | "--ignore=testing/embedding/test_performance.py")
|
| 135 | #:phases
|
| 136 | #~(modify-phases %standard-phases
|
| 137 | (add-after 'unpack 'set-gcc
|
| 138 | (lambda _
|
| 139 | |
| 140 | |
| 141 | (substitute* "testing/embedding/test_basic.py"
|
| 142 | (("c = distutils\\.ccompiler\\.new_compiler\\(\\)")
|
| 143 | (string-append "c = distutils.ccompiler.new_compiler();"
|
| 144 | "c.set_executables(compiler='gcc',"
|
| 145 | "compiler_so='gcc',linker_exe='gcc',"
|
| 146 | "linker_so='gcc -shared')")))
|
| 147 | (substitute* "testing/cffi0/test_ownlib.py"
|
| 148 | (("\"cc testownlib") "\"gcc testownlib"))))
|
| 149 | (add-before 'check 'patch-paths-of-dynamically-loaded-libraries
|
| 150 | (lambda* (#:key inputs #:allow-other-keys)
|
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | (let ((libm (search-input-file inputs "lib/libm.so.6"))
|
| 156 | (libc (search-input-file inputs "lib/libc.so.6")))
|
| 157 | (substitute* '("testing/cffi0/test_function.py"
|
| 158 | "testing/cffi0/test_parsing.py"
|
| 159 | "testing/cffi0/test_unicode_literals.py"
|
| 160 | "testing/cffi0/test_zdistutils.py"
|
| 161 | "testing/cffi1/test_recompiler.py")
|
| 162 | (("lib_m = ['\"]{1}m['\"]{1}")
|
| 163 | (format #f "lib_m = '~a'" libm)))
|
| 164 | (substitute* '("testing/cffi0/test_verify.py"
|
| 165 | "testing/cffi1/test_verify1.py")
|
| 166 | (("lib_m = \\[['\"]{1}m['\"]{1}\\]")
|
| 167 | (format #f "lib_m = ['~a']" libm)))
|
| 168 | (substitute* "src/c/test_c.py"
|
| 169 | (("find_and_load_library\\(['\"]{1}c['\"]{1}")
|
| 170 | (format #f "find_and_load_library('~a'" libc)))))))))
|
| 171 | (native-inputs
|
| 172 | (list pkg-config
|
| 173 | python-pytest
|
| 174 | python-setuptools))
|
| 175 | (inputs
|
| 176 | (list libffi))
|
| 177 | (propagated-inputs |
| 178 | (list python-pycparser))
|
| 179 | (home-page "https://cffi.readthedocs.io/")
|
| 180 | (synopsis "Foreign function interface for Python")
|
| 181 | (description "Foreign Function Interface for Python calling C code.")
|
| 182 | (license expat)))
|
| 183 |
|
| 184 | (define-public python-cffi-documentation
|
| 185 | (package
|
| 186 | (name "python-cffi-documentation")
|
| 187 | (version (package-version python-cffi))
|
| 188 | (source (package-source python-cffi))
|
| 189 | (build-system gnu-build-system)
|
| 190 | (arguments
|
| 191 | `(#:tests? #f
|
| 192 | #:phases (modify-phases %standard-phases
|
| 193 | (add-after 'unpack 'chdir
|
| 194 | (lambda _ (chdir "doc") #t))
|
| 195 | (delete 'configure)
|
| 196 | (replace 'build
|
| 197 | (lambda* (#:key (make-flags '()) #:allow-other-keys)
|
| 198 | (apply invoke "make" "html" make-flags)))
|
| 199 | (replace 'install
|
| 200 | (lambda* (#:key outputs #:allow-other-keys)
|
| 201 | (let ((out (assoc-ref outputs "out")))
|
| 202 | (copy-recursively "build/html" (string-append out "/html"))
|
| 203 | #t))))))
|
| 204 | (native-inputs
|
| 205 | `(("sphinx-build" ,python-sphinx)))
|
| 206 | (home-page (package-home-page python-cffi))
|
| 207 | (synopsis "Documentation for the Python CFFI interface")
|
| 208 | (description
|
| 209 | "This package contains HTML documentation for the @code{python-cffi}
|
| 210 | project.")
|
| 211 | (license (package-license python-cffi))))
|
| 212 |
|
| 213 | (define-public ruby-ffi
|
| 214 | (package
|
| 215 | (name "ruby-ffi")
|
| 216 | (version "1.15.5")
|
| 217 | (source (origin
|
| 218 | |
| 219 | |
| 220 | (method git-fetch)
|
| 221 | (uri (git-reference
|
| 222 | (url "https://github.com/ffi/ffi")
|
| 223 | (commit (string-append "v" version))))
|
| 224 | (file-name (git-file-name name version))
|
| 225 | (sha256
|
| 226 | (base32
|
| 227 | "1qk55s1zwpdjykwkj9l37m71i5n228i7f8bg3ply3ks9py16m7s6"))))
|
| 228 | (build-system ruby-build-system)
|
| 229 | (arguments
|
| 230 | `(#:phases
|
| 231 | (modify-phases %standard-phases
|
| 232 | (replace 'replace-git-ls-files
|
| 233 | (lambda _
|
| 234 | |
| 235 | (substitute* "ffi.gemspec"
|
| 236 | (("git ls-files -z")
|
| 237 | "find * -type f -print0 | sort -z")
|
| 238 | (("lfs \\+?= .*")
|
| 239 | "lfs = []\n"))
|
| 240 | (substitute* "Rakefile"
|
| 241 | (("git .*ls-files -z")
|
| 242 | "find * -type f -print0 | sort -z")
|
| 243 | (("LIBFFI_GIT_FILES = .*")
|
| 244 | "LIBFFI_GIT_FILES = []\n"))))
|
| 245 | (replace 'build
|
| 246 | (lambda _
|
| 247 | |
| 248 | |
| 249 | (invoke "rake" "compile")
|
| 250 |
|
| 251 | |
| 252 | |
| 253 | |
| 254 | |
| 255 | (invoke "gem" "build" "ffi.gemspec")))
|
| 256 | (replace 'check
|
| 257 | (lambda* (#:key tests? #:allow-other-keys)
|
| 258 | (if tests?
|
| 259 | (begin
|
| 260 | (setenv "MAKE" "make")
|
| 261 | (setenv "CC" "gcc")
|
| 262 | (invoke "rspec" "spec"))
|
| 263 | (format #t "test suite not run~%")))))))
|
| 264 | (native-inputs
|
| 265 | (list ruby-rake-compiler ruby-rspec ruby-rubygems-tasks))
|
| 266 | (inputs
|
| 267 | (list libffi))
|
| 268 | (synopsis "Ruby foreign function interface library")
|
| 269 | (description "Ruby-FFI is a Ruby extension for programmatically loading
|
| 270 | dynamic libraries, binding functions within them, and calling those functions
|
| 271 | from Ruby code. Moreover, a Ruby-FFI extension works without changes on Ruby
|
| 272 | and JRuby.")
|
| 273 | (home-page "https://wiki.github.com/ffi/ffi")
|
| 274 | (license bsd-3)))
|