I am using shake and a little bit confused about why one of my rule is triggered. Here is the rule:
"images/ghc-clojure.uuid" *> \uuidFile -> do
need ["images/ubuntu.uuid", "ghc-clojure/Dockerfile"]
buildImage uuidFile (cmImage "ghc-clojure") "ghc-clojure"
It basically builds a docker image and stores the image id in a file so that it can be used as dependency and tracked by shake. Definition of buildImage is pretty simple:
trackImage :: FilePath -> Image -> Action ()
trackImage uuidFile img = imageId img >>= writeFileChanged uuidFile
buildImage :: FilePath -> Image -> FilePath -> Action ()
buildImage uuidFile img dir = do
() <- cmd "docker" ["build","--no-cache","-t", show img, dir]
trackImage uuidFile img
I am experimenting with changing the build, so I cloned a pristine repository then copied old ghc-clojure.uuid file from another build tree to images/ghc-clojure.uuid in order to prevent rebuilding this particular image (takes a long time...).
But this does not work: shake triggers build of ghc-clojure rule although file is newer. Is there a way to tell it to simply use the file it finds? I assume what I want to do does not work because shake's DB is not populated with content of this file?
Thanks for any help
Arnaud
Hi Arnaud,
> But this does not work: shake triggers build of ghc-clojure rule although file is newer.
Shake treats timestamps as proxies for equality. Being older or newer
is irrelevant, Shake just sees the file has changed, thus is dirty,
and thus rebuilds it.
> Is there a way to tell it to simply use the file it finds?
Yes. Pass --old-file=images/ghc-clojure.uuid and it will skip it (this
matches the Make interface).
On the plus side, I'll go away and write it down, and I also plan to
add a new non-Make-compatible flag which does things in a more
sensible/principled way, which hopefully will be easier to use.