-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-make.el
56 lines (46 loc) · 1.79 KB
/
build-make.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
;;; make.el --- Build Makefile projects in Emacs -*- lexical-binding: t; -*-
;; Copyright (C) 2024 Justin Andreas Lacoste
;; Author: Justin Andreas Lacoste <[email protected]>
;; URL: https://github.com/27justin/build.el
;; Version: 0.1
;; Keywords: compile, build-system, makefile
;;; Commentary:
;;; Requirements:
(require 'build-api)
(require 'make-mode)
;;; Code
(defun build-make-project-p ()
(build--project-file-exists-p "Makefile"))
(defun make--get-targets (callback)
"Call `callback' asynchronously with all Make targets that match `query'."
(with-current-buffer (find-file (format "%s/Makefile" (project-root (project-current))))
(setq-local makefile-need-target-pickup t)
(makefile-pickup-targets)
(funcall callback (flatten-list makefile-target-table))))
(defun build-make-run (&optional args)
"`bazel test' a target"
(interactive
(list (transient-args 'build-make-transient))
)
(make--get-targets (lambda(targets)
(let* ((choice (funcall build--completing-read "Target: " targets)))
(funcall build--compile (format "make %s %s" choice (string-join args " ")))))))
(with-eval-after-load 'transient
;; Make transient definition
(transient-define-prefix build-make-transient ()
"Make Commands"
:value '("-j 1" "-f Makefile")
["Make Options\n"
["Generic"
("-f" "Makefile" "-f " :prompt "Path to Makefile: " :class transient-option)
("-j" "Threads" "-j " :prompt "# of threads: " :class transient-option :always-read t)
("v" "Variables" " " :prompt "Override variables: " :class transient-option :always-read t)
]
]
[""
["Run"
("r" "Run" build-make-run)
]
]))
(add-to-list 'build--systems '(build-make-project-p . build-make-transient))
(provide 'build-make)