[darcs-users] make continuous
me at mornfall.net
Wed Jul 22 09:07:14 UTC 2009
twb at cybersource.com.au (Trent W. Buck) writes:
> twkm> changing gmake so it is a daemon that waits for events from the
> twkm> o/s would limit its portability, but i wouldn't doubt they'd
> twkm> consider doing it if it sounded cool enough.
> twkm> foo.c is too complex, you create bar.c, notified-gmake spits at
> twkm> you because it doesn't know crap about it yet, pull stuff out of
> twkm> foo.c, app no longer compiles or links because bar.c hasn't be
> twkm> written yet, ... but yeah, eventually all would be well.
> twkm> dnotify -MCDR $(find . -type d) -e make &
> twkm> dnotify can't handle a directory named -e, and that particular
> twkm> command can't handle directories with whitespace in their names,
> twkm> but otherwise it would thrash when almost anything was changed.
dnotify -MCDR -q 1 -r src -e cabal build
however, this also comes at a cost: if your editor creates temporary files,
these will trigger (needless) rebuilds.
This seems to work better:
while true; do
inotifywait -e CLOSE_WRITE -e MOVE_SELF $(DARCS_FILES)
but will miss changes done while cabal build is running... probably a more
involved program is needed to make things work correctly for all the cases. See
There are some issues with inotify, specifically if you (vim will do this)
moves a file over a watched one, you get notified, but further monitoring is
then cancelled. I imagine you need something like
watch file action = addWatch inotify [MoveSelf, CloseWrite] file handle
where handle ev = case ev of
Ignored -> watch file action >> action
_ -> action
use like: watch "src/darcs.hs" (putStrLn "modified!")
It'd be great if someone wanted to build a notifier around the above "watch"
primitive, that'd sorta work like dnotify -q 1, but only waiting for specific
Of course it would be also possible to build something like this with polling
(which would be much more portable, although less efficient). It would also be
possible to use forkIO to make the interface very similar to the above. By
using a primitive like "buildOrQueue" (itself exploiting IORefs), it would be
quite straightforward to implement a full build-upon-modification tool that
could invoke anything you wanted (e.g. cabal build).
PS: Yes, I hope someone will pick it up from here.
More information about the darcs-users