Function: ghostel--compile-module
ghostel--compile-module is a natively compiled function defined in
ghostel-module-install.el.
Signature
(ghostel--compile-module DEST-DIR)
Documentation
Compile the native module from source and install it in DEST-DIR.
The build runs in ghostel--resource-root (which holds build.zig);
on success the produced module and its sidecar are moved into DEST-DIR.
Source Code
;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel-module-install.el
(defun ghostel--compile-module (dest-dir)
"Compile the native module from source and install it in DEST-DIR.
The build runs in `ghostel--resource-root' (which holds build.zig);
on success the produced module and its sidecar are moved into DEST-DIR."
(let* ((source-dir (ghostel--resource-root))
(build-dir nil)
(default-directory source-dir))
(message "ghostel: compiling native module with zig build (this may take a moment)...")
(condition-case err
(unwind-protect
(progn
(setq build-dir (ghostel--make-module-build-dir dest-dir))
(let ((ret (process-file "zig" nil "*ghostel-build*" nil
"build" "--prefix" build-dir
"-Doptimize=ReleaseFast" "-Dcpu=baseline")))
(if (not (eq ret 0))
(display-warning 'ghostel
"Module compilation failed. See *ghostel-build* buffer for details.")
(let* ((file-name (concat "ghostel-module" module-file-suffix))
(built (expand-file-name file-name build-dir))
(final (expand-file-name file-name dest-dir)))
(if (not (file-exists-p built))
(display-warning 'ghostel
(format "Build succeeded but module not produced at %s"
built))
(ghostel--install-module-pair
built final
(expand-file-name "ghostel-module.version" build-dir)
(expand-file-name "ghostel-module.version" dest-dir))
(ghostel--install-support-assets dest-dir)
(message "ghostel: native module compiled successfully"))))))
(when (and build-dir (file-directory-p build-dir))
(ignore-errors (delete-directory build-dir t))))
(file-missing
(display-warning 'ghostel
(format "zig executable not found while compiling in %s" source-dir)))
(error
(display-warning 'ghostel (error-message-string err))))))