From: Ian Jackson Date: Thu, 28 Feb 2019 01:25:54 +0000 (+0000) Subject: maybe-rerun-optim X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=31a46ce586ba6edb01f33d10380eb91eb777f4ee;p=pandemic-rising-tide.git maybe-rerun-optim --- diff --git a/Makefile b/Makefile index 5ce5779..d15de38 100644 --- a/Makefile +++ b/Makefile @@ -9,18 +9,16 @@ PLANAR_GRAPH=planar-graph map.plag: generate-plag input-graph Parse.pm ./$< input-graph $o -opt.plag: map.plag $(PLANAR_GRAPH) - sha256sum $^ >.opt.plag.sums.tmp - cmp .opt.plag.sums.tmp .opt.plag.sums || ( \ - $(PLANAR_GRAPH) RF $< \ +# create opt.plag.reuse to shortcut this +opt.plag: maybe-rerun-optim map.plag $(PLANAR_GRAPH) + ./$^ $@ .opt.plag.sums \ + R \ DUAL \ OUTER-F2V OUTER-SPLIT \ B T OUTER-F2V OUTER-F12VA \ PCO CP RAE \ - D 0 NLOPT \ + D 0 NLOPT \ W $@.tmp \ - && $i \ - && mv -vf .opt.plag.sums.tmp .opt.plag.sums ) #map.ps: map.dot # neato -Tps $^ $o diff --git a/maybe-rerun-optim b/maybe-rerun-optim new file mode 100755 index 0000000..23331e9 --- /dev/null +++ b/maybe-rerun-optim @@ -0,0 +1,26 @@ +#!/bin/bash +set -e +set -o posix +set -o pipefail + +input=$1 ; shift +planar_graph=$1 ; shift +dest=$1 ; shift +sums=$1 ; shift + +inst () { mv -vf $dest.tmp $dest; } + +if test -f $dest.reuse; then + cp -v $@.reuse $@.tmp + inst + exit 0 +fi + +sha256sum "$input" "$planar_graph" >$sums.tmp +for arg in "$@"; do printf >>$sums.tmp "%s\n" "$arg"; done + +if cmp $sums.tmp $sums; then + exit 0 +fi + +"$planar_graph" <$input "$@"