少年修仙传客户端基础资源
hch
2024-06-17 d994c578379d81a7dff0683af034f24e3aaa260e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using HybridCLR.Editor.ABI;
using HybridCLR.Editor.Link;
using HybridCLR.Editor.Meta;
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
    {
 
        [MenuItem("HybridCLR/Generate/ReversePInvokeWrapper", priority = 103)]
 
        public static void CompileAndGenerateReversePInvokeWrapper()
        {
            BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
            CompileDllCommand.CompileDll(target);
            GenerateReversePInvokeWrapper(target);
        }
 
        public static void GenerateReversePInvokeWrapper(BuildTarget target)
        {
            List<string> hotUpdateDlls = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved;
            using (var cache = new AssemblyCache(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotUpdateDlls)))
            {
                var analyzer = new ReversePInvokeWrap.Analyzer(cache, hotUpdateDlls);
                analyzer.Run();
 
                string outputFile = $"{SettingsUtil.GeneratedCppDir}/ReversePInvokeMethodStub.cpp";
 
                List<ABIReversePInvokeMethodInfo> methods = analyzer.BuildABIMethods();
                Debug.Log($"GenerateReversePInvokeWrapper. wraperCount:{methods.Sum(m => m.Count)} output:{outputFile}");
                var generator = new Generator();
                generator.Generate(methods, outputFile);
                Debug.LogFormat("[ReversePInvokeWrapperGeneratorCommand] output:{0}", outputFile);
            }
            MethodBridgeGeneratorCommand.CleanIl2CppBuildCache();
        }
    }
}