Hi, I am trying to add support for config.def.h and config.h files to my
project, which uses apenwarr/redo. The functionality needed is:
- By default, only config.def.h is included in the project's repository.
- config.h is initially generated from config.def.h, for example:
#------------config.h.do------------
cat config.def.h >$3
#------------config.h.do------------
- User should be able to modify config.h.
The issue is that once the user modifies config.h, its dependants are always
regenerated, and redo issues the message (for example, if util.c depends on
config.h by including it - see
default.o.do):
redo (util.o)
redo: config.h - you modified it; skipping
redo util.o
redo: config.h - you modified it; skipping
Is there a way to record the state of the user-modified config.h file, so that
the next time redo is called (without any further source code modifications),
no .o files are regenerated? I have:
#------------default.o.do------------
sed -n '/^#include "/s/^#include "\([^"]*\)"/\1/p' ${2%.o}.c | \
xargs redo-ifchange
redo-ifchange $2.c
gcc -g -Wall -std=c99 -c $2.c -o $3
#------------default.o.do------------
#------------default.do------------
if [ -r $
1.in ]; then
redo-ifchange $
1.in version date
read VERSION <version
read DATE <date
sed -e "s/%VERSION%/$VERSION/g" \
-e "s/%DATE%/$DATE/g" <$
1.in >$3
else
printf "%s: don't know how to build '%s'\n" "$0" "$1" >&2
exit 99
fi
#------------default.do------------
#------------date.do------------
FALLBACKDATE=${FALLBACKDATE:-unknown}
user=$(stat -c %U .)
e_user=$(id -un)
if command -v git >/dev/null 2>&1; then
if [ "$e_user" = "$user" ]; then
env LC_ALL=C git log --format=format:%cd \
--date=format:"%d %b %Y" -1 @ >$3
else
su "${user}" -c 'env LC_ALL=C git log --format=format:%cd '\
'--date=format:"%d %b %Y" -1 @' >$3
fi
echo >>$3
else
echo $FALLBACKDATE >$3
fi
redo-always
redo-stamp <$3
#------------date.do------------
#------------version.do------------
FALLBACKVER=${FALLBACKVER:-unknown}
user=$(stat -c %U .)
e_user=$(id -un)
if command -v git >/dev/null 2>&1; then
if [ "$e_user" = "$user" ]; then
git describe 2>/dev/null | sed 's/^v//' >$3
else
su "${user}" -c 'git describe' 2>/dev/null | sed 's/^v//' >$3
fi
else
echo $FALLBACKVER >$3
fi
redo-always
redo-stamp <$3
#------------all.do------------
#------------all.do------------
redo-ifchange my_prog
#------------all.do------------
#------------my_prog.do------------
redo-ifchange my_prog.o util.o
gcc -g -Wall -std=c99 -o $3 my_prog.o util.o >/dev/null
#------------my_prog.do------------
Thanks in advance,
Strahinya