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.
This commit is contained in:
Avery Pennarun 2010-11-24 02:48:27 -08:00
commit 984ad747f8
13 changed files with 38 additions and 41 deletions

View file

@ -176,9 +176,6 @@ def main(targets, shouldbuildfunc):
for i in range(len(targets)): for i in range(len(targets)):
t = targets[i] t = targets[i]
if os.path.exists('%s/all.do' % t):
# t is a directory, but it has a default target
targets[i] = '%s/all' % t
# In the first cycle, we just build as much as we can without worrying # In the first cycle, we just build as much as we can without worrying
# about any lock contention. If someone else has it locked, we move on. # about any lock contention. If someone else has it locked, we move on.

View file

@ -73,9 +73,6 @@ _do()
redo() redo()
{ {
for i in "$@"; do for i in "$@"; do
if [ -e "$i/." ]; then
i="$i/all"
fi
_dirsplit "$i" _dirsplit "$i"
( cd "$dir" && _do "$dir" "$base" ) || exit $? ( cd "$dir" && _do "$dir" "$base" ) || exit $?
done done

View file

@ -5,8 +5,13 @@ from helpers import debug, err, mkdirp, unlink
def dirty_deps(t, depth): def dirty_deps(t, depth):
if os.path.exists('%s/.' % t): try:
t = '%s/all' % t st = os.stat(t)
realtime = st.st_mtime
except OSError:
st = None
realtime = 0
debug('%s?%s\n' % (depth, t)) debug('%s?%s\n' % (depth, t))
if state.isbuilt(t): if state.isbuilt(t):
debug('%s-- DIRTY (built)\n' % depth) debug('%s-- DIRTY (built)\n' % depth)
@ -20,11 +25,6 @@ def dirty_deps(t, depth):
debug('%s-- DIRTY (no stamp)\n' % depth) debug('%s-- DIRTY (no stamp)\n' % depth)
return True return True
try:
realtime = os.stat(t).st_mtime
except OSError:
realtime = 0
if stamptime != realtime: if stamptime != realtime:
debug('%s-- DIRTY (mtime)\n' % depth) debug('%s-- DIRTY (mtime)\n' % depth)
return True return True

2
t/.gitignore vendored
View file

@ -8,3 +8,5 @@ test.args
test2.args test2.args
/passfail /passfail
mode1 mode1
makedir
makedir.log

View file

@ -1 +1,2 @@
redo-ifchange hello yellow bellow c d example/ redo-ifchange hello yellow bellow c d example/all

View file

@ -1,4 +1,4 @@
redo example/clean curse/clean deps/clean "space dir/clean" redo example/clean curse/clean deps/clean "space dir/clean"
rm -f c c.c c.c.c c.c.c.b c.c.c.b.b d mode1 rm -f c c.c c.c.c c.c.c.b c.c.c.b.b d mode1 makedir.log
rm -f hello [by]ellow *.o *~ .*~ CC LD passfail rm -f hello [by]ellow *.o *~ .*~ CC LD passfail
rm -rf makedir rm -rf makedir

View file

@ -1,2 +1,2 @@
redo-ifchange dir1/ redo-ifchange dir1/all
echo $$ >>log echo $$ >>log

View file

@ -1,2 +0,0 @@
redo-ifchange dir1
echo $$ >>log

View file

@ -1,2 +0,0 @@
redo-ifchange dir1/all
echo $$ >>log

View file

@ -1,19 +1,15 @@
touch t?.do rm -f log dir1/log dir1/stinky
for first in t1 t2 t3; do touch t1.do
for second in t1 t2 t3; do . ../../flush-cache.sh
rm -f log dir1/log dir1/stinky redo t1
. ../../flush-cache.sh touch t1.do
redo $first . ../../flush-cache.sh
touch $second.do redo t1
. ../../flush-cache.sh . ../../flush-cache.sh
redo $second redo-ifchange t1
. ../../flush-cache.sh C1="$(wc -l <dir1/log)"
redo-ifchange $second C2="$(wc -l <log)"
C1="$(wc -l <dir1/log)" if [ "$C1" != 1 -o "$C2" != 2 ]; then
C2="$(wc -l <log)" echo "failed: t1>t1, c1=$C1, c2=$C2" >&2
if [ "$C1" != 1 -o "$C2" != 2 ]; then
echo "failed: $first>$second, c1=$C1, c2=$C2" >&2
exit 55 exit 55
fi fi
done
done

View file

@ -1,2 +1,3 @@
[ -e "$1" ] && rmdir $1 rm -rf "$1"
mkdir $1 mkdir $1
echo $$ >>makedir.log

7
t/makedir2.do Normal file
View file

@ -0,0 +1,7 @@
rm -f makedir.log
redo makedir
touch makedir/outfile
. ./flush-cache.sh
redo-ifchange makedir
COUNT=$(wc -l <makedir.log)
[ "$COUNT" = 1 ] || exit 99

View file

@ -1,4 +1,4 @@
redo-ifchange all redo-ifchange all
./hello >&2 ./hello >&2
redo deltest deltest2 test.args test2.args passfailtest \ redo deltest deltest2 test.args test2.args passfailtest \
curse/test deps/test "space dir/test" modetest makedir curse/test deps/test "space dir/test" modetest makedir2