1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-20 07:34:49 +00:00

Add sh-rule and sh-phony to jpm dialect.

Provides useful shorthand for writing rules that invoke
shell commands.
This commit is contained in:
Calvin Rose 2020-04-14 20:43:53 -05:00
parent 71882475d6
commit 058f63b440

View File

@ -34,7 +34,7 @@
(defmacro rule
"Add a rule to the rule graph."
[target deps & body]
~(,rule-impl ,target ,deps (fn [] nil ,;body)))
~(,rule-impl ,target ,deps (fn [] ,;body)))
(defmacro phony
"Add a phony rule to the rule graph. A phony rule will run every time
@ -43,6 +43,16 @@
[target deps & body]
~(,rule-impl ,target ,deps (fn [] nil ,;body) true))
(defmacro sh-rule
"Add a rule that invokes a shell command, and fails if the command returns non-zero."
[target deps & body]
~(,rule-impl ,target ,deps (fn [] (,assert (,zero? (,os/shell (,string ,;body)))))))
(defmacro sh-phony
"Add a phony rule that invokes a shell command, and fails if the command returns non-zero."
[target deps & body]
~(,rule-impl ,target ,deps (fn [] (,assert (,zero? (,os/shell (,string ,;body))))) true))
(defn add-dep
"Add a dependency to an existing rule. Useful for extending phony
rules or extending the dependency graph of existing rules."