[jamming] Pre-parsing source files before building
Craig Allsop
cjamallsop at gmail.com
Thu Aug 23 15:47:23 PDT 2007
Hi Chris,
Ok, order matters for in-place parsing but I wouldn't recommend
parsing them in-place because it adds unnecessary complexity. How will
jam know the difference between a converted file and one which is not
each time your run it? What is wrong with the intermediate files as
many tools use them e.g. yacc? The nice thing about GenFile is you can
build your pre-parsing tool before pre-parsing. You can tell jam to
output them to an intermediate directory if you don't like them in the
source folder ... anyway ...
Ok, assuming you *really* want to do this, I would set a variable on
your obj targets and use this variable to construct the pre-parsing
action of the source file when Cc action runs. So here we go...
1. Create a rule to set a variable on your objs, we'll set it's value
to the name of your tool that pre-parses the files... you can hide
this in your jamrules.
rule PreParse
{
PP on [ FGristFiles $(<:S=$(SUFOBJ)) ] = yourpptool.exe ;
}
2. Call this rule on your genfile sources in your jamfile:
PreParse $(AUXSRC) ;
3. Copy and modify the Cc actions so that when PP is set, it will be
called to preparse your source file before it is compiled. Hide this
in your jamrules as well.
actions Cc
{
$(PP)$(SPACE)$(>)
$(CC) /c /Fo$(<) $(CCFLAGS) $(CCDEFS) $(CCHDRS) /I$(STDHDRS) $(>)
}
4. Add the definition of SPACE to your jamrules as well..
SPACE = " " ;
Explanation: For the files with PP set, jam will expand the initial
line and call your tool to do the in-place conversion (which it will
have to do always since you don't know if it needs doing or not -
which is my problem with this - but anyway it will work for you) and
thus running your tool prior to compiling it to an obj. For those
files which do not have PP set, jam will expand the line to blank by
multiplication (see docs) not executing anything at all, then compile
the file to obj.
If you have C++ sources you'll need the same mod on it's actions.
Hope it helps, let me know how you go.
Cheers,
Craig.
On 8/24/07, Chris <syndicate_dragon at yahoo.com> wrote:
> The order DOES matter for me, because when I parse these generated files,
> the names of the resulting files are the same. I parse them "in-place" so to
> speak.
>
> Is the only way to get this to work is to rename them once parsed? Or can I
> force GenFiles to run before Main?
>
> Thanks
> Chris
More information about the jamming
mailing list