[revert] Revert "[new] support preserve UnityEngine core types when GenerateLinkXml"
This reverts commit 82163d2e50.
main
parent
de7b60695a
commit
b8dd2be1e4
|
|
@ -28,7 +28,7 @@ namespace HybridCLR.Editor.Commands
|
||||||
List<string> hotfixAssemblies = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved;
|
List<string> hotfixAssemblies = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved;
|
||||||
|
|
||||||
var analyzer = new Analyzer(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotfixAssemblies));
|
var analyzer = new Analyzer(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotfixAssemblies));
|
||||||
var refTypes = analyzer.CollectRefs(hotfixAssemblies, !ls.dontPreserveUnityEngineCoreTypesInLinkXml);
|
var refTypes = analyzer.CollectRefs(hotfixAssemblies);
|
||||||
|
|
||||||
Debug.Log($"[LinkGeneratorCommand] hotfix assembly count:{hotfixAssemblies.Count}, ref type count:{refTypes.Count} output:{Application.dataPath}/{ls.outputLinkFile}");
|
Debug.Log($"[LinkGeneratorCommand] hotfix assembly count:{hotfixAssemblies.Count}, ref type count:{refTypes.Count} output:{Application.dataPath}/{ls.outputLinkFile}");
|
||||||
var linkXmlWriter = new LinkXmlWriter();
|
var linkXmlWriter = new LinkXmlWriter();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
@ -22,48 +21,12 @@ namespace HybridCLR.Editor.Link
|
||||||
_resolver = resolver;
|
_resolver = resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HashSet<TypeRef> CollectRefs(List<string> rootAssemblies)
|
||||||
public HashSet<ITypeDefOrRef> CollectRefs(List<string> rootAssemblies, bool includeUnityEngineCoreTypes)
|
|
||||||
{
|
|
||||||
var typeRefs = new HashSet<ITypeDefOrRef>(TypeEqualityComparer.Instance);
|
|
||||||
CollectHotUpdateRefs(rootAssemblies, typeRefs);
|
|
||||||
|
|
||||||
if (includeUnityEngineCoreTypes)
|
|
||||||
{
|
|
||||||
CollectUnityEngineCoreTypes(typeRefs);
|
|
||||||
}
|
|
||||||
return typeRefs;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CollectUnityEngineCoreTypes(HashSet<ITypeDefOrRef> preservedTypes)
|
|
||||||
{
|
|
||||||
Debug.Log("CollectUnityEngineCoreTypes");
|
|
||||||
string unityEngineDllPath = $"{EditorApplication.applicationContentsPath}/Managed/UnityEngine";
|
|
||||||
|
|
||||||
var assCollector = new AssemblyCache(_resolver);
|
|
||||||
foreach (string unityEngineDll in Directory.GetFiles(unityEngineDllPath, "UnityEngine.*.dll", SearchOption.AllDirectories))
|
|
||||||
{
|
|
||||||
// because of bug of unity 2019.4.x, preserving types in this dll will cause crash in android build
|
|
||||||
if (unityEngineDll.EndsWith("UnityEngine.PerformanceReportingModule.dll", StringComparison.InvariantCulture))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ModuleDefMD mod = assCollector.LoadModuleFromFileWithoutCache(unityEngineDll);
|
|
||||||
foreach (TypeDef type in mod.GetTypes())
|
|
||||||
{
|
|
||||||
if (type.Methods.Any(m => m.IsInternalCall || m.IsPinvokeImpl))
|
|
||||||
{
|
|
||||||
preservedTypes.Add(type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CollectHotUpdateRefs(List<string> rootAssemblies, HashSet<ITypeDefOrRef> preservedTypes)
|
|
||||||
{
|
{
|
||||||
var assCollector = new AssemblyCache(_resolver);
|
var assCollector = new AssemblyCache(_resolver);
|
||||||
var rootAssemblyNames = new HashSet<string>(rootAssemblies);
|
var rootAssemblyNames = new HashSet<string>(rootAssemblies);
|
||||||
|
|
||||||
|
var typeRefs = new HashSet<TypeRef>(TypeEqualityComparer.Instance);
|
||||||
foreach (var rootAss in rootAssemblies)
|
foreach (var rootAss in rootAssemblies)
|
||||||
{
|
{
|
||||||
var dnAss = assCollector.LoadModule(rootAss, false);
|
var dnAss = assCollector.LoadModule(rootAss, false);
|
||||||
|
|
@ -76,10 +39,11 @@ namespace HybridCLR.Editor.Link
|
||||||
}
|
}
|
||||||
if (!rootAssemblyNames.Contains(type.DefinitionAssembly.Name.ToString()))
|
if (!rootAssemblyNames.Contains(type.DefinitionAssembly.Name.ToString()))
|
||||||
{
|
{
|
||||||
preservedTypes.Add(type);
|
typeRefs.Add(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return typeRefs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ namespace HybridCLR.Editor.Link
|
||||||
{
|
{
|
||||||
internal class LinkXmlWriter
|
internal class LinkXmlWriter
|
||||||
{
|
{
|
||||||
public void Write(string outputLinkXmlFile, HashSet<ITypeDefOrRef> refTypes)
|
public void Write(string outputLinkXmlFile, HashSet<TypeRef> refTypes)
|
||||||
{
|
{
|
||||||
string parentDir = Directory.GetParent(outputLinkXmlFile).FullName;
|
string parentDir = Directory.GetParent(outputLinkXmlFile).FullName;
|
||||||
Directory.CreateDirectory(parentDir);
|
Directory.CreateDirectory(parentDir);
|
||||||
|
|
|
||||||
|
|
@ -71,13 +71,6 @@ namespace HybridCLR.Editor.Meta
|
||||||
return mod;
|
return mod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModuleDefMD LoadModuleFromFileWithoutCache(string dllPath)
|
|
||||||
{
|
|
||||||
ModuleDefMD mod = ModuleDefMD.Load(File.ReadAllBytes(dllPath), _modCtx);
|
|
||||||
mod.EnableTypeDefFindCache = true;
|
|
||||||
return mod;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadNetStandard()
|
private void LoadNetStandard()
|
||||||
{
|
{
|
||||||
string netstandardDllPath = _assemblyPathResolver.ResolveAssembly("netstandard", false);
|
string netstandardDllPath = _assemblyPathResolver.ResolveAssembly("netstandard", false);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ namespace HybridCLR.Editor.Settings
|
||||||
private SerializedProperty _externalHotUpdateAssembliyDirs;
|
private SerializedProperty _externalHotUpdateAssembliyDirs;
|
||||||
private SerializedProperty _strippedAOTDllOutputRootDir;
|
private SerializedProperty _strippedAOTDllOutputRootDir;
|
||||||
private SerializedProperty _patchAOTAssemblies;
|
private SerializedProperty _patchAOTAssemblies;
|
||||||
private SerializedProperty _dontPreserveUnityEngineCoreTypesInLinkXml;
|
|
||||||
private SerializedProperty _outputLinkFile;
|
private SerializedProperty _outputLinkFile;
|
||||||
private SerializedProperty _outputAOTGenericReferenceFile;
|
private SerializedProperty _outputAOTGenericReferenceFile;
|
||||||
private SerializedProperty _maxGenericReferenceIteration;
|
private SerializedProperty _maxGenericReferenceIteration;
|
||||||
|
|
@ -52,7 +51,6 @@ namespace HybridCLR.Editor.Settings
|
||||||
_externalHotUpdateAssembliyDirs = _serializedObject.FindProperty("externalHotUpdateAssembliyDirs");
|
_externalHotUpdateAssembliyDirs = _serializedObject.FindProperty("externalHotUpdateAssembliyDirs");
|
||||||
_strippedAOTDllOutputRootDir = _serializedObject.FindProperty("strippedAOTDllOutputRootDir");
|
_strippedAOTDllOutputRootDir = _serializedObject.FindProperty("strippedAOTDllOutputRootDir");
|
||||||
_patchAOTAssemblies = _serializedObject.FindProperty("patchAOTAssemblies");
|
_patchAOTAssemblies = _serializedObject.FindProperty("patchAOTAssemblies");
|
||||||
_dontPreserveUnityEngineCoreTypesInLinkXml = _serializedObject.FindProperty("dontPreserveUnityEngineCoreTypesInLinkXml");
|
|
||||||
_outputLinkFile = _serializedObject.FindProperty("outputLinkFile");
|
_outputLinkFile = _serializedObject.FindProperty("outputLinkFile");
|
||||||
_outputAOTGenericReferenceFile = _serializedObject.FindProperty("outputAOTGenericReferenceFile");
|
_outputAOTGenericReferenceFile = _serializedObject.FindProperty("outputAOTGenericReferenceFile");
|
||||||
_maxGenericReferenceIteration = _serializedObject.FindProperty("maxGenericReferenceIteration");
|
_maxGenericReferenceIteration = _serializedObject.FindProperty("maxGenericReferenceIteration");
|
||||||
|
|
@ -142,7 +140,6 @@ namespace HybridCLR.Editor.Settings
|
||||||
EditorGUILayout.PropertyField(_externalHotUpdateAssembliyDirs);
|
EditorGUILayout.PropertyField(_externalHotUpdateAssembliyDirs);
|
||||||
EditorGUILayout.PropertyField(_strippedAOTDllOutputRootDir);
|
EditorGUILayout.PropertyField(_strippedAOTDllOutputRootDir);
|
||||||
EditorGUILayout.PropertyField(_patchAOTAssemblies);
|
EditorGUILayout.PropertyField(_patchAOTAssemblies);
|
||||||
EditorGUILayout.PropertyField(_dontPreserveUnityEngineCoreTypesInLinkXml);
|
|
||||||
EditorGUILayout.PropertyField(_outputLinkFile);
|
EditorGUILayout.PropertyField(_outputLinkFile);
|
||||||
EditorGUILayout.PropertyField(_outputAOTGenericReferenceFile);
|
EditorGUILayout.PropertyField(_outputAOTGenericReferenceFile);
|
||||||
EditorGUILayout.PropertyField(_maxGenericReferenceIteration);
|
EditorGUILayout.PropertyField(_maxGenericReferenceIteration);
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,6 @@ namespace HybridCLR.Editor.Settings
|
||||||
[Tooltip("supplementary metadata assembly names(without .dll suffix)")]
|
[Tooltip("supplementary metadata assembly names(without .dll suffix)")]
|
||||||
public string[] patchAOTAssemblies;
|
public string[] patchAOTAssemblies;
|
||||||
|
|
||||||
[Tooltip("don't preserve UnityEngine core types in link.xml")]
|
|
||||||
public bool dontPreserveUnityEngineCoreTypesInLinkXml;
|
|
||||||
|
|
||||||
[Tooltip("output file of automatic generated link.xml by scanning hot update assemblies")]
|
[Tooltip("output file of automatic generated link.xml by scanning hot update assemblies")]
|
||||||
public string outputLinkFile = "HybridCLRGenerate/link.xml";
|
public string outputLinkFile = "HybridCLRGenerate/link.xml";
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue