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.)
This commit is contained in:
parent
41ef15fde2
commit
fb5275938d
2 changed files with 16 additions and 6 deletions
2
clean.do
2
clean.do
|
|
@ -1,3 +1,4 @@
|
||||||
|
rm -rf t/.redo redo-sh
|
||||||
if [ -e .do_built ]; then
|
if [ -e .do_built ]; then
|
||||||
while read x; do
|
while read x; do
|
||||||
rm -f "$x"
|
rm -f "$x"
|
||||||
|
|
@ -6,5 +7,4 @@ fi
|
||||||
[ -z "$DO_BUILT" ] && rm -rf .do_built .do_built.dir
|
[ -z "$DO_BUILT" ] && rm -rf .do_built .do_built.dir
|
||||||
redo t/clean Documentation/clean
|
redo t/clean Documentation/clean
|
||||||
rm -f *~ .*~ */*~ */.*~ *.pyc install.wrapper
|
rm -f *~ .*~ */*~ */.*~ *.pyc install.wrapper
|
||||||
rm -rf t/.redo redo-sh
|
|
||||||
find . -name '*.tmp' -exec rm -fv {} \;
|
find . -name '*.tmp' -exec rm -fv {} \;
|
||||||
|
|
|
||||||
20
minimal/do
20
minimal/do
|
|
@ -15,12 +15,14 @@ _dirsplit()
|
||||||
_dirsplit "$0"
|
_dirsplit "$0"
|
||||||
export REDO=$(cd "${dir:-.}" && echo "$PWD/$base")
|
export REDO=$(cd "${dir:-.}" && echo "$PWD/$base")
|
||||||
|
|
||||||
|
DO_TOP=
|
||||||
if [ -z "$DO_BUILT" ]; then
|
if [ -z "$DO_BUILT" ]; then
|
||||||
|
DO_TOP=1
|
||||||
export DO_BUILT=$PWD/.do_built
|
export DO_BUILT=$PWD/.do_built
|
||||||
if [ -e "$DO_BUILT" ]; then
|
if [ -e "$DO_BUILT" ]; then
|
||||||
echo "Removing previously built files..." >&2
|
echo "Removing previously built files..." >&2
|
||||||
sort -u "$DO_BUILT" | tee "$DO_BUILT.new" |
|
sort -u "$DO_BUILT" | tee "$DO_BUILT.new" |
|
||||||
while read f; do rm -f "$f" 2>/dev/null; done
|
while read f; do rm -f "$f" "$f.did" 2>/dev/null; done
|
||||||
mv "$DO_BUILT.new" "$DO_BUILT"
|
mv "$DO_BUILT.new" "$DO_BUILT"
|
||||||
fi
|
fi
|
||||||
DO_PATH=$DO_BUILT.dir
|
DO_PATH=$DO_BUILT.dir
|
||||||
|
|
@ -55,7 +57,7 @@ _run_dofile()
|
||||||
export DO_DEPTH="$DO_DEPTH "
|
export DO_DEPTH="$DO_DEPTH "
|
||||||
export REDO_TARGET=$PWD/$TARGET
|
export REDO_TARGET=$PWD/$TARGET
|
||||||
set -e
|
set -e
|
||||||
. "$PWD/$DOFILE" >"$TARGET.tmp"
|
. "$PWD/$DOFILE" >"$TARGET.tmp2"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -63,7 +65,7 @@ _do()
|
||||||
{
|
{
|
||||||
DIR=$1
|
DIR=$1
|
||||||
TARGET=$2
|
TARGET=$2
|
||||||
if [ ! -e "$TARGET" ]; then
|
if [ ! -e "$TARGET" ] || [ -e "$TARGET/." -a ! -e "$TARGET.did" ]; then
|
||||||
printf '\033[32mdo %s\033[1m%s\033[m\n' \
|
printf '\033[32mdo %s\033[1m%s\033[m\n' \
|
||||||
"$DO_DEPTH" "$DIR$TARGET" >&2
|
"$DO_DEPTH" "$DIR$TARGET" >&2
|
||||||
echo "$PWD/$TARGET" >>"$DO_BUILT"
|
echo "$PWD/$TARGET" >>"$DO_BUILT"
|
||||||
|
|
@ -75,6 +77,7 @@ _do()
|
||||||
echo "do: $TARGET: no .do file" >&2
|
echo "do: $TARGET: no .do file" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
: >>"$TARGET.did"
|
||||||
( _run_dofile "$BASE" "$EXT" "$TARGET.tmp" )
|
( _run_dofile "$BASE" "$EXT" "$TARGET.tmp" )
|
||||||
RV=$?
|
RV=$?
|
||||||
if [ $RV != 0 ]; then
|
if [ $RV != 0 ]; then
|
||||||
|
|
@ -82,8 +85,10 @@ _do()
|
||||||
"$DIR$TARGET: got exit code $RV" >&2
|
"$DIR$TARGET: got exit code $RV" >&2
|
||||||
return $RV
|
return $RV
|
||||||
fi
|
fi
|
||||||
mv "$TARGET.tmp" "$TARGET" 2>/dev/null
|
mv "$TARGET.tmp" "$TARGET" 2>/dev/null ||
|
||||||
: >>"$TARGET"
|
! test -s "$TARGET.tmp2" ||
|
||||||
|
mv "$TARGET.tmp2" "$TARGET" 2>/dev/null
|
||||||
|
rm -f "$TARGET.tmp2"
|
||||||
else
|
else
|
||||||
echo "do $DO_DEPTH$TARGET exists." >&2
|
echo "do $DO_DEPTH$TARGET exists." >&2
|
||||||
fi
|
fi
|
||||||
|
|
@ -105,3 +110,8 @@ if [ -n "$*" ]; then
|
||||||
else
|
else
|
||||||
redo all
|
redo all
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "$DO_TOP" ]; then
|
||||||
|
echo "Removing stamp files..." >&2
|
||||||
|
while read f; do rm -f "$f.did" 2>/dev/null; done <"$DO_BUILT"
|
||||||
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue