[Cook] Multiple cook files in a project

Kyle Loveless kyle.p.loveless at gmail.com
Thu Sep 15 14:01:50 EST 2011


Hi,

I've just started looking into using cook for my build dependency system.

>From what I can tell from the tutorial, it looked like the normal use of
cook is to use a single cookbook for the entire project. What I would like
to do is have a separate cookbook for each library and each executable.
I can use the #include directive to load in other cookbooks easily enough,
but in my case I want the cook files to execute depending on where they are
loaded from.

For instance, say I have a cookbook that builds a zlib library. For my
repository its in /libraries/zlib. And say I have a program in /program1
which has a cookbook containing:
#include /libraries/zlib/Howto.cook

Basically I want that include to execute the zlib cookbook as if cook was
called in the /libraries/zlib folder. Right now the /libraries/zlib folder
would not be in the search path and thus everything wouldn't build properly.
What I could do is in the zlib cookbook is have this at the beginning:
old_search_list = [search_list];
search_list = [__FILEPATH__]\:[search_list];

where I define __FILEPATH__ to be a built-in which is the full path to the
current cook file(like __FILE__ but the full path). Thus searching will
begin in the correct directory(and presumably fix some of my issues).
At the end of the cookbook I would add:
search_list = [old_search_list];
to return search_list to its original state.

So this would require me to modify cook (which may be fine, but if I don't
have to its better not to) to add the __FILEPATH__ intrinsic. Also this
requires the above pattern in every cook file. Instead of doing this
manually, I could modify cook to do the updating of search_list
automatically.

One thing this wouldn't handle is name collisions. For build rules, the
repository path could be hard-coded in, but this wouldn't solve the problem
for variables. I haven't see support for namespaces in cook.

So this leads me to a few questions:
1) Is there something I've missed that lets me build a project easily with a
cookbook for each library?
2) If there isn't, what are your thoughts on the above solution(s)?

Thanks!

Kyle
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.auug.org.au/pipermail/cook-users/attachments/20110915/6a933077/attachment.html>


More information about the Cook-users mailing list