[jamming] Pre-parsing source files before building
Chris
syndicate_dragon at yahoo.com
Wed Aug 22 08:55:57 PDT 2007
Maybe I should have been more specific. :)
srcfile1.c and genfile1.c are not related. genfile1.c etc are output by a design tool that we use.
Here is another example of something I tried.
rule PreParse
{
Depends $(1) : $(2) ;
}
actions PreParse
{
#just a place holder for the script I need to run
echo "Preparsing!"
}
rule AuxSrc
{
Depends $(1) : $(2) ;
PreParse $(1) : $(2) ;
Objects $(2) ;
}
rule BuildLib
{
Depends $(1) : $(2:S=.OBJ) ;
}
actions BuildLib
{
$(AR) r $(AUXLIB) $(AUXOBJ)
}
AuxSrc $(AUXLIB) : $(AUXSRC) ;
BuildLib $(AUXLIB) : $(AUXSRC) ;
Main $(LINKTARGET) : $(SRC) ;
Convert $(FINALTARGET) : $(LINKTARGET) ;
This didn't work, because the source files were being compiled before the PreParse rule was being invoked. No matter what I did, I couldn't get the PreParse action to run before the Objects was invoked.
I think the problem is that when the source files are generated, they're newer than the target, so the tool assumes they need to built - which is true, except that I need to do this other step to them first.
I feel like I'm close, but there is some fundamental idea I'm missing. Any more ideas?
Thanks
Chris
Craig Allsop <cjamallsop at gmail.com> wrote: Hi Chris,
I'm assuming srcfile1.c is converted to genfile1.c and then linked in
the final program? So to make it easier to write in jam, can we just
add a gen prefix for the generated files so that srcfile1.c is
converted to gensrcfile1.c? Therefore you would do this...
LINKTARGET = flash.hex
FINALTARGET = app.bin
MAINSRC = srcfile1.c srcfile2.c ;
for i in $(MAINSRC)
{
# this will run: yourpreparsetoolhere outfile infile
GenFile gen$(i) : yourpreparsetoolhere $(i) ;
}
Main $(LINKTARGET) : gen$(MAINSRC) ;
Convert $(FINALTARGET) : $(LINKTARGET) ;
Depends all : $(FINALTARGET) ;
Only pass the generated sources to Main, gen$(MAINSRC) will be
expanded to prefix all source with "gen". If you have others you don't
then just list with as extras.
Hope that helps.
Craig.
On 8/21/07, Chris wrote:
> We have a tool which generates some of our source files. Unfortunately, the
> files need to be touched up a bit before our cranky compiler can use them. I
> am trying to make this pre-parsing an automated part of the jam build
> process, but I'm having some trouble finding the right magic words to make
> it work. The problem seems to be that the files may already exist and need
> not be parsed again if they have not changed from the previous build. I'm
> having a hard time coming up with a rule/dependencies that can detect if
> generated source files are newer than the final target and run the
> pre-parsing script on them before compiling them. The script we have
> automatically fixes all of the generated files, so it only needs to run
> once.
>
> Here's what I have so far, which seems to work except for the pre-parsing
> step. AUXSRC are the sources generated by the tool. There are custom actions
> for Cc and Link to deal with our stupid compiler. I can detail those if
> someone thinks it necessary, but for brevity they are omitted here. The
> "Convert" rule/action handles converting the linker output to our download
> format.
>
> LINKTARGET = flash.hex
> FINALTARGET = app.bin
> MAINSRC = srcfile1.c srcfile2.c ;
> AUXSRC = genfile1.c genfile2.c ;
> SRC = $(MAINSRC) $(AUXSRC) ;
>
> Main $(LINKTARGET) : $(SRC) ;
> Convert $(FINALTARGET) : $(LINKTARGET) ;
> Depends all : $(FINALTARGET) ;
>
>
> Thanks,
> Chris
>
> ________________________________
> Yahoo! oneSearch: Finally, mobile search that gives answers, not web links.
> _______________________________________________
> jamming mailing list - jamming at perforce.com
> http://maillist.perforce.com/mailman/listinfo/jamming
>
>
---------------------------------
Moody friends. Drama queens. Your life? Nope! - their life, your story.
Play Sims Stories at Yahoo! Games.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://maillist.perforce.com/pipermail/jamming/attachments/20070822/efb4f566/attachment.html
More information about the jamming
mailing list