Re: Learning and using aap in website project

Bram Moolenaar <[email protected]> Thu, 01 Jul 2004 12:14:07 +0200
Newsgroups gmane.comp.tools.aap.user
Message-ID <[email protected]>
Fredrik wrote:

> > It's not so obvious.  Aap finds the rule to turn a .asc file into a
> > .html file, but a rule does not specify where to search for the source
> > file.  It simply uses the name of the file with the path for the %.
> > 
> > The most explicit solution is to adjust the rule to include the path:
> > 
> >     :rule ../html/%.html : %.asc conf/asciidoc.conf
> >         ...
> 
> Thanx! That solved it!
> 
> I still cannot figure out how to solve the "articles" part (subdir).
> 
> In the "source" dir I have another dir called "articles" where I put submitted
> articles also written in AsciiDoc but in this dir the conf/asciidoc.conf is
> diffrent than in the the source dir so I can't have these files in the
> "source" dir. I have tried a lot of combinations with ":child
> source/articles/main.aap" and changed the "ROOT" variable in the filelist to
> "ARTICLES" but I get an message about that source/articles/main.aap doesent
> know how to build "about.asc" which is a file in "source" not in "articles".
> Even after I have changed the the "HTML_FILES" variable to "ARTICLES" wich is
> a variable in the "filelist.aap".  ( I hope you understand what I mean).
> 
> Here is an exact description of what I want to do :)
> 
> /
> /source/
> /source/conf/
> /source/atricles
> /source/articles/conf
> /html
> 
> In the source dir the "main" site is located and in the "articles" dir
> submitted articles are located. In those dirs there is another dir "conf"
> which contans a asciidoc.conf file which holds the configuration when
> generating html from the ascidoc files. These need to be diffrent
> (that's why I need to have a seperate dir for the articles).
> 
> Going to / and type "aap" would first go to "source" and build all the %.asc
> files using /source/conf/asciidoc.conf configuration file and then go to
> "/source/articles" and build all the %.asc files using
> "/source/articles/conf/asciidoc.conf" configuration and all build files should
> be palced in the /html dir. *phew* 

It looks like it gets too complicated to do this with a rule.  Let's
switch to explicit dependencies.  This has the advantage that the file
names are fixed (relative to the recipe in which the dependency is
defined).

Since you will use the build commands more then once, it's a good idea
to put them in an action.  This functions as a subroutine then.  You
could put this in the top directory in a "include.aap" recipe.

	:action asc2html default
		... build commands from $source to $target ...

To make sure the right conf/asciidoc.conf is used, define the
dependencies in the directory where the .asc files are located.  Is it
OK that conf/asciidoc.conf is one of the source files?

For source/main.aap:

	:include ../include.aap
	LocalFiles = one two three

	@for name in var2list(LocalFiles):
		../html/$(name).html : $(name).asc conf/asciidoc.conf
			:do asc2html $source

For source/articles/main.aap:

	:include ../../include.aap
	LocalFiles = hip hop hup

	@for name in var2list(LocalFiles):
		../../html/$(name).html : $(name).asc conf/asciidoc.conf
			:do asc2html $source

To avoid listing the files twice you can pass the html names to the
parent:

	_top.FileList += html/$*(LocalFiles).html

So that in the toplevel main.aap you can do:

	:child source/main.aap
	:child source/articles/main.aap

	all: $FileList

Hope that gives you enough ideas.

-- 
-rwxr-xr-x  1 root          24 Oct 29  1929 /bin/ed
-rwxr-xr-t  4 root      131720 Jan  1  1970 /usr/ucb/vi
-rwxr-xr-x  1 root  5.89824e37 Oct 22  1990 /usr/bin/emacs

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\  Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///


-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com