“初始化俯视角工程,带puerts,未编过”

This commit is contained in:
2024-12-01 02:11:25 +08:00
parent 04698dd585
commit 850d76173c
1491 changed files with 271579 additions and 0 deletions
@@ -0,0 +1,162 @@
/*
* Tencent is pleased to support the open source community by making Puerts available.
* Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
* Puerts is licensed under the BSD 3-Clause License, except for the third-party components listed in the file 'LICENSE' which may be subject to their corresponding license terms.
* This file is subject to the terms and conditions defined in file 'LICENSE', which is part of this source code package.
*/
using System;
using EpicGames.UHT.Tables;
using EpicGames.UHT.Types;
using EpicGames.UHT.Utils;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using EpicGames.Core;
namespace CSharpParamDefaultValueMetas
{
[UnrealHeaderTool]
class CSharpParamDefaultValueMetas
{
[UhtExporter(Name = "Puerts", Description = "Puerts Default Values Collector", Options = UhtExporterOptions.Default, ModuleName = "JsEnv")]
private static void UnLuaDefaultParamCollectorUbtPluginExporter(IUhtExportFactory factory)
{
var paramDefaultValueMetas = new CSharpParamDefaultValueMetas(factory);
paramDefaultValueMetas.Generate();
bool bHasGameRuntime = (from package in factory.Session.Packages where package.Module.ModuleType == UHTModuleType.GameRuntime select package).Any();
paramDefaultValueMetas.OutputIfNeeded(bHasGameRuntime);
}
private IUhtExportFactory Factory;
private BorrowStringBuilder BSB;
private StringBuilder GeneratedContentBuilder => BSB.StringBuilder;
public CSharpParamDefaultValueMetas(IUhtExportFactory factory)
{
Factory = factory;
BSB = new BorrowStringBuilder(StringBuilderCache.Big);
}
IEnumerable<UhtType> TraverseTree(UhtType parentNode)
{
yield return parentNode;
if (parentNode.Children != null)
{
foreach (UhtType childNode in parentNode.Children.SelectMany(TraverseTree))
{
yield return childNode;
}
}
}
private void Generate()
{
GeneratedContentBuilder.Append("// Generated By C# UbtPlugin\r\n");
var packages = (from package in Factory.Session.Packages
where (package.Module.ModuleType == UHTModuleType.EngineRuntime || package.Module.ModuleType == UHTModuleType.GameRuntime)
select package);
var classes = packages
.SelectMany(TraverseTree)
.Where(t => t is UhtClass).Cast<UhtClass>()
.Where(c => !c.ClassFlags.HasAnyFlags(EClassFlags.Interface));
classes.Distinct().OrderBy(c => c.SourceName).ToList().ForEach(ExportClass);
}
private void ExportClass(UhtClass uhtClass)
{
bool declared = false;
Action declareOnce = () => {
if (!declared)
{
GeneratedContentBuilder.AppendFormat("PC = &ParamDefaultMetas.Add(TEXT(\"{0}\"));\r\n", uhtClass.EngineName);
declared = true;
}
};
foreach (UhtFunction uhtFunction in uhtClass.Functions.OrderBy(Func => Func.SourceName))
{
if (!uhtFunction.MetaData.IsEmpty())
{
ExportFunction(uhtFunction, declareOnce);
}
}
if (declared)
{
GeneratedContentBuilder.Append("\r\n");
}
}
private static bool TryGetDefaultValue(UhtMetaData metaData, UhtProperty property, out string value)
{
var hasValue = metaData.TryGetValue(property.SourceName, out string? tempValue);
if (!hasValue)
{
var cppKey = "CPP_Default_" + property.SourceName;
hasValue = metaData.TryGetValue(cppKey, out tempValue);
}
value = tempValue ?? string.Empty;
return hasValue;
}
private void ExportFunction(UhtFunction uhtFunction, Action declareClassOnce)
{
bool declared = false;
var properties = uhtFunction.Children
.Where(c => c is UhtProperty)
.Cast<UhtProperty>()
.Where(p => p.PropertyFlags.HasAnyFlags(EPropertyFlags.Parm) && !p.PropertyFlags.HasAnyFlags(EPropertyFlags.ReturnParm));
foreach (var property in properties.OrderBy(Property => Property.SourceName))
{
if (TryGetDefaultValue(uhtFunction.MetaData, property, out string defaultValue))
{
declareClassOnce();
if (!declared)
{
GeneratedContentBuilder.AppendFormat("PF = &PC->Add(TEXT(\"{0}\"));\r\n", uhtFunction.SourceName);
declared = true;
}
string escapeDefaultValue = defaultValue.Replace("\"", "\\\"");
if (property is UhtBoolProperty)
{
escapeDefaultValue = escapeDefaultValue.Replace("true", "True").Replace("false", "False");
}
GeneratedContentBuilder.AppendFormat("PF->Add(TEXT(\"{0}\"), TEXT(\"{1}\"));\r\n", property.SourceName, escapeDefaultValue);
}
}
}
private void OutputIfNeeded(bool bHasGameRuntime)
{
string filePath = Factory.MakePath("InitParamDefaultMetas", ".inl");
if (File.Exists(filePath))
{
var fileContent = File.ReadAllText(filePath);
if (bHasGameRuntime ? (!fileContent.Equals(GeneratedContentBuilder.ToString())) : (fileContent.Length != 0))
{
Factory.CommitOutput(filePath, GeneratedContentBuilder);
}
}
else
{
Factory.CommitOutput(filePath, GeneratedContentBuilder);
}
}
}
}
@@ -0,0 +1,50 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="CSharpParamDefaultValueMetas.ubtplugin.csproj.props" Condition="Exists('CSharpParamDefaultValueMetas.ubtplugin.csproj.props')" />
<Import Project="$(EngineDir)\Source\Programs\Shared\UnrealEngine.csproj.props" />
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Configuration Condition=" '$(Configuration)' == '' ">Development</Configuration>
<OutputType>Library</OutputType>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<Configurations>Debug;Release;Development</Configurations>
<RootNamespace>CSharpParamDefaultValueMetas</RootNamespace>
<AssemblyName>CSharpParamDefaultValueMetas</AssemblyName>
<OutputPath>..\..\..\..\Binaries\DotNET\UnrealBuildTool\Plugins\CSharpParamDefaultValueMetas\</OutputPath>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DebugType>pdbonly</DebugType>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Development|AnyCPU' ">
<DefineConstants>$(DefineConstants);TRACE</DefineConstants>
<Optimize>true</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DefineConstants>$(DefineConstants);TRACE</DefineConstants>
<Optimize>true</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DefineConstants>$(DefineConstants);DEBUG;TRACE</DefineConstants>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="EpicGames.Build">
<HintPath>$(EngineDir)\Binaries\DotNET\UnrealBuildTool\EpicGames.Build.dll</HintPath>
</Reference>
<Reference Include="EpicGames.Core">
<HintPath>$(EngineDir)\Binaries\DotNET\UnrealBuildTool\EpicGames.Core.dll</HintPath>
</Reference>
<Reference Include="EpicGames.UHT">
<HintPath>$(EngineDir)\Binaries\DotNET\UnrealBuildTool\EpicGames.UHT.dll</HintPath>
</Reference>
<Reference Include="UnrealBuildTool">
<HintPath>$(EngineDir)\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<EngineDir Condition="'$(EngineDir)' == ''">D:\MiceCola\UE_5.5\Engine</EngineDir>
</PropertyGroup>
</Project>
@@ -0,0 +1,93 @@
{
"format": 1,
"restore": {
"D:\\MiceCola\\MingSimulator\\Plugins\\Puerts\\Source\\CSharpParamDefaultValueMetas\\CSharpParamDefaultValueMetas.ubtplugin.csproj": {}
},
"projects": {
"D:\\MiceCola\\MingSimulator\\Plugins\\Puerts\\Source\\CSharpParamDefaultValueMetas\\CSharpParamDefaultValueMetas.ubtplugin.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "D:\\MiceCola\\MingSimulator\\Plugins\\Puerts\\Source\\CSharpParamDefaultValueMetas\\CSharpParamDefaultValueMetas.ubtplugin.csproj",
"projectName": "CSharpParamDefaultValueMetas",
"projectPath": "D:\\MiceCola\\MingSimulator\\Plugins\\Puerts\\Source\\CSharpParamDefaultValueMetas\\CSharpParamDefaultValueMetas.ubtplugin.csproj",
"packagesPath": "C:\\Users\\张青\\.nuget\\packages\\",
"outputPath": "D:\\MiceCola\\MingSimulator\\Plugins\\Puerts\\Source\\CSharpParamDefaultValueMetas\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
],
"configFilePaths": [
"C:\\Users\\张青\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net6.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net6.0": {
"targetAlias": "net6.0",
"projectReferences": {}
}
},
"warningProperties": {
"allWarningsAsErrors": true,
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
}
},
"frameworks": {
"net6.0": {
"targetAlias": "net6.0",
"dependencies": {
"Microsoft.CSharp": {
"target": "Package",
"version": "[4.7.0, )"
}
},
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"downloadDependencies": [
{
"name": "Microsoft.AspNetCore.App.Ref",
"version": "[6.0.30, 6.0.30]"
},
{
"name": "Microsoft.NETCore.App.Ref",
"version": "[6.0.30, 6.0.30]"
},
{
"name": "Microsoft.WindowsDesktop.App.Ref",
"version": "[6.0.30, 6.0.30]"
}
],
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "D:\\MiceCola\\UE_5.5\\Engine\\Binaries\\ThirdParty\\DotNet\\8.0.300\\win-x64\\sdk\\8.0.300\\RuntimeIdentifierGraph.json"
}
}
}
}
}
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\张青\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.10.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="C:\Users\张青\.nuget\packages\" />
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
</ItemGroup>
</Project>
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />
@@ -0,0 +1,15 @@
is_global = true
build_property.TargetFramework = net6.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = CSharpParamDefaultValueMetas
build_property.ProjectDir = D:\MiceCola\MingSimulator\Plugins\Puerts\Source\CSharpParamDefaultValueMetas\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
build_property.EffectiveAnalysisLevelStyle = 6.0
build_property.EnableCodeStyleSeverity =
@@ -0,0 +1 @@
acfc2ce6c21e11e243f1beb848c668c5ad8317be9df7ed1ce1347befd4c57e75
@@ -0,0 +1,3 @@
D:\MiceCola\MingSimulator\Plugins\Puerts\Source\CSharpParamDefaultValueMetas\obj\Development\CSharpParamDefaultValueMetas.ubtplugin.csproj.AssemblyReference.cache
D:\MiceCola\MingSimulator\Plugins\Puerts\Source\CSharpParamDefaultValueMetas\obj\Development\CSharpParamDefaultValueMetas.ubtplugin.GeneratedMSBuildEditorConfig.editorconfig
D:\MiceCola\MingSimulator\Plugins\Puerts\Source\CSharpParamDefaultValueMetas\obj\Development\CSharpParamDefaultValueMetas.ubtplugin.csproj.CoreCompileInputs.cache
@@ -0,0 +1,181 @@
{
"version": 3,
"targets": {
"net6.0": {
"Microsoft.CSharp/4.7.0": {
"type": "package",
"compile": {
"ref/netcoreapp2.0/_._": {}
},
"runtime": {
"lib/netcoreapp2.0/_._": {}
}
}
}
},
"libraries": {
"Microsoft.CSharp/4.7.0": {
"sha512": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==",
"type": "package",
"path": "microsoft.csharp/4.7.0",
"files": [
".nupkg.metadata",
".signature.p7s",
"LICENSE.TXT",
"THIRD-PARTY-NOTICES.TXT",
"lib/MonoAndroid10/_._",
"lib/MonoTouch10/_._",
"lib/net45/_._",
"lib/netcore50/Microsoft.CSharp.dll",
"lib/netcoreapp2.0/_._",
"lib/netstandard1.3/Microsoft.CSharp.dll",
"lib/netstandard2.0/Microsoft.CSharp.dll",
"lib/netstandard2.0/Microsoft.CSharp.xml",
"lib/portable-net45+win8+wp8+wpa81/_._",
"lib/uap10.0.16299/_._",
"lib/win8/_._",
"lib/wp80/_._",
"lib/wpa81/_._",
"lib/xamarinios10/_._",
"lib/xamarinmac20/_._",
"lib/xamarintvos10/_._",
"lib/xamarinwatchos10/_._",
"microsoft.csharp.4.7.0.nupkg.sha512",
"microsoft.csharp.nuspec",
"ref/MonoAndroid10/_._",
"ref/MonoTouch10/_._",
"ref/net45/_._",
"ref/netcore50/Microsoft.CSharp.dll",
"ref/netcore50/Microsoft.CSharp.xml",
"ref/netcore50/de/Microsoft.CSharp.xml",
"ref/netcore50/es/Microsoft.CSharp.xml",
"ref/netcore50/fr/Microsoft.CSharp.xml",
"ref/netcore50/it/Microsoft.CSharp.xml",
"ref/netcore50/ja/Microsoft.CSharp.xml",
"ref/netcore50/ko/Microsoft.CSharp.xml",
"ref/netcore50/ru/Microsoft.CSharp.xml",
"ref/netcore50/zh-hans/Microsoft.CSharp.xml",
"ref/netcore50/zh-hant/Microsoft.CSharp.xml",
"ref/netcoreapp2.0/_._",
"ref/netstandard1.0/Microsoft.CSharp.dll",
"ref/netstandard1.0/Microsoft.CSharp.xml",
"ref/netstandard1.0/de/Microsoft.CSharp.xml",
"ref/netstandard1.0/es/Microsoft.CSharp.xml",
"ref/netstandard1.0/fr/Microsoft.CSharp.xml",
"ref/netstandard1.0/it/Microsoft.CSharp.xml",
"ref/netstandard1.0/ja/Microsoft.CSharp.xml",
"ref/netstandard1.0/ko/Microsoft.CSharp.xml",
"ref/netstandard1.0/ru/Microsoft.CSharp.xml",
"ref/netstandard1.0/zh-hans/Microsoft.CSharp.xml",
"ref/netstandard1.0/zh-hant/Microsoft.CSharp.xml",
"ref/netstandard2.0/Microsoft.CSharp.dll",
"ref/netstandard2.0/Microsoft.CSharp.xml",
"ref/portable-net45+win8+wp8+wpa81/_._",
"ref/uap10.0.16299/_._",
"ref/win8/_._",
"ref/wp80/_._",
"ref/wpa81/_._",
"ref/xamarinios10/_._",
"ref/xamarinmac20/_._",
"ref/xamarintvos10/_._",
"ref/xamarinwatchos10/_._",
"useSharedDesignerContext.txt",
"version.txt"
]
}
},
"projectFileDependencyGroups": {
"net6.0": [
"Microsoft.CSharp >= 4.7.0"
]
},
"packageFolders": {
"C:\\Users\\张青\\.nuget\\packages\\": {},
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "D:\\MiceCola\\MingSimulator\\Plugins\\Puerts\\Source\\CSharpParamDefaultValueMetas\\CSharpParamDefaultValueMetas.ubtplugin.csproj",
"projectName": "CSharpParamDefaultValueMetas",
"projectPath": "D:\\MiceCola\\MingSimulator\\Plugins\\Puerts\\Source\\CSharpParamDefaultValueMetas\\CSharpParamDefaultValueMetas.ubtplugin.csproj",
"packagesPath": "C:\\Users\\张青\\.nuget\\packages\\",
"outputPath": "D:\\MiceCola\\MingSimulator\\Plugins\\Puerts\\Source\\CSharpParamDefaultValueMetas\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
],
"configFilePaths": [
"C:\\Users\\张青\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net6.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net6.0": {
"targetAlias": "net6.0",
"projectReferences": {}
}
},
"warningProperties": {
"allWarningsAsErrors": true,
"warnAsError": [
"NU1605"
]
},
"restoreAuditProperties": {
"enableAudit": "true",
"auditLevel": "low",
"auditMode": "direct"
}
},
"frameworks": {
"net6.0": {
"targetAlias": "net6.0",
"dependencies": {
"Microsoft.CSharp": {
"target": "Package",
"version": "[4.7.0, )"
}
},
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48",
"net481"
],
"assetTargetFallback": true,
"warn": true,
"downloadDependencies": [
{
"name": "Microsoft.AspNetCore.App.Ref",
"version": "[6.0.30, 6.0.30]"
},
{
"name": "Microsoft.NETCore.App.Ref",
"version": "[6.0.30, 6.0.30]"
},
{
"name": "Microsoft.WindowsDesktop.App.Ref",
"version": "[6.0.30, 6.0.30]"
}
],
"frameworkReferences": {
"Microsoft.NETCore.App": {
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "D:\\MiceCola\\UE_5.5\\Engine\\Binaries\\ThirdParty\\DotNet\\8.0.300\\win-x64\\sdk\\8.0.300\\RuntimeIdentifierGraph.json"
}
}
}
}
@@ -0,0 +1,13 @@
{
"version": 2,
"dgSpecHash": "+l+ToRTRVP0=",
"success": true,
"projectFilePath": "D:\\MiceCola\\MingSimulator\\Plugins\\Puerts\\Source\\CSharpParamDefaultValueMetas\\CSharpParamDefaultValueMetas.ubtplugin.csproj",
"expectedPackageFiles": [
"C:\\Users\\张青\\.nuget\\packages\\microsoft.csharp\\4.7.0\\microsoft.csharp.4.7.0.nupkg.sha512",
"C:\\Users\\张青\\.nuget\\packages\\microsoft.netcore.app.ref\\6.0.30\\microsoft.netcore.app.ref.6.0.30.nupkg.sha512",
"C:\\Users\\张青\\.nuget\\packages\\microsoft.windowsdesktop.app.ref\\6.0.30\\microsoft.windowsdesktop.app.ref.6.0.30.nupkg.sha512",
"C:\\Users\\张青\\.nuget\\packages\\microsoft.aspnetcore.app.ref\\6.0.30\\microsoft.aspnetcore.app.ref.6.0.30.nupkg.sha512"
],
"logs": []
}