Add sh-rule and sh-phony to jpm dialect.
Provides useful shorthand for writing rules that invoke
shell commands.
(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
[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."
