Support user defined .NET analyzers/source generators in Flax.Build
This commit is contained in:
@@ -272,8 +272,10 @@ namespace Flax.Build
|
||||
foreach (var reference in fileReferences)
|
||||
args.Add(string.Format("/reference:\"{0}\"", reference));
|
||||
#if USE_NETCORE
|
||||
foreach (var analyzer in buildOptions.ScriptingAPI.SystemAnalyzers)
|
||||
args.Add(string.Format("/analyzer:\"{0}{1}.dll\"", referenceAnalyzers, analyzer));
|
||||
foreach (var systemAnalyzer in buildOptions.ScriptingAPI.SystemAnalyzers)
|
||||
args.Add(string.Format("/analyzer:\"{0}{1}.dll\"", referenceAnalyzers, systemAnalyzer));
|
||||
foreach (var analyzer in buildOptions.ScriptingAPI.Analyzers)
|
||||
args.Add(string.Format("/analyzer:\"{0}\"", analyzer));
|
||||
#endif
|
||||
foreach (var sourceFile in sourceFiles)
|
||||
args.Add("\"" + sourceFile + "\"");
|
||||
|
||||
@@ -200,14 +200,19 @@ namespace Flax.Build.NativeCpp
|
||||
public HashSet<string> SystemReferences;
|
||||
|
||||
/// <summary>
|
||||
/// The .Net libraries references (dll or exe files paths).
|
||||
/// The system analyzers/source generators.
|
||||
/// </summary>
|
||||
public HashSet<string> SystemAnalyzers;
|
||||
|
||||
/// <summary>
|
||||
/// The .NET libraries references (dll or exe files paths).
|
||||
/// </summary>
|
||||
public HashSet<string> FileReferences;
|
||||
|
||||
/// <summary>
|
||||
/// The .Net libraries references (dll or exe files paths).
|
||||
/// The .NET analyzers (dll or exe files paths).
|
||||
/// </summary>
|
||||
public HashSet<string> SystemAnalyzers;
|
||||
public HashSet<string> Analyzers;
|
||||
|
||||
/// <summary>
|
||||
/// True if ignore compilation warnings due to missing code documentation comments.
|
||||
@@ -232,6 +237,7 @@ namespace Flax.Build.NativeCpp
|
||||
Defines.AddRange(other.Defines);
|
||||
SystemReferences.AddRange(other.SystemReferences);
|
||||
FileReferences.AddRange(other.FileReferences);
|
||||
Analyzers.AddRange(other.Analyzers);
|
||||
IgnoreMissingDocumentationWarnings |= other.IgnoreMissingDocumentationWarnings;
|
||||
}
|
||||
}
|
||||
@@ -305,6 +311,7 @@ namespace Flax.Build.NativeCpp
|
||||
"Microsoft.Interop.SourceGeneration",
|
||||
},
|
||||
FileReferences = new HashSet<string>(),
|
||||
Analyzers = new HashSet<string>(),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -247,6 +247,14 @@ namespace Flax.Build.Projects.VisualStudio
|
||||
csProjectFileContent.AppendLine(" </ItemGroup>");
|
||||
}
|
||||
}
|
||||
foreach (var analyzer in configuration.TargetBuildOptions.ScriptingAPI.Analyzers)
|
||||
{
|
||||
csProjectFileContent.AppendLine(string.Format(" <ItemGroup Condition=\" '$(Configuration)|$(Platform)' == '{0}' \">", configuration.Name));
|
||||
csProjectFileContent.AppendLine(string.Format(" <Analyzer Include=\"{0}\">", Path.GetFileNameWithoutExtension(analyzer)));
|
||||
csProjectFileContent.AppendLine(string.Format(" <HintPath>{0}</HintPath>", Utilities.MakePathRelativeTo(analyzer, projectDirectory).Replace('/', '\\')));
|
||||
csProjectFileContent.AppendLine(" </Analyzer>");
|
||||
csProjectFileContent.AppendLine(" </ItemGroup>");
|
||||
}
|
||||
|
||||
csProjectFileContent.AppendLine("");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user