<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7650.28">
<TITLE>RE: [Cook] Enumerating leaf directories</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<BR>
<BR>
<BR>
<P><FONT SIZE=2>-----Original Message-----<BR>
From: Reuben Thomas [<A HREF="mailto:rrt@sc3d.org">mailto:rrt@sc3d.org</A>]<BR>
Sent: Sat 03-Mar-07 11:00<BR>
To: Pendergraft, Jerry<BR>
Cc: Cook users list<BR>
Subject: RE: [Cook] Enumerating leaf directories<BR>
<BR>
On Fri, 2 Mar 2007, Pendergraft, Jerry wrote:<BR>
> > Normally within a cook file you have some kind of list of "project" files - a manifest as it were.<BR>
<BR>
>Right, this is the sort of philosophical correction I wanted. I was starting<BR>
>from the products, whereas with cook I should start, it seems, from the<BR>
>ingredients.<BR>
right - all flows from the ingredients. You define what you want to generate, and provide recipes that know how to do so.<BR>
<BR>
> > project_files = [collect find . -type f -name [quote '*.html'] -print | sed -e [quote 's:^\./'::']];<BR>
<BR>
> This is a good start, but what about spaces in file names? Surely I should<BR>
> be using "-print0"? Also, the sed bit at the end is better done by find:<BR>
Possibly - but always a good idea to *not* have file names with spaces ;^)<BR>
<BR>
>1. This doesn't yet deal properly with spaces or other odd characters in<BR>
>filenames. I can't find anything in the Cook documentation about using<BR>
>NUL-terminated strings, so the best I can do for now is:<BR>
<BR>
>project_files = [collect_lines find . -type f -name [quote '*.html'] -printf \"%P\\n\"'];<BR>
right - collect lines will do one per line. Within cook all are NUL terminated, not the same as NL terminated.<BR>
<BR>
> 2. I use subversion, so I have to prune the subversion directories from the<BR>
surely subversion, and any other sane system provides a way to list the files it controls? The you just define that command ala for aegis:<BR>
project_list_command = aelpf;<BR>
<BR>
> One final thing: the whole point of my using cook was to use it to build<BR>
>HTML files from non-HTML files, so I should remove the "-name" predicate<BR>
> above, leaving:<BR>
<BR>
>project_files = [collect_lines find . -type f -printf \"%P\\n\"'];<BR>
Again - use your control system to list the files.<BR>
<BR>
>> So now the leaf directories you seek are given by:<BR>
>> leaf_directories = [stringset [dirname [project_files]]];<BR>
<BR>
>I'm not convinced by this: it looks as though it'll simply give me a list of<BR>
>directories in the project (i.e. a list of every directory containing<BR>
>files), which is not the same as a list of leaf directories. I'm pretty sure<BR>
>I need a list of leaf directories, because they determine what I build<BR>
>(there's one web page in the output per leaf directory in the source).<BR>
<BR>
Not sure I follow here - don't understand how an empty directory serves as a source?<BR>
Don't you define what you build? That is by mapping source files to build product files?<BR>
If you mean something like building index.html in each product directory you can do something like:<BR>
indexes = [prepost product/ /index.html [leaf_directories]] ;<BR>
<BR>
/* the %0% is the path under product matching the path to your sources */<BR>
/* this will build a new index if any files in the matching source directory change */<BR>
product/%0%/index.html : [match_mask %0%/%%1 [project_files]]<BR>
{<BR>
build_index -o [target] [match_mask %0%/%%1 [project_files]];<BR>
}<BR>
<BR>
<BR>
>Thanks for your patience, Jerry; as you can see, I'm in culture<BR>
>shock...anyway, it looks like once I've sorted out these two things (list of<BR>
>files, list of targets) I'll be good to try sorting out the dependencies.<BR>
No problem.<BR>
<BR>
--<BR>
<A HREF="http://rrt.sc3d.org/">http://rrt.sc3d.org/</A> | Brevity is the soul<BR>
<BR>
<BR>
Jerry Pendergraft voice:651-523-6935<BR>
St.Jude Medical mobil:651-491-0163<BR>
Atrial Fibrillation Division email:jpendergraft@sjm.com<BR>
1350 Energy Lane<BR>
St.Paul, MN 55108<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
</FONT>
</P>
</BODY>
</HTML>