We'll have to stop using nonblocking reads, unfortunately. But this seems
to work better than nothing. There's still a race condition that could
theoretically make GNU make angry, unfortunately, since we briefly set the
socket to nonblocking.
So that more than one redo doesn't try to build the same thing at the same
time. Kind of dumb, though, since it currently wipes out all the locks at
the toplevel, so running more than one at a time won't give accurate
results, but the -j option doesn't do anything yet.
It used to say:
redo: t/all
redo: hello
and now it says:
redo t/all
redo t/hello
ie. there's no colon, and the path is intact. That means if the build
fails, you can cut-and-paste 'redo t/hello', add a -v, and try to debug
what went wrong.
This is a departure from how djb seems to have it set up, but I just like it
better. It's more like the reasonably-common Makefile standard. (Although
what make *actually* does is just use the first target declared in the
file.)
This is what GNU make does. If SHELL isn't defined, we still fall back to
calling sh.
Rumour has it that Google has some kind of build system that can be
massively distributed if you just set SHELL to the right program; maybe
it'll work with redo now. (Of course it won't do you any good until we
implement parallel builds...)
I'm pretty sure this must be the intended behaviour. It's kind of
meaningless to use this to declare a dependency on a file that might start
to exist later, if the file already exists.
redo-ifchange already does this, and then calls redo.py, so it's redundant.
The only weird case is if a .do file calls 'redo' instead of
'redo-ifchange'. I'm not sure what exactly is supposed to happen here.
test.do does this, for example, and it works, but only because we always do
'redo test' and nobody depends on 'redo-ifchange test'; if they did, the
dependencies would be off, I guess. But maybe it's meaningless to do that
anyway.
So if we're in redo/t/ and running 'redo hello', we'll detect redo/.redo and
use that one rather than creating a new redo/t/.redo directory.
The downside of this is we get slightly different behaviour if the *first*
thing you build isn't from the root. Probably that's bad, but it should
hopefully be rare.
'./redo -d test' reveals that we check and re-check things like CC and LD
even when they're children of objects that don't need to be rebuilt, and who
we've already checked earlier in the build cycle. We need to be a little
smarter about pruning if we want dependency checking to be fast.
But it seems to be pretty unsolvable in the current form; the problem is
that when you're nesting one jwack inside the other and the jobserver is GNU
make, there's no way to tell the parent jwack not to use up a token. Thus,
if you nest too deeply, it just deadlocks.
So this approach isn't really going to work the way it is.
And move test scripts into t/ subdir to keep things clean.
As part of that, make sure redo adds itself to the PATH on startup so that
subscripts can find it.