-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-cargo.el
61 lines (50 loc) · 1.7 KB
/
build-cargo.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
57
58
59
60
61
;;; cargo.el --- Build Cargo 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, cargo
;;; Commentary:
;;; Requirements
(require 'build-api)
;;; Code
(defun build-cargo-project-p ()
(build--project-file-exists-p "Cargo.toml"))
(defun build-cargo-build (&optional args)
"Run cargo build with the provided ARGS."
(interactive
(list (transient-args 'build-cargo-transient)))
(funcall build--compile (format "cargo build %s" (string-join args " "))))
(defun build-cargo-run (&optional args)
"Run cargo run with the provided ARGS."
(interactive
(list (transient-args 'build-cargo-transient)))
(funcall build--compile (format "cargo run %s" (string-join args " "))))
(with-eval-after-load 'transient
(transient-define-prefix build-cargo-transient ()
"Cargo Build Commands"
:value '("--debug")
:incompatible '(("--release" "--profile ")
("--lib" "--bins" "--examples"))
["Cargo Options\n"
["Generic"
("-r" "Release" "--release")
("-l" "Build library" "--lib")
("-b" "Build binaries" "--bins")
("-e" "Build examples" "--examples")
]
["Profile"
("-p" "Set profile" "--profile " :always-read t :class transient-option)
("-t" "Target triple" "--target " :always-read t :class transient-option)
]
]
[""
["Build"
("b" "Build" build-cargo-build)
]
["Run"
("r" "Run" build-cargo-run)
]
]))
(add-to-list 'build--systems '(build-cargo-project-p . build-cargo-transient))
(provide 'build-cargo)