Last active
January 6, 2017 13:05
-
-
Save micha/f8e15235a2e447259b3384eeb4b37427 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(require '[clojure.java.io :as io]) | |
(deftask demo [] | |
(let [tmp (tmp-dir!) ; Anonymous, boot-managed temp directory. | |
prev-fs (atom nil)] ; Atom where the previous fileset is stored. | |
(with-pre-wrap [fs] | |
(let [diff (fileset-diff @prev-fs (reset! prev-fs fs)) ; Fileset containing only changed files. | |
inputs (->> (input-files diff) ; Sequence of [String, java.io.File] | |
(by-ext [".c"]) ; pairs, the classpath path and File | |
(map (juxt tmp-path tmp-file)))] ; for files with given extensions. | |
(doseq [[inpath infile] inputs] | |
(let [outpath (.replaceAll inpath "\\.c$" ".o") ; The output file classpath path. | |
outfile (doto (io/file tmp outpath) io/make-parents)] ; The output File (in the temp dir). | |
(cc infile outfile))) ; The cc fn is assumed to be defined elsewhere. | |
(-> fs (add-resource tmp) (commit!)))))) ; Add temp dir to fileset, and commit changes. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment