tup
tup copied to clipboard
modified generated file is not deleted when the associated rule is removed
Hi, this script reproduces the issue:
#!/bin/bash -ve
TMPDIR=$(mktemp -d)
cd ${TMPDIR}
tup --version
tup init
cat << EOF > Tupfile
: |> echo '#define number 7' > %o |> a.h
: a.c | a.h |> cc -o %o %f |> a
EOF
cat << EOF > a.c
#include "a.h"
int main() { return number; }
EOF
> release
tup variant release
tup
sed -i 1d Tupfile
cp build-release/a.h a.h
sleep 1
> build-release/a.h
tup || true
cd -
rm -rf ${TMPDIR}
The result is:
#!/bin/bash -ve
TMPDIR=$(mktemp -d)
cd ${TMPDIR}
tup --version
tup v0.7.7
tup init
.tup repository initialized.
cat << EOF > Tupfile
: |> echo '#define number 7' > %o |> a.h
: a.c | a.h |> cc -o %o %f |> a
EOF
cat << EOF > a.c
#include "a.h"
int main() { return number; }
EOF
> release
tup variant release
tup: Added variant 'build-release' using config file 'release'
tup
[ tup ] [0.000s] Scanning filesystem...
[ tup ] [0.005s] Reading in new configuration/environment variables...
1) new variant: build-release/tup.config
[ ] 100%
[ tup ] [0.009s] Parsing Tupfiles...
1) [0.002s] build-release
[ ] 100%
[ tup ] [0.012s] No files to delete.
[ tup ] [0.012s] Generating .gitignore files...
[ tup ] [0.013s] Executing Commands...
1) [0.027s] build-release: echo '#define number 7' > a.h
2) [0.183s] build-release: cc -o a a.c
[ ] 100%
[ tup ] [0.225s] Updated.
sed -i 1d Tupfile
cp build-release/a.h a.h
sleep 1
> build-release/a.h
tup || true
[ tup ] [0.000s] Scanning filesystem...
tup warning: generated file 'build-release/a.h' was modified outside of tup. This file will be overwritten on the next update, unless the rule that creates it is also removed.
[ tup ] [0.002s] Reading in new environment variables...
[ tup ] [0.002s] Parsing Tupfiles...
1) [0.001s] build-release
[ ] 100%
[ tup ] [0.008s] Deleting files...
[ tup ] [0.008s] Deleting 1 command...
[ ] 100%
[ tup ] [0.009s] Converting generated files to normal files...
1) generated -> normal: build-release/a.h
[ ] 100%
[ tup ] [0.010s] Generating .gitignore files...
[ tup ] [0.010s] Executing Commands...
* 1) build-release: cc -o a a.c
a.c: In function 'main':
a.c:2:21: error: 'number' undeclared (first use in this function)
int main() { return number; }
^~~~~~
a.c:2:21: note: each undeclared identifier is reported only once for each function it appears in
*** tup errors ***
*** Command ID=14 failed with return value 1
[ ] 100%
*** tup: 1 job failed.
cd -
/tmp
rm -rf ${TMPDIR}
Please, note the sleep command! If the time is reduced or the sleep command removed then the reproducibility is random. The highest the wait time, higher the probability to reproduce.
Regards, Vicenç.