From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Not overwriting unchanged source code files when tangling Date: Fri, 18 Nov 2011 23:00:05 -0500 Message-ID: <5462.1321675205@alphaville.dokosmarshall.org> References: <5701.1321644756@alphaville.americas.hpqcorp.net> Reply-To: nicholas.dokos@hp.com Return-path: Received: from eggs.gnu.org ([140.186.70.92]:36615) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RRc67-0002gV-6x for emacs-orgmode@gnu.org; Fri, 18 Nov 2011 23:00:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RRc66-0002H6-21 for emacs-orgmode@gnu.org; Fri, 18 Nov 2011 23:00:11 -0500 Received: from g4t0015.houston.hp.com ([15.201.24.18]:41700) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RRc65-0002F2-Kj for emacs-orgmode@gnu.org; Fri, 18 Nov 2011 23:00:09 -0500 In-Reply-To: Message from Holger Hoefling of "Sat, 19 Nov 2011 01:51:12 +0100." 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: Holger Hoefling Cc: nicholas.dokos@hp.com, emacs-orgmode@gnu.org, Carsten Dominik 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