tools/make: make +make/run more robust; add +make/run-last #543
This commit is contained in:
parent
fb95ef6255
commit
adb3fdbdce
1 changed files with 20 additions and 9 deletions
|
@ -1,14 +1,25 @@
|
|||
;;; tools/make/autoload.el -*- lexical-binding: t; -*-
|
||||
|
||||
(require 'makefile-executor)
|
||||
|
||||
;;;###autoload
|
||||
(defun +make/run ()
|
||||
"Run a make task in the current project."
|
||||
"Run a make task in the current project. If multiple makefiles are available,
|
||||
you'll be prompted to select one."
|
||||
(interactive)
|
||||
(require 'makefile-executor)
|
||||
(let* ((buffer-file (or buffer-file-name default-directory))
|
||||
(makefile-dir (locate-dominating-file buffer-file "Makefile")))
|
||||
(unless makefile-dir
|
||||
(user-error "No makefile found in this project."))
|
||||
(let ((default-directory makefile-dir))
|
||||
(makefile-executor-execute-target
|
||||
(expand-file-name "Makefile")))))
|
||||
(if (doom-project-p 'nocache)
|
||||
(makefile-executor-execute-project-target)
|
||||
(let ((makefile (cl-loop with buffer-file = (or buffer-file-name default-directory)
|
||||
for file in (list "Makefile" "makefile")
|
||||
if (locate-dominating-file buffer-file file)
|
||||
return file)))
|
||||
(unless makefile
|
||||
(user-error "Cannot find a makefile in the current project"))
|
||||
(let ((default-directory (file-name-directory makefile)))
|
||||
(makefile-executor-execute-target makefile)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +make/run-last ()
|
||||
"TODO"
|
||||
(interactive)
|
||||
(makefile-executor-execute-last nil))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue