源文件更改时摇不重建

Shake not rebuilding when source file changes

我正在使用 Shake 构建 lilypond 文件,然后将其放入网页中。我试图在 first example in the manual:

之后为我的 Build.hs 建模
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]

预期的行为是 "to build the index.html file, all PDFs should be generated to www/static from respective src/lilypond/*.ly files"。这适用于干净的构建,但编辑源 .ly 文件不会触发重建,我不明白为什么。 (更新:编辑 src/www/index.html 也不会触发重建)

我尝试过的事情:

我觉得我错过了一个基本概念:/

Full project here.

您在 cmd_ "lilypond" ... 之前错过了对 need [c] 的呼叫。这将导致它添加必要的依赖项 - 作为一般经验法则,在调用 cmd 之前,您对它将使用的所有东西调用 need