10 Commits
Author SHA1 Message Date
crazytuzi 0f2fd1382f UTF-8 2026-07-07 19:09:50 +08:00
yawn831 e5c27effd7 feat: 头文件注释 (#10)
* feat: 头文件注释

* feat: 头文件注释提交
2026-01-22 10:31:06 +08:00
crazytuzi 7bcb7823a6 Merge pull request #8 from yawn831/Black
feat: 新增blacklist
2025-06-28 20:33:16 +08:00
yawn831831 197fbbe6ce feat: 新增blacklist 2025-06-28 01:12:32 +08:00
crazytuzi bf9949b5cb Merge pull request #7 from yawn831/fixerror
fix: 修复sg报错
2025-06-24 23:03:59 +08:00
yawn831831 fbe837fca9 fix: 修复sg报错 2025-06-24 23:01:35 +08:00
crazytuzi 4aac4cc1fc Merge pull request #5 from crazytuzi/5.3
Ignore props
2024-11-17 19:02:58 +08:00
crazytuzi 4a3273ec31 Ignore props 2024-11-17 19:02:44 +08:00
crazytuzi fa2f24a764 Merge pull request #4 from Srkmn/5.5
Cross Version
2024-11-17 17:16:52 +08:00
Srkmn 90c5058a4c Cross Version 2024-11-17 17:15:24 +08:00
3 changed files with 37 additions and 23 deletions

No files matched your search

+1
View File
@@ -74,3 +74,4 @@ Plugins/**/Intermediate/*
DerivedDataCache/* DerivedDataCache/*
obj/* obj/*
SourceCodeGenerator.ubtplugin.csproj.props
+34 -21
View File
@@ -62,6 +62,15 @@ namespace SourceCodeGeneratorUbtPlugin
private const string HeaderSuffix = ".header.inl"; private const string HeaderSuffix = ".header.inl";
private readonly HashSet<string> ClassBlacklist = new();
private const string GeneratedHeaderComment =
"/*===========================================================================\n" +
" Generated code exported from UnrealCSharp SourceCodeGenerator.\n" +
" DO NOT modify this manually!\n" +
"===========================================================================*/\n" +
"\n";
public SourceCodeGenerator(IUhtExportFactory factory) public SourceCodeGenerator(IUhtExportFactory factory)
{ {
Factory = factory; Factory = factory;
@@ -119,26 +128,37 @@ namespace SourceCodeGeneratorUbtPlugin
ExportModule.Add(value); ExportModule.Add(value);
} }
} }
if (SettingConfigHierarchySection.TryGetValues("ClassBlacklist", out var BlacklistValues))
{
foreach (var value in BlacklistValues)
{
if (!string.IsNullOrEmpty(value))
{
ClassBlacklist.Add(value);
}
}
}
} }
} }
List<Task?> tasks = new(); List<Task?> tasks = new();
foreach (var package in Session.Packages) foreach (var module in Session.Modules)
{ {
if (package.Module.ModuleType != UHTModuleType.EngineRuntime && if (module.Module.ModuleType != UHTModuleType.EngineRuntime &&
package.Module.ModuleType != UHTModuleType.GameRuntime) module.Module.ModuleType != UHTModuleType.GameRuntime)
{ {
continue; continue;
} }
if (ExportModule.All(module => if (ExportModule.All(x =>
string.Compare(module, package.Module.Name, StringComparison.OrdinalIgnoreCase) != 0)) string.Compare(x, module.Module.Name, StringComparison.OrdinalIgnoreCase) != 0))
{ {
continue; continue;
} }
QueueClassExports(package, tasks); QueueClassExports(module.ScriptPackage, tasks);
} }
var waitTasks = tasks.Where(Task => Task != null).Cast<Task>().ToArray(); var waitTasks = tasks.Where(Task => Task != null).Cast<Task>().ToArray();
@@ -179,7 +199,8 @@ namespace SourceCodeGeneratorUbtPlugin
/// <returns>True if the class should be exported, false if not</returns> /// <returns>True if the class should be exported, false if not</returns>
protected virtual bool CanExportClass(UhtClass classObj) protected virtual bool CanExportClass(UhtClass classObj)
{ {
return !classObj.ClassFlags.HasAnyFlags(EClassFlags.Interface) && return !ClassBlacklist.Contains(classObj.SourceName) &&
!classObj.ClassFlags.HasAnyFlags(EClassFlags.Interface) &&
IsClassTypeSupported(classObj); IsClassTypeSupported(classObj);
} }
@@ -275,14 +296,6 @@ namespace SourceCodeGeneratorUbtPlugin
} }
} }
if (property is UhtObjectPtrProperty objectPtrProperty)
{
if (!IsClassTypeSupported(objectPtrProperty.Class))
{
return false;
}
}
if (property is UhtInterfaceProperty interfaceProperty) if (property is UhtInterfaceProperty interfaceProperty)
{ {
if (interfaceProperty.InterfaceClass == interfaceProperty.Session.IInterface) if (interfaceProperty.InterfaceClass == interfaceProperty.Session.IInterface)
@@ -360,6 +373,8 @@ namespace SourceCodeGeneratorUbtPlugin
var builder = borrow.StringBuilder; var builder = borrow.StringBuilder;
builder.Append(GeneratedHeaderComment);
builder.Append("#pragma once\r\n\r\n"); builder.Append("#pragma once\r\n\r\n");
foreach (var value in package.Value) foreach (var value in package.Value)
@@ -367,7 +382,7 @@ namespace SourceCodeGeneratorUbtPlugin
builder.Append(GenerateInclude($"{value}{BindingSuffix}")); builder.Append(GenerateInclude($"{value}{BindingSuffix}"));
} }
var fileName = Factory.MakePath(package.Key, HeaderSuffix); var fileName = Factory.MakePath(package.Key.Module, HeaderSuffix);
SaveIfChanged(fileName, builder); SaveIfChanged(fileName, builder);
} }
@@ -375,6 +390,8 @@ namespace SourceCodeGeneratorUbtPlugin
private bool ExportClass(StringBuilder builder, UhtClass classObj) private bool ExportClass(StringBuilder builder, UhtClass classObj)
{ {
builder.Append(GeneratedHeaderComment);
builder.Append("#pragma once\r\n\r\n" + builder.Append("#pragma once\r\n\r\n" +
"PRAGMA_DISABLE_DEPRECATION_WARNINGS\r\n\r\n"); "PRAGMA_DISABLE_DEPRECATION_WARNINGS\r\n\r\n");
@@ -463,10 +480,6 @@ namespace SourceCodeGeneratorUbtPlugin
DependencyClasses.Add(classProperty.MetaClass); DependencyClasses.Add(classProperty.MetaClass);
} }
} }
else if (property is UhtObjectPtrProperty objectPtrProperty)
{
DependencyClasses.Add(objectPtrProperty.Class);
}
else if (property is UhtObjectProperty objectProperty) else if (property is UhtObjectProperty objectProperty)
{ {
DependencyClasses.Add(objectProperty.Class); DependencyClasses.Add(objectProperty.Class);
@@ -759,7 +772,7 @@ namespace SourceCodeGeneratorUbtPlugin
private string GetHeaderFile(UhtClass classObj) private string GetHeaderFile(UhtClass classObj)
{ {
return Path.Combine(HeaderPath[classObj.Package.ShortName], classObj.HeaderFile.FilePath); return Path.Combine(HeaderPath[classObj.Package.Module.ShortName], classObj.HeaderFile.FilePath);
} }
private static string GenerateInclude(string file) private static string GenerateInclude(string file)
+2 -2
View File
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<Import Project="SourceCodeGenerator.ubtplugin.csproj.props" Condition="Exists('SourceCodeGenerator.ubtplugin.csproj.props')" /> <Import Project="SourceCodeGenerator.ubtplugin.csproj.props" Condition="Exists('SourceCodeGenerator.ubtplugin.csproj.props')" />
<Import Project="$(EngineDir)\Source\Programs\Shared\UnrealEngine.csproj.props" /> <Import Project="$(EngineDir)\Source\Programs\Shared\UnrealEngine.csproj.props" />
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<Configuration Condition=" '$(Configuration)' == '' ">Development</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Development</Configuration>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>