Previously _version.py was a phony target because we couldn't easily
tell when the current git working tree version had changed. This caused
various targets to be rebuilt multiple times (i.e. recursive make
invocations, etc.).
To fix that, just update _version.py once (at startup) if needed, via an
immediate variable assignment that calls a new ./configure-version
command, i.e.
initial_setup := $(shell ./configure-version --update)
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
test_tmp := $(CURDIR)/t/tmp
endif
test_tmp := $(CURDIR)/t/tmp
endif
+initial_setup := $(shell ./configure-version --update)
bup_deps := bup lib/bup/_version.py lib/bup/_helpers$(SOEXT) cmds
all: $(bup_deps) Documentation/all $(current_sampledata)
bup_deps := bup lib/bup/_version.py lib/bup/_helpers$(SOEXT) cmds
all: $(bup_deps) Documentation/all $(current_sampledata)
LDFLAGS="$(LDFLAGS)" CFLAGS="$(CFLAGS)" $(PYTHON) csetup.py build
cp lib/bup/build/*/_helpers$(SOEXT) lib/bup/
LDFLAGS="$(LDFLAGS)" CFLAGS="$(CFLAGS)" $(PYTHON) csetup.py build
cp lib/bup/build/*/_helpers$(SOEXT) lib/bup/
-# This must be completely atomic since it may be run (often) in
-# parallel when "-j" is specified, either via targets here, or via
-# tests that use an install tree as data.
-.PHONY: lib/bup/_version.py
- rm -f $@.tmp-$$$$ \
- && ./format-subst.pl $@.pre > $@.tmp-$$$$ \
- && (if ! test -e $@ || ! cmp $@ $@.tmp-$$$$; then mv $@.tmp-$$$$ $@; fi) \
- && rm -f $@.tmp-$$$$
+ @echo "Something has gone wrong; $@ should already exist."
+ @echo 'Check "./configure-version --update"'
+ @false
.*~ *~ */*~ lib/*/*~ lib/*/*/*~ \
*.pyc */*.pyc lib/*/*.pyc lib/*/*/*.pyc \
bup bup-* cmd/bup-* \
.*~ *~ */*~ lib/*/*~ lib/*/*/*~ \
*.pyc */*.pyc lib/*/*.pyc lib/*/*/*.pyc \
bup bup-* cmd/bup-* \
- lib/bup/_version.py lib/bup/_version.py.tmp-* \
randomgen memtest \
testfs.img lib/bup/t/testfs.img
if test -e t/mnt; then t/cleanup-mounts-under t/mnt; fi
randomgen memtest \
testfs.img lib/bup/t/testfs.img
if test -e t/mnt; then t/cleanup-mounts-under t/mnt; fi
then umount lib/bup/t/testfs || true; fi
rm -rf *.tmp *.tmp.meta t/*.tmp lib/*/*/*.tmp build lib/bup/build lib/bup/t/testfs
if test -e t/tmp; then t/force-delete t/tmp; fi
then umount lib/bup/t/testfs || true; fi
rm -rf *.tmp *.tmp.meta t/*.tmp lib/*/*/*.tmp build lib/bup/build lib/bup/t/testfs
if test -e t/tmp; then t/force-delete t/tmp; fi
+ ./configure-version --clean
t/configure-sampledata --clean
t/configure-sampledata --clean
--- /dev/null
+#!/usr/bin/env bash
+
+set -eo pipefail
+
+top="$(pwd)"
+vpy=lib/bup/_version.py
+readonly top vpy
+
+usage()
+{
+ echo 'Usage: ./configure-version [--update | --clean]'
+}
+
+if test "$#" -ne 1; then
+ usage 1>&2; exit 1
+fi
+
+case "$1" in
+ --update)
+ rm -f $vpy.tmp-$$
+ ./format-subst.pl $vpy.pre > $vpy.tmp-$$
+ if ! test -e $vpy || ! cmp -s $vpy $vpy.tmp-$$; then
+ mv $vpy.tmp-$$ $vpy;
+ fi
+ rm -f $vpy.tmp-$$
+ ;;
+ --clean)
+ rm -f lib/bup/_version.py lib/bup/_version.pyc lib/bup/_version.py.tmp-*
+ ;;
+ *)
+ usage 1>&2; exit 1
+ ;;
+esac