Commit graph

210 commits

Author SHA1 Message Date
Avery Pennarun
96347f3d83 bash completions: also mark 'do' as a completable command.
(ie. minimal/do)
2011-01-01 21:59:24 -08:00
Avery Pennarun
3c256dee9b bash completions: work correctly when $cur is an empty string.
Otherwise 'cd t/defaults-flat' then 'redo <tab>' doesn't show all the
possible targets.
2011-01-01 21:57:29 -08:00
Avery Pennarun
70923c5f30 bash completions: call redo-targets for a more complete list.
Also fix handling of filenames needing quoting (like "t/space dir"),
directories, and targets named after directories.
2011-01-01 21:12:50 -08:00
Avery Pennarun
d5beda0ffe bash completions: work correctly with subdirs, ie. 'redo t/<tab>' 2011-01-01 21:12:14 -08:00
Zoran Zaric
fa4b64285d Sample bash completion rules for redo targets. 2011-01-01 17:15:16 -08:00
Avery Pennarun
7142c342ae minimal/do: faster deletion of stamp files.
"while/read/printf | xargs -0" is much faster than while/read/rm, because it
doesn't fork so many times.
2011-01-01 04:15:12 -08:00
Avery Pennarun
8aa27d050b minimal/do: delete .tmp files if a build fails. 2011-01-01 04:14:41 -08:00
Avery Pennarun
fb5275938d minimal/do: use ".did" stamp files instead of empty target files.
If all.do runs and creates no output, we shouldn't create a file called
'all', but we should remember that 'all' has been run successfully.  We do
this by creating 'all.did' during the build.

Since minimal/do always just wipes everything out every time it runs, we can
safely remove the .did files after minimal/do terminates, so this doesn't
clutter things too much in normal use.

This fixes some edge cases, particularly that 'minimal/do clean' no longer
leaves stupid files named "clean" lying around, and the redo-sh directory
can now be rebuilt correctly since we rebuild it as long as redo-sh.did
doesn't exist.  (We don't want to "rm -rf redo-sh" because it makes me
nervous.)
2011-01-01 04:11:20 -08:00
Avery Pennarun
41ef15fde2 minimal/do: use posix shell features instead of dirname/basename.
This avoids a few forks, and is a good example of how to do some "modern" sh
programming.  Plus we now use fewer lines of code.
2011-01-01 04:10:47 -08:00
Avery Pennarun
fb388b3dde Automatically select a good shell instead of relying on /bin/sh.
This includes a fairly detailed test of various known shell bugs from the
autoconf docs.

The idea here is that if redo works on your system, you should be able to
rely on a *good* shell to run your .do files; you shouldn't have to work
around zillions of bugs like autoconf does.
2010-12-21 04:44:39 -08:00
Avery Pennarun
e207b723b4 Move some of the tests from t/ into t/defaults-flat.
This lets us move t/default.do out of the way; it was confusing otherwise.
2010-12-19 04:54:44 -08:00
Avery Pennarun
2618ebfafb Man pages for redo-targets, redo-sources, redo-ood. 2010-12-19 04:11:05 -08:00
Avery Pennarun
560f95fd77 Don't update the database during redo-ood.
Makes it slightly faster.
2010-12-19 03:50:55 -08:00
Avery Pennarun
3b19ccad9f Add a new redo-ood command.
Prints the list of existing but out-of-date targets.
2010-12-19 03:50:38 -08:00
Avery Pennarun
df85b3d163 Move dependency checking from redo-ifchange into deps.py.
In preparation for sharing between multiple commands.
2010-12-19 03:50:38 -08:00
Avery Pennarun
f2d34fa685 New redo-sources and redo-targets commands.
Suggested by djb in personal email, and on the mailing list.  redo-targets
lists all the targets in the database; redo-sources lists all the existing
sources (ie. files that are referred to but which aren't targets).

redo-ifcreate filenames aren't included in the redo-sources list.
2010-12-19 03:50:38 -08:00
Avery Pennarun
db4c4fc17a Rename redo-oob to redo-unlocked, to more accurately represent its use.
It's still undocumented.  Because you shouldn't run it by hand.  So don't!
It's dangerous!
2010-12-19 01:20:13 -08:00
Avery Pennarun
ca7a1de4e3 Add Documentation/git-{import,export}.do scripts.
These export and import, respectively, the generated man pages to/from the
git branch called 'man'.  You can use it to retrieve the .1 files if you
don't have a working pandoc.
2010-12-19 01:05:52 -08:00
junkblocker
bab7b40a49 Don't rely on GNU find behaviour in clean.do. 2010-12-17 11:40:42 -08:00
Oscar Bonilla
0105b33483 _tty_width() will return zero when redo is run inside an emacs shell 2010-12-16 11:55:09 -08:00
Avery Pennarun
c13eac953e Release minimal/do to the public domain.
This makes it more convenient if you really want to include it as the build
script for your own projects.
2010-12-14 17:58:16 -08:00
Jonathan Wakely
fabe969fd8 Fix a couple of typos in the README. 2010-12-14 17:56:18 -08:00
Avery Pennarun
5f9b6eeaf4 install.do: stub /usr/bin programs: be smarter about finding the libdir.
We were hardcoding the absolute $LIBDIR location, which sounds smart, but not if
you're doing "make install" into a temp dir that will end up somewhere else
later.

Instead, look for ../lib/redo/ from wherever the binary is installed.
2010-12-14 02:51:44 -08:00
Avery Pennarun
3dd8d081be minimal/do: MacOS has /usr/bin/true, not /bin/true. 2010-12-14 02:47:51 -08:00
Avery Pennarun
95680ed7ef Switch to using a separate lockfile per target.
The previous method, using fcntl byterange locks, was very efficient and
avoided unnecessarily filesystem metadata churn (ie. creating/deleting
inodes).  Unfortunately, MacOS X (at least version 10.6.5) apparently has a
race condition in its fcntl locking that makes it unusably unreliable
(http://apenwarr.ca/log/?m=201012#13).

My tests indicate that if you only ever lock a *single* byterange on a file,
the race condition doesn't cause a problem.  So let's just use one lockfile
per target.  Now "redo -j20 test" passes for me on both MacOS and Linux.

This doesn't measurably affect the speed on Linux, at least, in my tests.

The bad news: it's hard to safely *delete* those lockfiles when we're done
with them, so they tend to accumulate in the .redo dir.
2010-12-14 02:44:29 -08:00
Avery Pennarun
294945bd0f Assert that one instance never holds multiple locks on the same file at once.
This could happen if you did 'redo foo foo'.  Which nobody ever did, I
think, but let's make sure we catch it if they do.

One problem with having multiple locks on the same file is then you have to
remember not to *unlock* it until they're all done.  But there are other
problems, such as: why the heck did we think it was a good idea to lock the
same file more than once?  So just prevent it from happening for now,
unless/until we somehow come up with a reason it might be a good idea.
2010-12-14 02:19:08 -08:00
Avery Pennarun
f5eabe61d2 install.do: don't crash when the manpages fail to build. 2010-12-12 05:42:20 -08:00
Avery Pennarun
8f9453a55d Fix tests on MacOS.
This comes down to the lack of a 'seq' command (what?!) and the fact that
BSD "wc -l" returns extra whitespace, while the GNU version doesn't.  We
should be using numeric comparisons instead of string comparisons, and then
it's ok.
2010-12-12 05:38:30 -08:00
Avery Pennarun
d21e6612e2 Answer a bunch more hopefully-FAQs. 2010-12-12 04:30:43 -08:00
Avery Pennarun
14456d5892 Generally clean up the README. 2010-12-12 03:50:56 -08:00
Avery Pennarun
6e5ec95c6a Add an 'install' target.
(usable as 'make install' or 'redo install', of course)
2010-12-12 02:48:42 -08:00
Avery Pennarun
4b48448233 Add a bunch of manpages. 2010-12-12 02:12:21 -08:00
Avery Pennarun
f16f0147b1 Add a redo-ifcreate test.
Turns out we weren't testing this one at all, which is a shame, because it
totally didn't work.
2010-12-11 23:50:12 -08:00
Avery Pennarun
e6f95521ae redo-always/redo-ifcreate/redo-stamp: work inside chdir().
If someone cd's to another directory and then runs redo-always, we weren't
adding to the right target.
2010-12-11 23:42:45 -08:00
Avery Pennarun
caea093519 Makefile: don't try to 'redo Makefile'.
This eliminates the relatively new warning about trying to redo static
files.
2010-12-11 23:41:40 -08:00
Avery Pennarun
c64b8a3eb1 Fix a race condition caused by zap_deps().
We can't just delete all the dependencies at the beginning and re-add them:
other people might be checking the same dependencies in parallel.  Instead,
mark them as delete_me up front, and then after the build completes, remove
only the delete_me entries.
2010-12-11 22:59:55 -08:00
Avery Pennarun
80fedc84fe minimal/do: make redo-ifchange (etc) into subprograms in a temp dir.
Using aliases for them was cute, but it didn't work with things like:

	find -name '*.c' | xargs redo-ifchange

since xargs doesn't know about aliases.
2010-12-11 21:47:55 -08:00
Avery Pennarun
1cb000ece1 redo.py: report when you're trying to rebuild a static file.
In redo-ifchange, this might be a good idea, since you might just want to
set a dependency on it, so we won't say anything from inside builder.py.
But if you're calling redo.py, that means you expect it to be rebuilt, since
there's no other reason to try.  So print a warning.

(This is what make does, more or less.)
2010-12-11 21:19:15 -08:00
Avery Pennarun
49f0a041b2 clean.do: cleanup *.tmp files that might have been left lying around.
...and fix a bug where builder.py can't handle it if its temp file is
deleted out from under it.
2010-12-11 21:10:57 -08:00
Avery Pennarun
b9987433c9 Disable the tests that don't work with minimal/do.
...only when running under minimal/do, of course.

The tests in question mostly fail because they're testing particular
dependency-related behaviour, and minimal/do doesn't support dependencies,
so naturally it doesn't work.
2010-12-11 21:06:12 -08:00
Avery Pennarun
a75555e7a8 minimal/do: don't completely abort if a sub-redo fails.
Just allow that sub-redo to return an error code.  Also, parent redos should
return error code 1, not the same code as the child.  That makes it easier
to figure out which file generated the "special" error code.
2010-12-11 20:37:27 -08:00
Avery Pennarun
fba684ee07 redo-ifchange can now be run even if there's no parent redo. 2010-12-11 19:08:53 -08:00
Avery Pennarun
e18fa85d58 The only thing in helpers.py that needed vars.py was the log stuff.
So put it in its own file.  Now it's safer to import and use helpers even if
you can't safely touch vars.
2010-12-11 18:34:02 -08:00
Avery Pennarun
1abaf77d35 jwack: start waitfds around fd#50.
That makes it a little easier to tell, in a strace, what the process is
waiting on.  If it's 100/101, then it's waiting on a token; 50+ means waiting
on a subtask.

Also, we weren't closing the read side of subtask fds on exec.  This didn't
cause any problems, but did result in a wasted fd in subprocesses.
2010-12-11 18:25:13 -08:00
Avery Pennarun
2706525fc0 redo-stamp: print a helpful message if stdin is a tty.
Otherwise your redo process might just freeze in the middle, and you'll
wonder why.
2010-12-11 18:13:58 -08:00
Avery Pennarun
0da5c7c082 Add a redo-always command: it adds an "always dirty" dependency to your target.
This is mostly useless except when combined with redo-stamp... I think.
2010-12-11 07:02:45 -08:00
Avery Pennarun
1d26d99e0c Fix a deadlock with redo-oob.
If a checksummed target A used to exist but is now missing, and we tried to
redo-ifchange that exact file, we would unnecessarily run 'redo-oob A A';
that is, we have to build A in order to determine if A needs to be built.

The sub-targets of redo-oob aren't run with REDO_UNLOCKED, so this would
deadlock instantly.

Add an assertion to redo-oob to ensure we never try to redo-ifchange the
primary target (thus converting the deadlock into an exception).  And skip
doing redo-oob when the target is already the same as the thing we have to
check.
2010-12-11 06:16:32 -08:00
Avery Pennarun
91630a892a Whoops, redo-oob was slightly wrong when used with -j.
We called 'redo' instead of 'redo-ifchange' on our indeterminate objects.
Since other instances of redo-oob might be running at the same time, this
could cause the same object to get rebuilt more than once unnecessarily.
The unit tests caught this, I just didn't notice earlier.
2010-12-11 05:54:39 -08:00
Avery Pennarun
e7f7119f2e If a checksummed file is deleted, we should still use redo-oob.
We were giving up and rebuilding the toplevel object, which did eventually
rebuild our checksummed file, but then the file turned out to be identical
to what it was before, so that nobody *else* who depended on it ended up
getting rebuilt.  So the results were indeterminate.

Now we treat it as if its dirtiness is unknown, so we build it using
redo-oob before building any of its dependencies.
2010-12-11 05:54:39 -08:00
Avery Pennarun
f702417ef3 The second half of redo-stamp: out-of-order building.
If a depends on b depends on c, and c is dirty but b uses redo-stamp
checksums, then 'redo-ifchange a' is indeterminate: we won't know if we need
to run a.do unless we first build b, but the script that *normally* runs
'redo-ifchange b' is a.do, and we don't want to run that yet, because we
don't know for sure if b is dirty, and we shouldn't build a unless one of
its dependencies is dirty.  Eek!

Luckily, there's a safe solution.  If we *know* a is dirty - eg. because
a.do or one of its children has definitely changed - then we can just run
a.do immediately and there's no problem, even if b is indeterminate, because
we were going to run a.do anyhow.

If a's dependencies are *not* definitely dirty, and all we have is
indeterminate ones like b, then that means a's build process *hasn't
changed*, which means its tree of dependencies still includes b, which means
we can deduce that if we *did* run a.do, it would end up running b.do.

Since we know that anyhow, we can safely just run b.do, which will either
b.set_checked() or b.set_changed().  Once that's done, we can re-parse a's
dependencies and this time conclusively tell if it needs to be redone or
not.  Even if it does, b is already up-to-date, so the 'redo-ifchange b'
line in a.do will be fast.

...now take all the above and do it recursively to handle nested
dependencies, etc, and you're done.
2010-12-11 05:54:39 -08:00