Function: pdf-tools-build-server
pdf-tools-build-server is a natively compiled function defined in
pdf-tools.el.
Signature
(pdf-tools-build-server TARGET-DIRECTORY &optional SKIP-DEPENDENCIES-P FORCE-DEPENDENCIES-P CALLBACK BUILD-DIRECTORY)
Documentation
Build the epdfinfo program in the background.
Install into TARGET-DIRECTORY, which should be a directory.
If CALLBACK is non-nil, it should be a function. It is called with the compiled executable as the single argument or nil, if the build failed.
Expect sources to be in BUILD-DIRECTORY. If nil, search for it
using pdf-tools-locate-build-directory.
See pdf-tools-install for the SKIP-DEPENDENCIES-P and
FORCE-DEPENDENCIES-P arguments.
Returns the buffer of the compilation process.
Source Code
;; Defined in /nix/store/63h5z2vmzn0mfavcxi2idi23g5xcgkbl-emacs-packages-deps/share/emacs/site-lisp/elpa/pdf-tools-20260102.1101/pdf-tools.el
(defun pdf-tools-build-server (target-directory
&optional
skip-dependencies-p
force-dependencies-p
callback
build-directory)
"Build the epdfinfo program in the background.
Install into TARGET-DIRECTORY, which should be a directory.
If CALLBACK is non-nil, it should be a function. It is called
with the compiled executable as the single argument or nil, if
the build failed.
Expect sources to be in BUILD-DIRECTORY. If nil, search for it
using `pdf-tools-locate-build-directory'.
See `pdf-tools-install' for the SKIP-DEPENDENCIES-P and
FORCE-DEPENDENCIES-P arguments.
Returns the buffer of the compilation process."
(unless callback (setq callback #'ignore))
(unless build-directory
(setq build-directory (pdf-tools-locate-build-directory)))
(cl-check-type target-directory (satisfies file-directory-p))
(setq target-directory (file-name-as-directory
(expand-file-name target-directory)))
(cl-check-type build-directory (and (not null)
(satisfies file-directory-p)))
(when (and skip-dependencies-p force-dependencies-p)
(error "Can't simultaneously skip and force dependencies"))
(let* ((compilation-auto-jump-to-first-error nil)
(compilation-scroll-output t)
(shell-file-name (pdf-tools-find-bourne-shell))
(shell-command-switch "-c")
(process-environment process-environment)
(default-directory build-directory)
(autobuild (shell-quote-argument
(expand-file-name (if (eq system-type 'android) "autobuild.android" "autobuild") build-directory)))
(msys2-p (equal "bash.exe" (file-name-nondirectory shell-file-name))))
(unless shell-file-name
(error "No suitable shell found"))
(when msys2-p
(push "BASH_ENV=/etc/profile" process-environment))
(let ((executable
(expand-file-name
(concat "epdfinfo" (and (eq system-type 'windows-nt) ".exe"))
target-directory))
(compilation-buffer
(compilation-start
(format "%s -i %s%s%s"
autobuild
(shell-quote-argument target-directory)
(cond
(skip-dependencies-p " -D")
(force-dependencies-p " -d")
(t ""))
(if pdf-tools-installer-os (concat " --os " pdf-tools-installer-os) ""))
t)))
;; In most cases user-input is required, so select the window.
(if (get-buffer-window compilation-buffer)
(select-window (get-buffer-window compilation-buffer))
(pop-to-buffer compilation-buffer))
(with-current-buffer compilation-buffer
(setq-local compilation-error-regexp-alist nil)
(add-hook 'compilation-finish-functions
(lambda (_buffer status)
(funcall callback
(and (equal status "finished\n")
executable)))
nil t)
(current-buffer)))))