mirror of
https://github.com/janet-lang/janet
synced 2026-09-09 10:59:10 +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:
+11
-1
@@ -34,7 +34,7 @@
|
|||||||
(defmacro rule
|
(defmacro rule
|
||||||
"Add a rule to the rule graph."
|
"Add a rule to the rule graph."
|
||||||
[target deps & body]
|
[target deps & body]
|
||||||
~(,rule-impl ,target ,deps (fn [] nil ,;body)))
|
~(,rule-impl ,target ,deps (fn [] ,;body)))
|
||||||
|
|
||||||
(defmacro phony
|
(defmacro phony
|
||||||
"Add a phony rule to the rule graph. A phony rule will run every time
|
"Add a phony rule to the rule graph. A phony rule will run every time
|
||||||
@@ -43,6 +43,16 @@
|
|||||||
[target deps & body]
|
[target deps & body]
|
||||||
~(,rule-impl ,target ,deps (fn [] nil ,;body) true))
|
~(,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
|
(defn add-dep
|
||||||
"Add a dependency to an existing rule. Useful for extending phony
|
"Add a dependency to an existing rule. Useful for extending phony
|
||||||
rules or extending the dependency graph of existing rules."
|
rules or extending the dependency graph of existing rules."
|
||||||
|
|||||||
Reference in New Issue
Block a user