[Cook] Enumerating leaf directories

Pendergraft, Jerry JPendergraft at sjm.com
Sun Mar 4 07:22:07 EST 2007




-----Original Message-----
From: Reuben Thomas [mailto:rrt at sc3d.org]
Sent: Sat 03-Mar-07 11:00
To: Pendergraft, Jerry
Cc: Cook users list
Subject: RE: [Cook] Enumerating leaf directories
 
On Fri, 2 Mar 2007, Pendergraft, Jerry wrote:
> > Normally within a cook file you have some kind of list of "project" files - a manifest as it were.

>Right, this is the sort of philosophical correction I wanted. I was starting 
>from the products, whereas with cook I should start, it seems, from the 
>ingredients.
right - all flows from the ingredients. You define what you want to generate, and provide recipes that know how to do so.

> > project_files = [collect find . -type f -name [quote '*.html'] -print | sed -e [quote 's:^\./'::']];

> This is a good start, but what about spaces in file names? Surely I should 
> be using "-print0"? Also, the sed bit at the end is better done by find:
Possibly - but always a good idea to *not* have file names with spaces ;^)

>1. This doesn't yet deal properly with spaces or other odd characters in 
>filenames. I can't find anything in the Cook documentation about using 
>NUL-terminated strings, so the best I can do for now is:

>project_files = [collect_lines find . -type f -name [quote '*.html'] -printf \"%P\\n\"'];
right - collect lines will do one per line. Within cook all are NUL terminated, not the same as NL terminated.

> 2. I use subversion, so I have to prune the subversion directories from the 
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:
project_list_command = aelpf;

> One final thing: the whole point of my using cook was to use it to build 
>HTML files from non-HTML files, so I should remove the "-name" predicate 
> above, leaving:

>project_files = [collect_lines find . -type f -printf \"%P\\n\"'];
Again - use your control system to list the files.

>> So now the leaf directories you seek are given by:
>> leaf_directories = [stringset [dirname [project_files]]];

>I'm not convinced by this: it looks as though it'll simply give me a list of 
>directories in the project (i.e. a list of every directory containing 
>files), which is not the same as a list of leaf directories. I'm pretty sure 
>I need a list of leaf directories, because they determine what I build 
>(there's one web page in the output per leaf directory in the source).

Not sure I follow here - don't understand how an empty directory serves as a source?
Don't you define what you build? That is by mapping source files to build product files?
If you mean something like building index.html in each product directory you can do something like:
indexes = [prepost product/ /index.html [leaf_directories]] ;

 /* the %0% is the path under product matching the path to your sources */
 /* this will build a new index if any files in the matching source directory change */
product/%0%/index.html : [match_mask %0%/%%1 [project_files]]
{
   build_index -o [target] [match_mask %0%/%%1 [project_files]];
}


>Thanks for your patience, Jerry; as you can see, I'm in culture 
>shock...anyway, it looks like once I've sorted out these two things (list of 
>files, list of targets) I'll be good to try sorting out the dependencies.
No problem.

-- 
http://rrt.sc3d.org/ | Brevity is the soul


Jerry Pendergraft                              voice:651-523-6935
St.Jude Medical                                mobil:651-491-0163
Atrial Fibrillation Division                email:jpendergraft at sjm.com
1350 Energy Lane
St.Paul, MN  55108





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.auug.org.au/pipermail/cook-users/attachments/20070303/98d88f10/attachment.htm>


More information about the Cook-users mailing list