From mboxrd@z Thu Jan 1 00:00:00 1970 From: Holger Hoefling Subject: Re: Not overwriting unchanged source code files when tangling Date: Sat, 19 Nov 2011 07:58:24 +0100 Message-ID: References: <5701.1321644756@alphaville.americas.hpqcorp.net> <5462.1321675205@alphaville.dokosmarshall.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=bcaec54fbd56dc898204b210fabc Return-path: Received: from eggs.gnu.org ([140.186.70.92]:41493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RRese-0005O5-5G for emacs-orgmode@gnu.org; Sat, 19 Nov 2011 01:58:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RResc-0003El-PS for emacs-orgmode@gnu.org; Sat, 19 Nov 2011 01:58:28 -0500 Received: from mail-vx0-f169.google.com ([209.85.220.169]:47154) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RResc-0003Eg-Kk for emacs-orgmode@gnu.org; Sat, 19 Nov 2011 01:58:26 -0500 Received: by vcbfo1 with SMTP id fo1so3534789vcb.0 for ; Fri, 18 Nov 2011 22:58:26 -0800 (PST) In-Reply-To: <5462.1321675205@alphaville.dokosmarshall.org> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: nicholas.dokos@hp.com Cc: emacs-orgmode@gnu.org, Carsten Dominik --bcaec54fbd56dc898204b210fabc Content-Type: text/plain; charset=ISO-8859-1 Hey Nick, thank you very much. That sounds like a very good solution to my problem that does not require changes to org-mode. Best Holger On Sat, Nov 19, 2011 at 5:00 AM, Nick Dokos wrote: > Holger Hoefling 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 > > > --bcaec54fbd56dc898204b210fabc Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hey Nick,

thank you very much. That sounds like a very good solution= to my problem that does not require changes to org-mode.

Best
Holger

On Sat, Nov 19, 2011 at 5:00 AM= , Nick Dokos <nicholas.dokos@hp.com> wrote:
Holger Hoefling <hhoeflin@gmail.com> wrote:

> I think you misunderstood me there - I am actually not worried about h= ow
> computationally intensive the tangling process is. This always works v= ery
> quickly, so even if they have to be copied around and take a bit longe= r, I
> would not mind.
>

Ah, ok - so you are talking about

=A0 =A0 =A0 tangle =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0compile
=A0 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 fi= le.


IMO, the best way to deal with it is still make: let's say

=A0 =A0 foo.org =A0----&g= t; 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
=A0 =A0 =A0 =A0 X a.x b.c c.x -o foo.out

a.x b.x c.x: foo.org
=A0 =A0 =A0 =A0 tangle foo.or= g

--8<---------------cut here---------------end--------------->8---


Rewrite the make file as follows:


--8<---------------cut here---------------start------------->8---
foo.out: a.y b.y c.y
=A0 =A0 X a.y b.y c.y -o foo.out

a.y: a.x
=A0 =A0 cmp --silent a.x a.y || cp a.x a.y

b.y: b.x
=A0 =A0 cmp --silent b.x b.y || cp b.x b.y

c.y: c.x
=A0 =A0 cmp --silent c.x c.y || cp c.x c.y

a.x b.x c.x: foo.org
=A0 =A0 tangle foo.org --8<---------------cut here---------------end--------------->8---


So if the *contents* of (say) a.x have not changed by the tangling, it comp= ares
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. =A0That 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
=A0 =A0 X a.y b.y c.y -o foo.out

%.y: %.x
=A0 =A0 -cmp --silent $< $@ || cp $< $@

a.x b.x c.x: foo.org
=A0 =A0 tangle foo.org --8<---------------cut here---------------end--------------->8---

HTH,
Nick



--bcaec54fbd56dc898204b210fabc--