Confused about why a rule is triggered

11 views
Skip to first unread message

arnaud...@gmail.com

unread,
Dec 3, 2015, 12:04:34 PM12/3/15
to Shake build system
Hello,

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

Neil Mitchell

unread,
Dec 3, 2015, 1:30:30 PM12/3/15
to Arnaud Bailly, Shake build system
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). I don't know if you'll need to pass that
in subsequent calls or not, the exact semantics aren't too easy to
remember and I don't have it written down.

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.

Thanks, Neil

Arnaud Bailly

unread,
Dec 3, 2015, 3:27:48 PM12/3/15
to Neil Mitchell, Shake build system
On Thu, Dec 3, 2015 at 7:30 PM, Neil Mitchell <ndmit...@gmail.com> wrote:
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.


OK, makes sense.
 
> 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).

Oh, great thanks. I have not used make enough to know that :-)
 
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.


Looking forward to it,

Thanks a lot
Regards
Arnaud
Reply all
Reply to author
Forward
0 new messages