I am using Shake to build lilypond files, which are then being put into a webpage. I tried to model my Build.hs
after the first example in the manual:
import Development.Shake
import Development.Shake.Command
import Development.Shake.FilePath
import Development.Shake.Util
dest = "www/static"
main :: IO ()
main = shakeArgs shakeOptions{shakeFiles="_build"} $ do
want ["www/index.html"]
phony "clean" $ do
putNormal "Cleaning files"
removeFilesAfter dest ["//*"]
"www/index.html" %> \out -> do
fs <- getDirectoryFiles "src/lilypond" ["*.ly"]
let pdfs = ["www/static" </> (takeBaseName sourceFile) -<.> "pdf" | sourceFile <- fs]
need pdfs
cmd_ "cp" "src/www/index.html" "www/index.html"
dest <> "//*.pdf" %> \outp -> do
let c = "src/lilypond" </> (dropDirectory1 . dropDirectory1 $ outp -<.> "ly")
let o = dropExtension outp
cmd_ "lilypond" "-o" [o] [c]
The intended behaviour is "to build the index.html file, all PDFs should be generated to www/static
from respective src/lilypond/*.ly
files". This works for a clean build, but editing a source .ly
files does not trigger a rebuild and I can't figure out why. (UPDATE: editing src/www/index.html
also does not trigger a rebuild)
Things I've tried:
shake-build www/static/muppets.pdf
. Same behaviour.--profile
. Nothing jumps out to me here..ly
file? Saw depends = []
in output, would have expected non empty.need [c]
in the PDF rule.I feel like there is a basic concept here I've missed :/
You are missing a call to need [c]
just before cmd_ "lilypond" ...
. That will cause it to add the necessary dependency - as a general rule of thumb, before calling cmd
, you call need
on all the things it will use.