Commit graph

20 commits

Author SHA1 Message Date
Avery Pennarun
984ad747f8 Remove special case for "dirname" -> "dirname/all"
It actually decreases readability of the .do files - by not making it
explicit when you're going into a subdir.

Plus it adds ambiguity: what if there's a dirname.do *and* a dirname/all?
We could resolve the ambiguity if we wanted, but that adds more code, while
taking out this special case makes *less* code and improves readability.
I think it's the right way to go.
2010-11-24 02:48:27 -08:00
Avery Pennarun
282bb0488e If the created target is a directory, it's okay for the .do to create it.
Normally, creating the target $1 yourself is bad; create $3 instead.  But if
$1 is a directory, we'll allow it.  That way 'redo subdir' can call
subdir.do, and subdir.do can both create the directory *and* run a bunch of
sub-.do files on it.
2010-11-24 02:30:54 -08:00
Avery Pennarun
83dd52c209 Targets created from stdout should be rw-, not rwx.
I had forgotten to pass the create mode to open().  Oops!
2010-11-24 02:26:15 -08:00
Avery Pennarun
190dd657d8 It's okay if a file is marked as generated and doesn't have a .do.
If we don't know how to rebuild the file, but it already exists, that's
pretty harmless.  Just consider it a successful rebuild.
2010-11-24 02:18:19 -08:00
Avery Pennarun
f337df463d state.stamp() can't imply state.built().
...because we deliberately stamp non-generated files as well, and that
doesn't need to imply that we rebuilt them just now.  In fact, we know for a
fact that we *didn't* rebuild them just now, but we still need to record the
timestamp for later.
2010-11-22 22:53:40 -08:00
Avery Pennarun
6d767e2a65 user-friendliness sanity checks: catch common mistakes regarding $1/$2/$3.
.do files should never modify $1, and should write to *either* $3 or stdout,
but not both.  If they write to both, it's probably because they forgot to
redirect stdout to stderr, a very easy mistake to make but a hard one to
detect.

Now redo detects it for you and prints an informative message.
2010-11-22 04:43:33 -08:00
Avery Pennarun
dce0076554 Print a useful message and exit when the .redo directory disappears. 2010-11-22 04:04:45 -08:00
Avery Pennarun
2dbd47100d state.py: reduce race condition between Lock.trylock() and unlock().
If 'redo clean' deletes the lockfile after trylock() succeeds but before
unlock(), then unlock() won't be able to open the pipe in order to release
readers, and any waiters might end up waiting forever.

We can't open the fifo for write until there's at least one reader, so let's
open a reader *just* to let us open a writer.  Then we'll leave them open
until the later unlock(), which can just close them both.
2010-11-22 04:04:45 -08:00
Avery Pennarun
135d1c161a builder.py: set FD_CLOEXEC flag on $3 when running a .do file.
Otherwise it could be inherited by other jwack jobs started from the same
parent process, resulting in some very-hard-to-debug race conditions, let me
tell you.
2010-11-22 01:48:02 -08:00
Avery Pennarun
8d0eba9c44 builder.py: use os.exec() instead of subprocess.call().
This avoids a second fork altogether, which apparently doesn't matter all
that much (5.3s -> 5.15s).  However, simply not importing the subprocess
module reduces us further to 4.6s.

And 'ps axf' now looks prettier because we have fewer stupid intermediate
processes.
2010-11-22 00:15:29 -08:00
Avery Pennarun
dcc2edba0c builder.py: further refactoring to run more stuff in the parent process
instead of inside the fork.

Still doesn't seem to affect runtime.  Good.

One nice side effect is jwack.py no longer needs to know anything about our
locks.
2010-11-22 00:04:15 -08:00
Avery Pennarun
3209316856 builder.py: now the only exported function is main().
We can also avoid forking altogether if should_build() returns false.  This
doesn't seem to result in any noticeable speedup, but it's cleaner at least.
2010-11-21 23:36:29 -08:00
Avery Pennarun
547dbe550f builder.py: remove the build() wrapper function and BuildError.
The only thing we want to do on a build error is return a nonzero exit code,
so let's just do that, simplifying the code a bit.
2010-11-21 23:06:31 -08:00
Avery Pennarun
7aa7c41e38 builder,jwack: slight cleanup to token passing.
In rare cases, one process could end up holding onto more than one token.
2010-11-21 22:46:20 -08:00
Avery Pennarun
867402e803 Fixup the target name in "exit code: 1" lines. 2010-11-21 07:25:05 -08:00
Avery Pennarun
b937e62d89 Add a new -k (--keep-going) option, like make has.
Previously, the default was to *always* keep going, which is actually not
usually what you want.  Now we actually exit correctly after an error.  Of
course you still might have multiple errors before existing if you were
building in parallel.
2010-11-21 07:15:48 -08:00
Avery Pennarun
6b0da1fda0 Add a -x option that just passes -x to the subshell.
This is often more useful than -v, since it prints the actual commands being
executed, not just the lines being input from the script.
2010-11-21 06:36:15 -08:00
Avery Pennarun
03a054ca79 Add a --debug-locks option.
Get rid of the "locked..." and "...unlocked!" messages by default, since
they're not usually interesting.  But add a new option to bring them back in
case we end up with trouble debugging the locking stuff.  (I don't really
100% trust it yet, although I haven't had a problem for a while now.)
2010-11-21 06:23:41 -08:00
Avery Pennarun
f644f3bd04 Remove the need for relpath (and thus abspath) in builder.py. 2010-11-21 03:35:19 -08:00
Avery Pennarun
f7734c3b8d Split build functions into builder.py. 2010-11-19 07:32:04 -08:00