hybridclr_unity/Editor/Commands/ReversePInvokeWrapperGenera...

32 lines
1.2 KiB
C#
Raw Normal View History

using HybridCLR.Editor.Link;
2022-09-22 08:56:07 +08:00
using HybridCLR.Editor.ReversePInvokeWrap;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using UnityEditor;
using UnityEngine;
namespace HybridCLR.Editor.Commands
{
public static class ReversePInvokeWrapperGeneratorCommand
{
2022-09-23 14:26:28 +08:00
[MenuItem("HybridCLR/Generate/ReversePInvokeWrapper", priority = 103)]
2022-09-22 08:56:07 +08:00
public static void GenerateReversePInvokeWrapper()
{
string ReversePInvokeWrapperStubFile = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/hybridclr/metadata/ReversePInvokeMethodStub.cpp";
string wrapperTemplateStr = AssetDatabase.LoadAssetAtPath<TextAsset>($"{SettingsUtil.TemplatePathInPackage}/ReversePInvokeMethodStub.cpp.txt").text;
int wrapperCount = SettingsUtil.GlobalSettings.ReversePInvokeWrapperCount;
var generator = new Generator();
2022-09-22 08:56:07 +08:00
generator.Generate(wrapperTemplateStr, wrapperCount,ReversePInvokeWrapperStubFile);
Debug.Log($"GenerateReversePInvokeWrapper. wraperCount:{wrapperCount} output:{ReversePInvokeWrapperStubFile}");
MethodBridgeGeneratorCommand.CleanIl2CppBuildCache();
}
}
}