2022-09-22 08:56:07 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
using UnityEditorInternal;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2022-10-09 03:25:56 +08:00
|
|
|
|
|
2022-09-22 08:56:07 +08:00
|
|
|
|
namespace HybridCLR.Editor
|
|
|
|
|
{
|
|
|
|
|
public static class SettingsUtil
|
|
|
|
|
{
|
2022-12-02 13:14:06 +08:00
|
|
|
|
public static bool Enable
|
|
|
|
|
{
|
|
|
|
|
get => HybridCLRSettings.Instance.enable;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
HybridCLRSettings.Instance.enable = value;
|
|
|
|
|
HybridCLRSettings.Save();
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-09-22 08:56:07 +08:00
|
|
|
|
|
2023-05-21 10:00:44 +08:00
|
|
|
|
public static string PackageName { get; } = "com.code-philosophy.hybridclr";
|
2022-09-22 08:56:07 +08:00
|
|
|
|
|
2022-09-26 11:54:14 +08:00
|
|
|
|
public static string HybridCLRDataPathInPackage => $"Packages/{PackageName}/Data~";
|
2022-09-22 08:56:07 +08:00
|
|
|
|
|
|
|
|
|
public static string TemplatePathInPackage => $"{HybridCLRDataPathInPackage}/Templates";
|
|
|
|
|
|
|
|
|
|
public static string ProjectDir { get; } = Directory.GetParent(Application.dataPath).ToString();
|
|
|
|
|
|
|
|
|
|
public static string ScriptingAssembliesJsonFile { get; } = "ScriptingAssemblies.json";
|
|
|
|
|
|
2022-10-23 17:46:09 +08:00
|
|
|
|
public static string HotUpdateDllsRootOutputDir => HybridCLRSettings.Instance.hotUpdateDllCompileOutputRootDir;
|
2022-09-22 08:56:07 +08:00
|
|
|
|
|
2022-10-23 17:46:09 +08:00
|
|
|
|
public static string AssembliesPostIl2CppStripDir => HybridCLRSettings.Instance.strippedAOTDllOutputRootDir;
|
2022-09-22 08:56:07 +08:00
|
|
|
|
|
2022-10-23 17:46:09 +08:00
|
|
|
|
public static string HybridCLRDataDir => $"{ProjectDir}/HybridCLRData";
|
2022-09-22 08:56:07 +08:00
|
|
|
|
|
|
|
|
|
public static string LocalUnityDataDir => $"{HybridCLRDataDir}/LocalIl2CppData-{Application.platform}";
|
|
|
|
|
|
|
|
|
|
public static string LocalIl2CppDir => $"{LocalUnityDataDir}/il2cpp";
|
|
|
|
|
|
2022-10-17 21:38:39 +08:00
|
|
|
|
public static string GeneratedCppDir => $"{LocalIl2CppDir}/libil2cpp/hybridclr/generated";
|
2022-09-22 08:56:07 +08:00
|
|
|
|
|
|
|
|
|
public static string Il2CppBuildCacheDir { get; } = $"{ProjectDir}/Library/Il2cppBuildCache";
|
|
|
|
|
|
2022-10-08 12:35:34 +08:00
|
|
|
|
public static string GetHotUpdateDllsOutputDirByTarget(BuildTarget target)
|
2022-09-22 08:56:07 +08:00
|
|
|
|
{
|
2022-10-08 12:35:34 +08:00
|
|
|
|
return $"{HotUpdateDllsRootOutputDir}/{target}";
|
2022-09-22 08:56:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string GetAssembliesPostIl2CppStripDir(BuildTarget target)
|
|
|
|
|
{
|
|
|
|
|
return $"{AssembliesPostIl2CppStripDir}/{target}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class AssemblyDefinitionData
|
|
|
|
|
{
|
|
|
|
|
public string name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2023-01-11 17:41:44 +08:00
|
|
|
|
/// 热更新dll列表。不包含 preserveHotUpdateAssemblies。
|
2022-09-22 08:56:07 +08:00
|
|
|
|
/// </summary>
|
2023-01-11 17:41:44 +08:00
|
|
|
|
public static List<string> HotUpdateAssemblyNamesExcludePreserved
|
2022-09-22 08:56:07 +08:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2022-10-09 20:53:13 +08:00
|
|
|
|
var gs = HybridCLRSettings.Instance;
|
2022-09-22 08:56:07 +08:00
|
|
|
|
var hotfixAssNames = (gs.hotUpdateAssemblyDefinitions ?? Array.Empty<AssemblyDefinitionAsset>()).Select(ad => JsonUtility.FromJson<AssemblyDefinitionData>(ad.text));
|
|
|
|
|
|
|
|
|
|
var hotfixAssembles = new List<string>();
|
|
|
|
|
foreach (var assName in hotfixAssNames)
|
|
|
|
|
{
|
|
|
|
|
hotfixAssembles.Add(assName.name);
|
|
|
|
|
}
|
|
|
|
|
hotfixAssembles.AddRange(gs.hotUpdateAssemblies ?? Array.Empty<string>());
|
|
|
|
|
return hotfixAssembles.ToList();
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-10-18 13:48:43 +08:00
|
|
|
|
|
2023-01-11 17:41:44 +08:00
|
|
|
|
public static List<string> HotUpdateAssemblyFilesExcludePreserved => HotUpdateAssemblyNamesExcludePreserved.Select(dll => dll + ".dll").ToList();
|
2022-09-22 08:56:07 +08:00
|
|
|
|
|
2023-01-11 17:41:44 +08:00
|
|
|
|
|
|
|
|
|
public static List<string> HotUpdateAssemblyNamesIncludePreserved
|
2022-10-18 13:48:43 +08:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2023-01-11 17:41:44 +08:00
|
|
|
|
List<string> allAsses = HotUpdateAssemblyNamesExcludePreserved;
|
2022-10-18 13:48:43 +08:00
|
|
|
|
string[] preserveAssemblyNames = HybridCLRSettings.Instance.preserveHotUpdateAssemblies;
|
|
|
|
|
if (preserveAssemblyNames != null && preserveAssemblyNames.Length > 0)
|
|
|
|
|
{
|
2023-01-11 17:41:44 +08:00
|
|
|
|
foreach (var assemblyName in preserveAssemblyNames)
|
2022-10-18 13:48:43 +08:00
|
|
|
|
{
|
2023-01-11 17:41:44 +08:00
|
|
|
|
if (allAsses.Contains(assemblyName))
|
2022-10-18 13:48:43 +08:00
|
|
|
|
{
|
2023-01-11 17:41:44 +08:00
|
|
|
|
throw new Exception($"[HotUpdateAssemblyNamesIncludePreserved] assembly:'{assemblyName}' 重复");
|
2022-10-18 13:48:43 +08:00
|
|
|
|
}
|
2023-01-11 17:41:44 +08:00
|
|
|
|
allAsses.Add(assemblyName);
|
2022-10-18 13:48:43 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-11 17:41:44 +08:00
|
|
|
|
return allAsses;
|
2022-10-18 13:48:43 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-11 17:41:44 +08:00
|
|
|
|
public static List<string> HotUpdateAssemblyFilesIncludePreserved => HotUpdateAssemblyNamesIncludePreserved.Select(ass => ass + ".dll").ToList();
|
|
|
|
|
|
|
|
|
|
public static List<string> AOTAssemblyNames => HybridCLRSettings.Instance.patchAOTAssemblies.ToList();
|
|
|
|
|
|
2022-10-09 20:53:13 +08:00
|
|
|
|
public static HybridCLRSettings HybridCLRSettings => HybridCLRSettings.Instance;
|
2022-09-22 08:56:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|