[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Not overwriting unchanged source code files when tangling
From: |
Nick Dokos |
Subject: |
Re: [O] Not overwriting unchanged source code files when tangling |
Date: |
Fri, 18 Nov 2011 23:00:05 -0500 |
Holger Hoefling <address@hidden> wrote:
> I think you misunderstood me there - I am actually not worried about how
> computationally intensive the tangling process is. This always works very
> quickly, so even if they have to be copied around and take a bit longer, I
> would not mind.
>
Ah, ok - so you are talking about
tangle compile
org -------> bunch of files -------------> output
The tangling step produces a bunch of files that are (re)compiled (or in
any case require some sort of lengthy processing) to produce some output file.
IMO, the best way to deal with it is still make: let's say
foo.org ----> a.x b.x c.x ------> foo.out
where the first arrow is the tangle and the second arrow is some processor,
call it X.
The standard way to set up a makefile is schematically:
--8<---------------cut here---------------start------------->8---
foo.out: a.x b.x c.x
X a.x b.c c.x -o foo.out
a.x b.x c.x: foo.org
tangle foo.org
--8<---------------cut here---------------end--------------->8---
Rewrite the make file as follows:
--8<---------------cut here---------------start------------->8---
foo.out: a.y b.y c.y
X a.y b.y c.y -o foo.out
a.y: a.x
cmp --silent a.x a.y || cp a.x a.y
b.y: b.x
cmp --silent b.x b.y || cp b.x b.y
c.y: c.x
cmp --silent c.x c.y || cp c.x c.y
a.x b.x c.x: foo.org
tangle foo.org
--8<---------------cut here---------------end--------------->8---
So if the *contents* of (say) a.x have not changed by the tangling, it compares
equal to a.y and the copy is skipped. That leaves a.y untouched.
OTOH, if the contents of a.x change (or a.y does not exist in the first
place), the comparison fails and we copy a.x to a.y. That updates a.y
and forces further updates on anything that depends on it.
Using some make fu (works for GNU make, but not necessarily for other makes),
you can write it more compactly:
--8<---------------cut here---------------start------------->8---
foo.out: a.y b.y c.y
X a.y b.y c.y -o foo.out
%.y: %.x
-cmp --silent $< $@ || cp $< $@
a.x b.x c.x: foo.org
tangle foo.org
--8<---------------cut here---------------end--------------->8---
HTH,
Nick
- Re: [O] Not overwriting unchanged source code files when tangling, (continued)
- Re: [O] Not overwriting unchanged source code files when tangling, Holger Hoefling, 2011/11/18
- Re: [O] Not overwriting unchanged source code files when tangling, Nick Dokos, 2011/11/18
- Re: [O] Not overwriting unchanged source code files when tangling, Holger Hoefling, 2011/11/18
- Re: [O] Not overwriting unchanged source code files when tangling,
Nick Dokos <=
- Re: [O] Not overwriting unchanged source code files when tangling, Holger Hoefling, 2011/11/19
- Re: [O] Not overwriting unchanged source code files when tangling, Holger Hoefling, 2011/11/19
- Re: [O] Not overwriting unchanged source code files when tangling, Allen S. Rout, 2011/11/22
- Re: [O] Not overwriting unchanged source code files when tangling, Nick Dokos, 2011/11/22
- Re: [O] Not overwriting unchanged source code files when tangling, cberry, 2011/11/19
Re: [O] Not overwriting unchanged source code files when tangling, Achim Gratz, 2011/11/18
Re: [O] Not overwriting unchanged source code files when tangling, Rustom Mody, 2011/11/19