Shake: signal, do you need to rebuild anything at all

I use shake to create a bunch of static web pages which I then need to upload to a remote host using sftp. Cronjob is currently running

git pull # get possibly updated sources ./my-shake-system lftp ... # upload 

I'd like to avoid executing the final command unless the shake actually rebuilds anything. Is there any way to tell shake "Run the foo command, after all else, and only if you change something!"?

Or, conversely, let him know that he did something in the process exit code?

I think I can add a rule that depends on everything the file is possibly generated, but it seems redundant and error prone.

+3
source share
1 answer

There is currently no direct / easy way to determine if something has been built. This is also not such a useful concept as for simpler build systems, as certain rules (especially those that define storedValue to return Nothing ) will always be "rerun", but then very quickly decide that they do not need to run rules that depend from them. To shake is the same as repeating. I can come up with several approaches that best probably depend on your situation:

Mark interesting rules

You can mark each interesting rule (which creates something that requires loading) with a function that writes to a specific file. If this particular file exists, you need to download it. This may work a little better, as if you were doing several Shake attempts, and in the first one something was changing, and the second did nothing, the file would still be present. If that makes sense, use IORef instead of the file.

Use profiling

Shake has a pretty advanced profiling. If you pass shakeProfile=["output.json"] , a JSON file appears with a detailed description of what was created and when. Starts are indexed using Int, with 0 for the most recent run, and any runs that didn't build anything are excluded. If you have one rule that always works (for example, it is written to a dummy file with alwaysRerun ), then if something works at the same time, it is restored.

See the size of .shake.database

Shake has a database stored under shakeFiles . Each uninteresting launch will grow by a fairly small amount (~ 100 bytes), but a fixed size, taking into account your system. If he changed in size by a larger amount, then he did something interesting.

Of these approaches, tagging interesting rules is probably the easiest and most direct (although it risks forgetting to tag something).

+2
source

All Articles