Add minimal/do, a stripped-down redo implementation in 977 bytes of sh.
This could be good for distributing with your packages, so that people who don't have redo installed can at least build it. Also, we could use it for building redo itself. Will surely need to get slightly bigger as I inevitably discover I've forgotten a critical feature.
This commit is contained in:
parent
3803da525c
commit
4243f31e1b
9 changed files with 60 additions and 8 deletions
1
clean.do
1
clean.do
|
|
@ -1,3 +1,2 @@
|
|||
rm -f t/hello t/[by]ellow t/*.o *~ .*~ t/*~ t/.*~ *.pyc t/CC t/LD
|
||||
rm -rf .redo t/.redo
|
||||
|
||||
|
|
|
|||
54
minimal/do
Executable file
54
minimal/do
Executable file
|
|
@ -0,0 +1,54 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# A minimal alternative to djb redo that doesn't support incremental builds.
|
||||
# For the full version, visit http://github.com/apenwarr/redo
|
||||
#
|
||||
export REDO="$(dirname "$0")/$(basename "$0")"
|
||||
IFS="
|
||||
"
|
||||
|
||||
if [ -z "$DO_BUILT" ]; then
|
||||
export DO_BUILT="$PWD/.do_built"
|
||||
if [ -e "$DO_BUILT" ]; then
|
||||
echo "Removing previously built files..." >&2
|
||||
sort "$DO_BUILT" | uniq | tee "$DO_BUILT.new" | xargs rm -f
|
||||
mv "$DO_BUILT.new" "$DO_BUILT"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
_do()
|
||||
{
|
||||
TARGET="$1"
|
||||
DOFILE="$1.do"
|
||||
if [ ! -e "$TARGET" ]; then
|
||||
printf '\033[32mdo \033[1m%s\033[m\n' "$PWD/$TARGET" >&2
|
||||
echo "$PWD/$TARGET" >>"$DO_BUILT"
|
||||
set "$TARGET" FIXME "$TARGET.tmp"
|
||||
( . "$PWD/$DOFILE" >"$TARGET.tmp" ) &&
|
||||
mv "$TARGET.tmp" "$TARGET"
|
||||
else
|
||||
echo "$1 exists." >&2
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
redo()
|
||||
{
|
||||
for i in "$@"; do
|
||||
D="$(dirname "$i")"
|
||||
B="$(basename "$i")"
|
||||
( cd "$D" && _do "$B" )
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
alias redo-ifchange="redo"
|
||||
alias redo-ifcreate=":"
|
||||
set -e
|
||||
|
||||
if [ -n "$*" ]; then
|
||||
redo "$@"
|
||||
else
|
||||
redo all
|
||||
fi
|
||||
1
redo.py
1
redo.py
|
|
@ -30,6 +30,7 @@ if not os.environ.get('REDO_BASE', ''):
|
|||
break
|
||||
os.environ['REDO_BASE'] = base
|
||||
os.environ['REDO_STARTDIR'] = os.getcwd()
|
||||
os.environ['REDO'] = os.path.abspath(sys.argv[0])
|
||||
|
||||
# FIXME: just wiping out all the locks is kind of cheating. But we
|
||||
# only do this from the toplevel redo process, so unless the user
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
. wvtest.sh
|
||||
. ./wvtest.sh
|
||||
|
||||
redo t/all
|
||||
WVSTART "t/runtests"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
redo-ifchange LD yellow.o
|
||||
./LD bellow yellow.o
|
||||
./LD "$3" yellow.o
|
||||
./sleep 2
|
||||
|
|
|
|||
0
t/hello.c
Normal file → Executable file
0
t/hello.c
Normal file → Executable file
|
|
@ -1,3 +1,3 @@
|
|||
redo-ifchange LD hello.o
|
||||
./sleep 1
|
||||
./LD hello hello.o
|
||||
./LD "$3" hello.o
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
redo-ifchange LD yellow.o
|
||||
./sleep 1.5
|
||||
./LD yellow yellow.o
|
||||
./LD "$3" yellow.o
|
||||
|
|
|
|||
4
test.do
4
test.do
|
|
@ -1,4 +1,2 @@
|
|||
redo-ifchange t/all
|
||||
wvtestrun redo runtests >&2
|
||||
|
||||
|
||||
./wvtestrun "$REDO" runtests >&2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue