[antlr-interest] VS 2008 build setup - Antlr is calledunnecessarily when grammar.g hasn't changed

Sam Harwell sharwell at pixelminegames.com
Fri Aug 7 11:32:35 PDT 2009


My build does not exhibit this behavior (the generated files are only
generated if they are out of date). I highlighted a section in the
Target definition which clearly differs from the web page description
and I know is used when checking for out-of-date dependencies.

 

Here is a combined grammar:

 

    <Antlr3 Include="UcLanguage\UcGrammar.g">

 
<OutputFiles>UcLanguage\UcGrammarLexer.cs;UcLanguage\UcGrammarParser.cs;
UcLanguage\UcGrammar.tokens</OutputFiles>

    </Antlr3>

 

Here is a lexer grammar:

 

    <Antlr3 Include="UcLanguage\DoxygenLexer.g3">

 
<OutputFiles>UcLanguage\DoxygenLexer.cs;UcLanguage\DoxygenLexer.tokens</
OutputFiles>

    </Antlr3>

 

Here is a tree walker:

 

    <Antlr3 Include="UcLanguage\UcGrammarWalker.g">

      <InputFiles>UcLanguage\UcGrammar.tokens</InputFiles>

 
<OutputFiles>UcLanguage\UcGrammarWalker.cs;UcLanguage\UcGrammarWalker.to
kens</OutputFiles>

      <TokensPath>$(MSBuildProjectDirectory)\UcLanguage\</TokensPath>

    </Antlr3>

 

Here is the target section:

 

  <PropertyGroup>

 
<Antlr3ToolPath>$(MSBuildProjectDirectory)\..\Reference\Antlr</Antlr3Too
lPath>

 
<CoreCompileDependsOn>$(CoreCompileDependsOn);GenerateAntlrCode</CoreCom
pileDependsOn>

  </PropertyGroup>

  <Target Name="GenerateAntlrCode" Inputs="@(Antlr3)"
Outputs="%(OutputFiles)">

    <Message Importance="normal" Text="Antlr: Transforming '@(Antlr3)'
to '%(Antlr3.OutputFiles)'" />

    <Exec Command="%22$(Antlr3ToolPath)\Antlr3.exe%22
-Xconversiontimeout 10000 -lib %22%(RootDir)%(Directory).%22
-message-format vs2005 @(Antlr3)" Outputs="%(OutputFiles)" />

  </Target>

 

Finally, I don't have InitialTargets set on the Project node, however I
do have the following set, which fixes the problem of requiring two
builds to catch changes to the compiled grammar. Perhaps setting the
InitialTargets is another method to accomplish the same thing? Either
way, this setting isn't the source of the particular build issue you're
asking about.

 

  <PropertyGroup>

    <UseHostCompilerIfAvailable>False</UseHostCompilerIfAvailable>

  </PropertyGroup>

 

Sam

 

From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Andrew Bradnan
Sent: Friday, August 07, 2009 12:10 PM
To: Andrew Chalmers; antlr-interest at antlr.org
Subject: Re: [antlr-interest] VS 2008 build setup - Antlr is
calledunnecessarily when grammar.g hasn't changed

 

There's a -make option to do what you want.

On Thu, Aug 6, 2009 at 7:02 PM, Andrew Chalmers <everfall at hotmail.com>
wrote:

I followed the instructions here
(http://www.antlr.org/wiki/display/ANTLR3/Integration+with+Development+E
nvironments).
 
My grammar.g has two child (dependent) items, blahLexer.cs and
blahParser.cs. When I build my solution, Antlr is called, and correctly
rebuilds the lexer and parser, which is great.
 
My problem is that Antlr is called _every_ time I run a build, even when
the two dependent items (lexer and parser.cs) are up-to-date wrt the
grammar definition.
 
Anyone know how to instruct msbuild (or even Antlr; I'm not picky!) to
skip the rebuild of lexer and parser when they're already up-to-date?

________________________________

Click Here View photos of singles in your area
<http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fdating%2Eninemsn%2Ecom%
2Eau%2Fsearch%2Fsearch%2Easpx%3Fexec%3Dgo%26tp%3Dq%26gc%3D2%26tr%3D1%26l
age%3D18%26uage%3D55%26cl%3D14%26sl%3D0%26dist%3D50%26po%3D1%26do%3D2%26
trackingid%3D1046138%26r2s%3D1&_t=773166090&_r=Hotmail_Endtext&_m=EXT> 



List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address






-- 
/Andrew

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090807/a26382ba/attachment.html 


More information about the antlr-interest mailing list