tools/make: make +make/run more robust; add +make/run-last #543

This commit is contained in:
Henrik Lissner 2018-04-20 04:14:30 -04:00
parent fb95ef6255
commit adb3fdbdce
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -1,14 +1,25 @@
;;; tools/make/autoload.el -*- lexical-binding: t; -*- ;;; tools/make/autoload.el -*- lexical-binding: t; -*-
(require 'makefile-executor)
;;;###autoload ;;;###autoload
(defun +make/run () (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) (interactive)
(require 'makefile-executor) (if (doom-project-p 'nocache)
(let* ((buffer-file (or buffer-file-name default-directory)) (makefile-executor-execute-project-target)
(makefile-dir (locate-dominating-file buffer-file "Makefile"))) (let ((makefile (cl-loop with buffer-file = (or buffer-file-name default-directory)
(unless makefile-dir for file in (list "Makefile" "makefile")
(user-error "No makefile found in this project.")) if (locate-dominating-file buffer-file file)
(let ((default-directory makefile-dir)) return file)))
(makefile-executor-execute-target (unless makefile
(expand-file-name "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))