Original Idea - provide mappers from EDN to Makefiles - and back again.
Message from 2022-10-07: I no longer think this is a good idea.
I now believe:
- Build dependencies are just data and code
- Generally, it’s nice to have a auto-caching build everything-command
- This can be solved with EDN,
babashka.fs/glob
andbabashka.fs/modified-since
Why?
- It’s possible to get equivalent performance with just babashka - perhaps even better if we don’t have to start / restart processes
- There’s just one language
- The “do we check in the Makefile?” question does not exist
- Other things can use the same EDN data that models build dependencies.
How?
Read this: https://blog.michielborkent.nl/speeding-up-builds-fs-modified-since.html
:comment | Makefile comment with # | string |
:target | Makefile target | string |
:dependencies | Dependencies for makefile target | sequence of strings |
:commands | Sequence of commands to produce target | sequence of strings |
def makefile
(:comment "Generate target for root index"}
[{;; # Generate target for root index
:target "index.html"
{:dependencies ["index.clj" "aphorisms/index.html" "aphorisms/play.edn"]
:commands ["./index.clj"]}
;; index.html: index.clj aphorisms/index.html aphorisms/play.edn
;; ./index.clj
:target "aphorisms/index.html"
{:dependencies ["aphorisms/index.org"]
:commands ["pandoc -s --shift-heading-level-by=1 --toc --from=org+smart -H live.html -i aphorisms/index.org -o aphorisms/index.html"]}
;; aphorisms/index.html: aphorisms/index.org
;; pandoc -s --shift-heading-level-by=1 --toc --from=org+smart -H live.html -i aphorisms/index.org -o aphorisms/index.html
])
makefile-edn/<-makefile-str
- read
from makefile string makefile-edn/->makefile-str
- write to
makefile string
Either as Clojure library or as babashka script. Could perhaps just provide the library — then babashka pulls in the library as needed.