From 3048b6f20440c17f3d8fb045646095faad615da9 Mon Sep 17 00:00:00 2001 From: jgart Date: Wed, 2 Oct 2024 02:20:24 -0500 Subject: [PATCH] gnu: lem: Build included shared library. * gnu/packages/text-editors.scm (lem): Build shared library. [source]: Delete precompiled binaries. [arguments]: Patch libvterm and build shared library. [inputs]: Add libvterm. Change-Id: I296f139f93032ccbb380e112c9c1e4fd681ae1a7 --- gnu/packages/text-editors.scm | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/gnu/packages/text-editors.scm b/gnu/packages/text-editors.scm index afc6caffbe..1851440ffd 100644 --- a/gnu/packages/text-editors.scm +++ b/gnu/packages/text-editors.scm @@ -165,25 +165,53 @@ (define-public lem (snippet #~(begin (use-modules (guix build utils)) - (delete-file-recursively "roswell"))))) + (delete-file-recursively "roswell") + ;; Delete precompiled shared object files. + (delete-file-recursively "extensions/terminal/lib"))))) (build-system asdf-build-system/sbcl) (arguments (list #:phases #~(modify-phases %standard-phases + (add-after 'unpack 'patch-shared-object-files + (lambda* (#:key inputs outputs #:allow-other-keys) + (let* ((libvterm-lib (assoc-ref inputs "libvterm")) + (lib-dir (string-append libvterm-lib "/lib")) + (shared-lib-dir (string-append (assoc-ref outputs "out") + "/lib")) + (shared-lib (string-append shared-lib-dir + "/terminal.so"))) + + (substitute* "extensions/terminal/ffi.lisp" + (("terminal.so") shared-lib))))) (add-after 'create-asdf-configuration 'build-program (lambda* (#:key outputs #:allow-other-keys) (build-program (string-append (assoc-ref outputs "out") "/bin/lem") outputs #:dependencies '("lem-ncurses" "lem-sdl2") - #:entry-program '((lem:main) 0))))))) + #:entry-program '((lem:main) 0)))) + (add-after 'build 'build-terminal-library + (lambda* (#:key inputs outputs #:allow-other-keys) + (let* ((libvterm-lib (assoc-ref inputs "libvterm")) + (lib-dir (string-append libvterm-lib "/lib")) + (shared-lib-dir (string-append (assoc-ref outputs "out") + "/lib")) + (shared-lib (string-append shared-lib-dir + "/terminal.so"))) + (mkdir-p shared-lib-dir) + (invoke "gcc" "extensions/terminal/terminal.c" + "-L" lib-dir "-lvterm" + "-Wl,-Bdynamic" + "-o" shared-lib + "-fPIC" "-shared"))))))) (native-inputs (list sbcl-cl-ansi-text sbcl-rove sbcl-trivial-package-local-nicknames)) (inputs (list + libvterm sbcl-alexandria sbcl-trivia sbcl-trivial-gray-streams