Skip to content

Commit 299acfd

Browse files
committed
Move build directory management from Sh to Elisp
1 parent 94e2b0b commit 299acfd

File tree

1 file changed

+17
-31
lines changed

1 file changed

+17
-31
lines changed

vterm.el

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -92,44 +92,30 @@ confirmation before compiling."
9292
(defvar vterm-install-buffer-name " *Install vterm* "
9393
"Name of the buffer used for compiling vterm-module.")
9494

95-
(defun vterm-module--cmake-is-available ()
96-
"Return t if cmake is available.
97-
CMake is needed to build vterm, here we check that we can find
98-
the executable."
99-
100-
(unless (executable-find "cmake")
101-
(error "Vterm needs CMake to be compiled. Please, install CMake"))
102-
t)
103-
10495
;;;###autoload
10596
(defun vterm-module-compile ()
10697
"Compile vterm-module."
10798
(interactive)
108-
(when (vterm-module--cmake-is-available)
109-
(let* ((vterm-directory
110-
(shell-quote-argument
111-
;; NOTE: This is a workaround to fix an issue with how the Emacs
112-
;; feature/native-comp branch changes the result of
113-
;; `(locate-library "vterm")'. See emacs-devel thread
114-
;; https://lists.gnu.org/archive/html/emacs-devel/2020-07/msg00306.html
115-
;; for a discussion.
116-
(file-name-directory (locate-library "vterm.el" t))))
117-
(make-commands
118-
(concat
119-
"cd " vterm-directory "; \
120-
mkdir -p build; \
121-
cd build; \
122-
cmake -G 'Unix Makefiles' "
123-
vterm-module-cmake-args
124-
" ..; \
125-
make; \
126-
cd -"))
127-
(buffer (get-buffer-create vterm-install-buffer-name)))
128-
(pop-to-buffer buffer)
99+
(unless (executable-find "cmake")
100+
(error "Vterm needs CMake to be compiled. Please, install CMake"))
101+
(let* ((vterm-directory
102+
(shell-quote-argument
103+
;; NOTE: This is a workaround to fix an issue with how the Emacs
104+
;; feature/native-comp branch changes the result of
105+
;; `(locate-library "vterm")'. See emacs-devel thread
106+
;; https://lists.gnu.org/archive/html/emacs-devel/2020-07/msg00306.html
107+
;; for a discussion.
108+
(file-name-directory (locate-library "vterm.el" t))))
109+
(default-directory (expand-file-name "build" vterm-directory))
110+
(make-commands (format "cmake -G 'Unix Makefiles' %s .. && make"
111+
vterm-module-cmake-args)))
112+
(make-directory default-directory t)
113+
(with-current-buffer (get-buffer-create vterm-install-buffer-name)
129114
(compilation-mode)
130115
(if (zerop (let ((inhibit-read-only t))
131-
(call-process "sh" nil buffer t "-c" make-commands)))
116+
(call-process "sh" nil t t "-c" make-commands)))
132117
(message "Compilation of `emacs-libvterm' module succeeded")
118+
(pop-to-buffer vterm-install-buffer-name)
133119
(error "Compilation of `emacs-libvterm' module failed!")))))
134120

135121
;; If the vterm-module is not compiled yet, compile it

0 commit comments

Comments
 (0)