Rebuild on changes to pure code?

17 views
Skip to first unread message

diste...@wehi.edu.au

unread,
Mar 7, 2017, 1:43:44 AM3/7/17
to Shake build system
I understand the shake database tracks the commands used in a build `Rule`. However, if a `Rule` involves pure code, and this changes, I presume shake won't know as much.

I presume too that there's no real way around this. But perhaps it might be worth warning users about it somewhere in the documentation.


Leon

Neil Mitchell

unread,
Mar 7, 2017, 1:48:46 AM3/7/17
to diste...@wehi.edu.au, Shake build system
Hi Leon,

Correct - Shake addresses that in the user manual, see
http://shakebuild.com/manual#changing-build-rules. Any further
information you would like? Anywhere you expected a warning but didn't
see it?

Thanks, Neil

t...@dockerz.net

unread,
Mar 20, 2017, 2:06:52 AM3/20/17
to Shake build system
> Correct - Shake addresses that in the user manual, see
> http://shakebuild.com/manual#changing-build-rules. Any further
> information you would like? Anywhere you expected a warning but didn't
> see it?

I'm a little confused by this. In this tiny example:

```
import Development.Shake
import Development.Shake.Command
import Development.Shake.FilePath
import Development.Shake.Util

import Data.Monoid

postgrestUrl :: String
postgrestUrl = "https://github.com/begriffs/postgrest/releases/download/v" <> ver <> "/postgrest-" <> ver <> "-ubuntu.tar.xz"
where
ver = "0.4.0.0"

main :: IO ()
main = shakeArgs shakeOptions{shakeFiles="_build"} $ do
want ["_build/postgrest.tar.xz"]

phony "clean" $ do
putNormal "Cleaning files in _build"
removeFilesAfter "_build" ["//*"]

"_build/postgrest.tar.xz" %> \out -> do
cmd "wget --no-verbose -O" [out] [postgrestUrl]
```

the rule runs as expected, and the file is downloaded correctly. However, I would have hoped that changing the value of `ver` would cause the executed command line to change, and hence a rebuild would cause shake to download the new version. Yet this doesn't seem to be the case. Presumably I am missing something simple?

Neil Mitchell

unread,
Mar 20, 2017, 6:20:33 PM3/20/17
to Tim Docker, Shake build system
Hi Tim,

> the rule runs as expected, and the file is downloaded correctly. However, I would have hoped that changing the value of `ver` would cause the executed command line to change, and hence a rebuild would cause shake to download the new version. Yet this doesn't seem to be the case. Presumably I am missing something simple?

I'm not sure why you expect it to rebuild - it's not a "tracked"
value, in the sense that it is just code that Shake can't peer into,
so it doesn't know if it changes. If you want to regularly change
`ver` I would recommend turning it into an Oracle value (which would
be tracked) or taking ver into shakeVersion. The first is conceptually
correct, but the second will equally work, at the cost of being more
crude and causing more rebuilds than strictly necessary.

Thanks, Neil

Tim Docker

unread,
Mar 20, 2017, 6:27:57 PM3/20/17
to Neil Mitchell, Shake build system

I’m not sure why you expect it to rebuild - it’s not a “tracked” value

I guess I’d naively expected that the text passed to cmd would be “tracked”, as this would include compiler flags etc. But presumably the monad structure of rules makes this impossible.

Now I’ve read the “Dependencies on extra information” section from the manual I can see my options here.

Thanks for the help.

Tim

Reply all
Reply to author
Forward
0 new messages