Created
September 30, 2010 21:05
-
-
Save lancepantz/605325 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro defile | |
"Define a file task. Uses the same syntax as deftask, however the task name | |
is a string representing the name of the file to be generated by the body. | |
Source files may be specified in the dependencies set, in which case | |
the file task will only be ran if the source is newer than the destination. | |
(defile \"main.o\" #{\"main.c\"} | |
(sh \"cc\" \"-c\" \"-o\" \"main.o\" \"main.c\"))" | |
[name & forms] | |
(let [{:keys [deps body doc]} (parse-task-opts forms) | |
{:keys [destruct pred actions]} (parse-body body) | |
{file-deps true task-deps false} (group-by string? deps)] | |
`(swap! tasks update '~name update-task '~deps '~doc | |
(fn [~destruct] | |
(let [f# (file ~name)] | |
(when (and (or (not (.exists f#)) | |
(seq (filter (partial mtime< f#) | |
(into ~file-deps | |
(map #(file ".cake" "run" (name %)) | |
'~task-deps))))) | |
~pred) | |
~@actions)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment