Subject: [bug#77990] [PATCH v2] gnu: Add emacs-ffi.

From: Cayetano Santos <[email-masked]>
Date: Tue, 22 Apr 2025 20:49:07 +0200

>mar. 22 avril 2025 at 10:51, "Suhail Singh" <[email-masked]> wrote:

> * gnu/packages/emacs-xyz.scm (emacs-ffi): New variable.
>
> Change-Id: I3379ff4728d3e3f45d5327978b5e284fcc0e664e
> ---
>  gnu/packages/emacs-xyz.scm | 53 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 53 insertions(+)
>
> diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
> index 08bd88fd08..e6253089e8 100644
> --- a/gnu/packages/emacs-xyz.scm
> +++ b/gnu/packages/emacs-xyz.scm
> @@ -236,6 +236,7 @@ (define-module (gnu packages emacs-xyz)
>    #:use-module (gnu packages llvm)
>    #:use-module (gnu packages image)
>    #:use-module (gnu packages image-viewers)
> +  #:use-module (gnu packages libffi)
>    #:use-module (gnu packages linux)
>    #:use-module (gnu packages libevent)
>    #:use-module (gnu packages lisp)
> @@ -23092,6 +23093,58 @@ (define-public emacs-display-wttr
>  @uref{https://wttr.in} and then displays it on the mode line.")
>      (license license:gpl3+)))
>
> +(define-public emacs-ffi
> +  (package
> +    (name "emacs-ffi")
> +    (version "0.2.1")
> +    (source
> +     (origin
> +       (method git-fetch)
> +       (uri (git-reference
> +             (url "https://github.com/emacs-ffi/emacs-ffi")
> +             (commit version)))
> +       (file-name (git-file-name name version))
> +       (sha256
> +        (base32 "05crpgscpbzkg4k0ylbfjz2wyw2r8lki8q9w2kmdpljsqrpdrwl0"))))
> +    (build-system emacs-build-system)
> +    (arguments
> +     (list
> +      #:tests? (not (%current-target-system))
> +      #:phases
> +      #~(modify-phases %standard-phases
> +          (add-after 'unpack 'patch-module-load
> +            (lambda _
> +              (make-file-writable "src/ffi.el")
> +              (emacs-substitute-sexps "src/ffi.el"
> +                ("(require 'ffi-module nil t)"
> +                 `(module-load
> +                   ,(string-append #$output "/lib/ffi-module.so"))))))
> +          (add-before 'check 'build-emacs-module
> +            (lambda _
> +              ;; Compile the shared object file.
> +              (invoke "make"
> +                      #$(string-append "CC="
> +                                       (cc-for-target)))
> +              ;; Copy the build artifacts to root and let the install phase do
> +              ;; its thing
> +              (copy-recursively "build/lib" ".")
> +              ;; Install the shared object file into /lib.
> +              (install-file "build/lib/ffi-module.so"
> +                            (string-append #$output "/lib"))))

I have a doubt about where do we  put .so files.

- lib
- lib/package
- lib/emacs (see emacs-jinx)

Other than this, LFTM.

C.