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)
|
foreach (var reference in fileReferences)
|
||||||
args.Add(string.Format("/reference:\"{0}\"", reference));
|
args.Add(string.Format("/reference:\"{0}\"", reference));
|
||||||
#if USE_NETCORE
|
#if USE_NETCORE
|
||||||
foreach (var analyzer in buildOptions.ScriptingAPI.SystemAnalyzers)
|
foreach (var systemAnalyzer in buildOptions.ScriptingAPI.SystemAnalyzers)
|
||||||
args.Add(string.Format("/analyzer:\"{0}{1}.dll\"", referenceAnalyzers, analyzer));
|
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
|
#endif
|
||||||
foreach (var sourceFile in sourceFiles)
|
foreach (var sourceFile in sourceFiles)
|
||||||
args.Add("\"" + sourceFile + "\"");
|
args.Add("\"" + sourceFile + "\"");
|
||||||
|
|||||||
@@ -200,14 +200,19 @@ namespace Flax.Build.NativeCpp
|
|||||||
public HashSet<string> SystemReferences;
|
public HashSet<string> SystemReferences;
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
public HashSet<string> FileReferences;
|
public HashSet<string> FileReferences;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The .Net libraries references (dll or exe files paths).
|
/// The .NET analyzers (dll or exe files paths).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public HashSet<string> SystemAnalyzers;
|
public HashSet<string> Analyzers;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// True if ignore compilation warnings due to missing code documentation comments.
|
/// True if ignore compilation warnings due to missing code documentation comments.
|
||||||
@@ -232,6 +237,7 @@ namespace Flax.Build.NativeCpp
|
|||||||
Defines.AddRange(other.Defines);
|
Defines.AddRange(other.Defines);
|
||||||
SystemReferences.AddRange(other.SystemReferences);
|
SystemReferences.AddRange(other.SystemReferences);
|
||||||
FileReferences.AddRange(other.FileReferences);
|
FileReferences.AddRange(other.FileReferences);
|
||||||
|
Analyzers.AddRange(other.Analyzers);
|
||||||
IgnoreMissingDocumentationWarnings |= other.IgnoreMissingDocumentationWarnings;
|
IgnoreMissingDocumentationWarnings |= other.IgnoreMissingDocumentationWarnings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -305,6 +311,7 @@ namespace Flax.Build.NativeCpp
|
|||||||
"Microsoft.Interop.SourceGeneration",
|
"Microsoft.Interop.SourceGeneration",
|
||||||
},
|
},
|
||||||
FileReferences = new HashSet<string>(),
|
FileReferences = new HashSet<string>(),
|
||||||
|
Analyzers = new HashSet<string>(),
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -247,6 +247,14 @@ namespace Flax.Build.Projects.VisualStudio
|
|||||||
csProjectFileContent.AppendLine(" </ItemGroup>");
|
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("");
|
csProjectFileContent.AppendLine("");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user