[Cook] Help wanted with unorthodox use of cook
Reuben Thomas
rrt at sc3d.org
Fri Mar 2 12:53:56 EST 2007
I have a slightly unusual use for cook, but I'm a complete newbie to it and
have little idea how to go about using it for this purpose. I have a very
simple web-templating system to which I want to add support for generated
files, but it occurred to me that this is just reinventing the wheel.
However, apart from cook, none of the make-like systems I investigated
seemed able to straightforwardly do what I want, namely:
1. Have a single top-level makefile that worked for a complete directory
hierarchy.
2. Process non-standard includes dependencies.
Having studied the cook manual and introduction I discovered that cook
handles 1 fine, and probably can do 2 easily, but I'd appreciate any
pointers the experts can give.
Basically, includes work like this in my system: suppose a file
foo/bar/baz/bob.html contains "$include{fragment}". Then a file called
"fragment" is searched for in the following directories, in the following
order: foo/bar/baz, foo/bar, foo, <root>.
So, it's pretty easy to see how to write a script to generate the
dependencies (it's just a simplified version of the program I already wrote,
called nancy: http://rrt.sc3d.org/Software/Nancy). It then needs to be run
on each file in each leaf directory of the hierarchy (the "leaf
directory=web page" rule means that every web page can have per-page
includes that don't conflict with any other page's includes). The simplest
thing I can think of is writing a script that a) finds all the leaf
directories, and b) finds the includes as above. Indeed, I already have
such a script. But I was wondering if that's overkill given cook's
capabilities. It then remains to tell cook how to produce an output file;
the other important detail is that, in order to avoid confusion and allow
fragments to use the same file suffix as web pages, to avoid having to
reprogram editors or file associations, I only do out-of-tree "builds", but
again, cook seems able to cope.
What I'd really appreciate is some moderately precise pointers on how best
to implement each element of this scheme, but any help would be much
appreciated, including of course any mistakes I seem to have made about
cook. I hope to end up with nancy written in cook as a single generic
Howto.cook file that I can use instead of nancy, adding per-project build
rules as necessary for projects that generate include files by other (more
traditional!) means; the motivating example in my case is HTML fragments
generated from XML.
--
http://rrt.sc3d.org/ | impunity, n. wealth (Bierce)
More information about the Cook-users
mailing list