Automatically select the C# target variant for the current framework

This commit is contained in:
Sam Harwell 2013-02-27 09:37:09 -06:00
parent c859debc68
commit 8ee3a2204f
3 changed files with 27 additions and 1 deletions

View File

@ -130,6 +130,7 @@
BuildTaskPath="$(Antlr4BuildTaskLocation)"
OutputPath="$(IntermediateOutputPath)"
TargetLanguage="%(Antlr4.TargetLanguage)"
TargetFrameworkVersion="$(TargetFrameworkVersion)"
SourceCodeFiles="@(Antlr4)"
ContinueOnError="$(_IntellisenseOnlyCompile)"
TokensFiles="@(Antlr4Tokens)"

View File

@ -76,6 +76,12 @@ namespace Antlr4.Build.Tasks
set;
}
public string TargetFrameworkVersion
{
get;
set;
}
public string BuildTaskPath
{
get;
@ -294,6 +300,7 @@ namespace Antlr4.Build.Tasks
wrapper.ToolPath = ToolPath;
wrapper.SourceCodeFiles = sourceCodeFiles;
wrapper.TargetLanguage = TargetLanguage;
wrapper.TargetFrameworkVersion = TargetFrameworkVersion;
wrapper.OutputPath = OutputPath;
wrapper.LanguageSourceExtensions = LanguageSourceExtensions;
wrapper.TargetNamespace = TargetNamespace;

View File

@ -65,6 +65,12 @@ namespace Antlr4.Build.Tasks
set;
}
public string TargetFrameworkVersion
{
get;
set;
}
public string OutputPath
{
get;
@ -173,7 +179,19 @@ namespace Antlr4.Build.Tasks
arguments.Add("-Dabstract=true");
if (!string.IsNullOrEmpty(TargetLanguage))
arguments.Add("-Dlanguage=" + TargetLanguage);
{
string framework = TargetFrameworkVersion;
if (string.IsNullOrEmpty(framework))
framework = "v2.0";
string language;
if (TargetLanguage.Equals("CSharp"))
language = TargetLanguage + '_' + framework.Replace('.', '_');
else
language = TargetLanguage;
arguments.Add("-Dlanguage=" + language);
}
if (!string.IsNullOrEmpty(TargetNamespace))
{