[Cook] find the cookbook up the path?

Tom Satter tsatter at purecode.com
Wed Sep 24 16:21:49 EST 2003


Actually, the way that we did it was this:

.../top/Howto.cook
       /libs/lib1/Howto.cook
                 /src/*.c
                 /hdr/*.h
            /lib2/Howto.cook
                 /src/*.c
                 /hdr/*.h
            /lib3/Howto.cook
                 /src/*.c
                 /hdr/*.h
       /pgm1/Howto.cook
            /src/*.c
            /hdr/*.h
       /pgm2/Howto.cook
            /src/*.c
            /hdr/*.h

The low level Howto.cook files set up the target for the proper
directory and then sourced the top Howto.cook file.  The top Howto.cook
file included all Howto.cook files below it.  Then the target was built.
 That way, if you were in the pgm1/src directory (where there is no
Howto.cook file) and you typed docook, it would properly build
libs/lib1, libs/lib2, and pgm1 (since pgm1 depends on lib1 and lib2). 
If you type docook in the top directory it would build all programs.

It actually works very well this way and keeps us from having to have
dummy Howto.cook files in all of the low level directories that don't
actually do anything.

The problem with the solution you gave is that it does not set up the
target information from your current directory. In a system like we have
here, where I have twenty libraries and thirty executables, I don't want
to have to wait for it to build everything so that I can test the one
exec that I am debugging.  Also, it is nice to have it automatically
figure out what exec to build based on my cwd.  It is always possible
(of course) to override the target on the command line: "docook pgm2"
from the pgm1 directory in which case pgm2 alone would be built.

This is not a hierarchical make.  We actually include all low level cook
files into the dependency tree and then do the building.

tom


On Tue, 23 Sep 2003 22:14:06 -0400 (EDT)
"Aryeh M. Friedman" <aryeh at m-net.arbornet.org> wrote:

> > Tom Satter schrieb am Mittwoch 24 September 2003 01:07:
> > > We just wrote a script called docook that lookup up the file
> > > hierarchy for a Howto.cook file and then used that.  If no
> > > Howto.cook was found within some number of hierarchical levels
> > > (like 6) then we reported an error.
> > 
> > thanks alot, I'll simply do the same --- hmmm... sometimes I wonder why the 
> > obvious isn't allways obvious... :-)
> 
> 	What is obvious is not always "right"... what I mean by this is
> your essencially recreating the whole problem cook was designed to solve
> (whole project dependancy graphs) [see either the chapter on whole project
> builds, the tutorial or a new guide I am in the middle of passing around to
> those intrested on how to intergrate cook/aegis/fhist/tardy in what
> ever order you wish {1}]...  the basic idea here being that for any given
> target there should be a single well defined method for how to build it
> and if you follow the DRY [don't repeat yourself] princible as put forward
> by Hunt and Thomas ("The Pragmatic Programmer") you should "never" have more
> then one physical representation of the recipe for this target.
> 
> 	Don't worry almost of us made the same mistake when we came to cook
> for the first time... I was essencially recreating recursive makes and not
> knowing it in my first  few cookbooks....
> 
> 	As to a practicle answer for your first question... assuming your
> not using a change/config managment system you should establish some root
> dir for your project and then create an alias like this (csh) to do cook:
> 
> alias docook 'set foo=`pwd`;cd $PRJ_ROOT;cook !\*;cd $foo'
> 
> 	--Aryeh
> 
> Notes:
> 
> 1. If me and Peter can work some formating issues the guide should be
> a part of the next release of cook and/or aegis (more likelly the second)
> ----- End of forwarded message (env-from aryeh) -----
> _______________________________________________
> Cook-users mailing list
> Cook-users at auug.org.au
> http://www.auug.org.au/mailman/listinfo/cook-users


-- 
tom satter -- tsatter at purecode.com
(303) 543-7623 (home), (303) 499-4100 (work)

The hardest thing in the world to understand is the income tax.
                -- Albert Einstein



More information about the Cook-users mailing list