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 19:32:42 +0100 Message-ID: References: <5701.1321644756@alphaville.americas.hpqcorp.net> <5462.1321675205@alphaville.dokosmarshall.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=bcaec5016389dfdaaf04b21aad2e Return-path: Received: from eggs.gnu.org ([140.186.70.92]:55359) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RRpiX-0000R9-Jh for emacs-orgmode@gnu.org; Sat, 19 Nov 2011 13:32:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RRpiW-00085e-3s for emacs-orgmode@gnu.org; Sat, 19 Nov 2011 13:32:45 -0500 Received: from mail-vx0-f169.google.com ([209.85.220.169]:61766) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RRpiW-00085V-0K for emacs-orgmode@gnu.org; Sat, 19 Nov 2011 13:32:44 -0500 Received: by vcbfo1 with SMTP id fo1so3918094vcb.0 for ; Sat, 19 Nov 2011 10:32:42 -0800 (PST) In-Reply-To: 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: emacs-orgmode@gnu.org --bcaec5016389dfdaaf04b21aad2e Content-Type: text/plain; charset=ISO-8859-1 Hi everyone, I wanted to thank everyone for their helpful suggestions and wanted to share the best solutions I heard of and found. One solution is to include a rule in the makefile for every sourcecode file that that copies it and only updates the copy if something has changed (see Nick's email below). Another one is the use of a non-standard make program like makepp, that allows for using md5 checksums for files instead of timestamp in order to derive which files have to be rebuild. Thanks again! Holger On Sat, Nov 19, 2011 at 7:58 AM, Holger Hoefling wrote: > 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 >> >> >> > --bcaec5016389dfdaaf04b21aad2e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi everyone,

I wanted to thank everyone for their helpful suggestion= s and wanted to share the best solutions I heard of and found.

One s= olution is to include a rule in the makefile for every sourcecode file that= that copies it and only updates the copy if something has changed (see Nic= k's email below).

Another one is the use of a non-standard make program like makepp, that= allows for using md5 checksums for files instead of timestamp in order to = derive which files have to be rebuild.

Thanks again!

Holger
On Sat, Nov 19, 2011 at 7:58 AM, Holger Hoef= ling <hhoeflin@g= mail.com> wrote:
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




--bcaec5016389dfdaaf04b21aad2e--