[new] 支持按版本号安装hybridclr和il2cpp_plus代码

main
walon 2022-11-28 12:20:52 +08:00
parent 521db6e38c
commit f36da3529a
6 changed files with 91 additions and 37 deletions

View File

@ -27,9 +27,7 @@ namespace HybridCLR.Editor.Installer
public partial class InstallerController
{
private const string hybridclr_repo_path = "hybridclr_repo";
private const string hybridclr_url = "hybridclr";
private const string il2cpp_plus_repo_path = "il2cpp_plus_repo";
private const string il2cpp_plus_url = "il2cpp_plus";
private string m_Il2CppInstallDirectory;
@ -210,14 +208,14 @@ namespace HybridCLR.Editor.Installer
#endif
}
public void InitHybridCLR(string il2cppBranch, string il2cppInstallPath)
public void InitHybridCLR(string il2cppBranch, string il2cppInstallPath, string hybridclrVer, string il2cppPlusVer)
{
if (CheckValidIl2CppInstallDirectory(il2cppBranch, il2cppInstallPath) != InstallErrorCode.Ok)
{
Debug.LogError($"请正确设置 il2cpp 安装目录");
return;
}
RunInitLocalIl2CppData(il2cppBranch, il2cppInstallPath);
RunInitLocalIl2CppData(il2cppBranch, il2cppInstallPath, hybridclrVer, il2cppPlusVer);
}
public bool HasInstalledHybridCLR()
@ -272,13 +270,7 @@ namespace HybridCLR.Editor.Installer
#endif
}
private static string GetRepoUrl(string repoName)
{
string repoProvider = SettingsUtil.HybridCLRSettings.cloneHomeURL;
return $"{repoProvider}/{repoName}";
}
private void RunInitLocalIl2CppData(string il2cppBranch, string il2cppInstallPath)
private void RunInitLocalIl2CppData(string il2cppBranch, string il2cppInstallPath, string hybridclrVer, string il2cppPlusVer)
{
#if UNITY_EDITOR_WIN
if (!BashUtil.ExistProgram("git"))
@ -296,16 +288,28 @@ namespace HybridCLR.Editor.Installer
BashUtil.CopyDir($"{SettingsUtil.HybridCLRDataPathInPackage}/iOSBuild", buildiOSDir, true);
// clone hybridclr
string hybridclrRepoURL = HybridCLRSettings.Instance.hybridclrRepoURL;
string hybridclrRepoDir = $"{workDir}/{hybridclr_repo_path}";
{
BashUtil.RemoveDir(hybridclrRepoDir);
var ret = BashUtil.RunCommand(workDir, "git", new string[]
string[] args = string.IsNullOrWhiteSpace(hybridclrVer) ? new string[]
{
"clone",
"--depth=1",
GetRepoUrl(hybridclr_url),
hybridclrRepoURL,
hybridclrRepoDir,
});
}
:
new string[]
{
"clone",
"--depth=1",
"-b",
hybridclrVer,
hybridclrRepoURL,
hybridclrRepoDir,
};
var ret = BashUtil.RunCommand(workDir, "git", args);
//if (ret != 0)
//{
// throw new Exception($"git clone 失败");
@ -313,18 +317,31 @@ namespace HybridCLR.Editor.Installer
}
// clone il2cpp_plus
string il2cppPlusRepoURL = HybridCLRSettings.Instance.il2cppPlusRepoURL;
string il2cppPlusRepoDir = $"{workDir}/{il2cpp_plus_repo_path}";
{
BashUtil.RemoveDir(il2cppPlusRepoDir);
var ret = BashUtil.RunCommand(workDir, "git", new string[]
string[] args = string.IsNullOrWhiteSpace(il2cppPlusVer) ?
new string[]
{
"clone",
"--depth=1",
"-b",
il2cppBranch,
GetRepoUrl(il2cpp_plus_url),
il2cppPlusRepoURL,
il2cppPlusRepoDir,
});
}
:
new string[]
{
"clone",
"--depth=1",
"-b",
il2cppPlusVer,
il2cppPlusRepoURL,
il2cppPlusRepoDir,
};
var ret = BashUtil.RunCommand(workDir, "git", args);
//if (ret != 0)
//{
// throw new Exception($"git clone 失败");
@ -367,6 +384,8 @@ namespace HybridCLR.Editor.Installer
if (HasInstalledHybridCLR())
{
Debug.Log("安装成功!");
_hybridclrLocalVersion = hybridclrVer;
_il2cppPlusLocalVersion = il2cppPlusVer;
}
else
{

View File

@ -10,6 +10,9 @@ namespace HybridCLR.Editor.Installer
{
private InstallerController m_Controller;
string _hybridclrVersion = "";
string _il2cppPlusVersion = "";
private void OnEnable()
{
m_Controller = new InstallerController();
@ -30,39 +33,57 @@ namespace HybridCLR.Editor.Installer
{
SettingsService.OpenProjectSettings("Project/HybridCLR Settings");
}
string minCompatibleVersion = m_Controller.GetMinCompatibleVersion(m_Controller.Il2CppBranch);
string il2cppBranch = m_Controller.Il2CppBranch;
string minCompatibleVersion = m_Controller.GetMinCompatibleVersion(il2cppBranch);
GUI.enabled = true;
GUILayout.Space(10f);
EditorGUILayout.LabelField("=======================说明====================");
EditorGUILayout.LabelField(
$"你所在项目的Unity版本可以与il2cpp_plus版本:{m_Controller.Il2CppBranch} 不一样。\n"
$"你所在项目的Unity版本可以与il2cpp_plus版本:{il2cppBranch} 不一样。\n"
+ $"如果你的Unity的版本号 >= {minCompatibleVersion}, 可以直接安装。\n"
+ $"如果你的Unity的版本号 < {minCompatibleVersion}, \n"
+ $"由于安装HybridCLR时需要从il2cpp_plus兼容版本{m_Controller.Il2CppBranch}而不是你项目版本拷贝il2cpp目录\n"
+ $"你必须同时安装兼容版本 {m_Controller.Il2CppBranch} 才能完成安装", EditorStyles.wordWrappedLabel);
+ $"由于安装HybridCLR时需要从il2cpp_plus兼容版本{il2cppBranch}而不是你项目版本拷贝il2cpp目录\n"
+ $"你必须同时安装兼容版本 {il2cppBranch} 才能完成安装", EditorStyles.wordWrappedLabel);
EditorGUILayout.LabelField("==============================================");
GUILayout.Space(10f);
EditorGUILayout.LabelField($"当前Unity版本: {Application.unityVersion}匹配的il2cpp_plus分支: {m_Controller.Il2CppBranch}");
EditorGUILayout.LabelField($"当前Unity版本: {Application.unityVersion}匹配的il2cpp_plus分支: {il2cppBranch}");
GUILayout.Space(5f);
EditorGUILayout.BeginVertical("box");
bool hasInstall = m_Controller.HasInstalledHybridCLR();
EditorGUILayout.LabelField($"安装状态:{(hasInstall ? "" : "")}", EditorStyles.boldLabel);
string hybridclrLocalVersion = m_Controller.HybridclrLocalVersion;
string il2cppPlusLocalVersion = m_Controller.Il2cppPlusLocalVersion;
if (hasInstall)
{
EditorGUILayout.LabelField($"HybridCLR 版本: {m_Controller.GetHybridCLRLocalVersion()}");
EditorGUILayout.LabelField($"HybridCLR 版本: {hybridclrLocalVersion}");
GUILayout.Space(5f);
EditorGUILayout.LabelField($"il2cpp_plus 版本: {m_Controller.GetIl2cppPlusLocalVersion(m_Controller.Il2CppBranch)}");
EditorGUILayout.LabelField($"il2cpp_plus 版本: {il2cppPlusLocalVersion}");
GUILayout.Space(5f);
GUIInstallButton("检查更新", "检查", UpdateHybridCLR);
GUILayout.Space(40f);
//GUIInstallButton("检查更新", "检查", UpdateHybridCLR);
//GUILayout.Space(40f);
}
GUISelectUnityDirectory($"il2cpp_plus分支对应的Unity兼容版本的il2cpp路径", "Select");
GUILayout.Space(10f);
GUIInstallButton("安装最新HybridCLR插件代码到本项目", "安装", InitHybridCLR);
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("待安装的 hybridclr 仓库版本号(或tag)(默认取最新版本):", GUILayout.MaxWidth(400));
_hybridclrVersion = EditorGUILayout.TextField(_hybridclrVersion);
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField($"待安装的 il2cpp_plus 仓库版本号(或tag)(默认取{il2cppBranch}分支最新版本):", GUILayout.MaxWidth(400));
_il2cppPlusVersion = EditorGUILayout.TextField(_il2cppPlusVersion);
EditorGUILayout.EndHorizontal();
GUIInstallButton("安装hybridclr+il2cpp_plus代码到本地目录", "安装", InitHybridCLR);
EditorGUILayout.EndVertical();
}
@ -130,7 +151,7 @@ namespace HybridCLR.Editor.Installer
private void InitHybridCLR()
{
m_Controller.InitHybridCLR(m_Controller.Il2CppBranch, m_Controller.Il2CppInstallDirectory);
m_Controller.InitHybridCLR(m_Controller.Il2CppBranch, m_Controller.Il2CppInstallDirectory, _hybridclrVersion, _il2cppPlusVersion);
}
private void UpdateHybridCLR()

View File

@ -4,7 +4,11 @@ namespace HybridCLR.Editor.Installer
{
public partial class InstallerController
{
public string GetHybridCLRLocalVersion()
private string _hybridclrLocalVersion;
public string HybridclrLocalVersion => _hybridclrLocalVersion ??= GetHybridCLRLocalVersion();
private string GetHybridCLRLocalVersion()
{
string workDir = SettingsUtil.HybridCLRDataDir;
string hybridclrRepoDir = $"{workDir}/{hybridclr_repo_path}";
@ -25,14 +29,18 @@ namespace HybridCLR.Editor.Installer
return "";
}
public string GetIl2cppPlusLocalVersion(string il2cppBranch)
private string _il2cppPlusLocalVersion;
public string Il2cppPlusLocalVersion => _il2cppPlusLocalVersion ??= GetIl2cppPlusLocalVersion();
private string GetIl2cppPlusLocalVersion()
{
string workDir = SettingsUtil.HybridCLRDataDir;
string il2cppPlusRepoDir = $"{workDir}/{il2cpp_plus_repo_path}";
if (Directory.Exists(il2cppPlusRepoDir))
{
var ret = BashUtil.RunCommand2(il2cppPlusRepoDir, "git",
new string[] { "log", $"{il2cppBranch}", "-n", "1", "--pretty=format:\"%H\"", },
new string[] { "log", "HEAD", "-n", "1", "--pretty=format:\"%H\"", },
false);
if (ret.ExitCode == 0)
{

View File

@ -11,7 +11,8 @@ namespace HybridCLR.Editor
private SerializedObject _serializedObject;
private SerializedProperty _enable;
private SerializedProperty _useGlobalIl2cpp;
private SerializedProperty _cloneHomeURL;
private SerializedProperty _hybridclrRepoURL;
private SerializedProperty _il2cppPlusRepoURL;
private SerializedProperty _hotUpdateAssemblyDefinitions;
private SerializedProperty _hotUpdateAssemblies;
private SerializedProperty _preserveHotUpdateAssemblies;
@ -39,7 +40,8 @@ namespace HybridCLR.Editor
_serializedObject = new SerializedObject(setting);
_enable = _serializedObject.FindProperty("enable");
_useGlobalIl2cpp = _serializedObject.FindProperty("useGlobalIl2cpp");
_cloneHomeURL = _serializedObject.FindProperty("cloneHomeURL");
_hybridclrRepoURL = _serializedObject.FindProperty("hybridclrRepoURL");
_il2cppPlusRepoURL = _serializedObject.FindProperty("il2cppPlusRepoURL");
_hotUpdateAssemblyDefinitions = _serializedObject.FindProperty("hotUpdateAssemblyDefinitions");
_hotUpdateAssemblies = _serializedObject.FindProperty("hotUpdateAssemblies");
_preserveHotUpdateAssemblies = _serializedObject.FindProperty("preserveHotUpdateAssemblies");
@ -127,7 +129,8 @@ namespace HybridCLR.Editor
_serializedObject.Update();
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(_enable);
EditorGUILayout.PropertyField(_cloneHomeURL);
EditorGUILayout.PropertyField(_hybridclrRepoURL);
EditorGUILayout.PropertyField(_il2cppPlusRepoURL);
EditorGUILayout.PropertyField(_useGlobalIl2cpp);
EditorGUILayout.PropertyField(_hotUpdateAssemblyDefinitions);
EditorGUILayout.PropertyField(_hotUpdateAssemblies);

View File

@ -11,8 +11,11 @@ namespace HybridCLR.Editor
[Header("使用全局安装的il2cpp")]
public bool useGlobalIl2cpp;
[Header("基准 git clone URL")]
public string cloneHomeURL = "https://gitee.com/focus-creative-games";
[Header("hybridclr 仓库 URL")]
public string hybridclrRepoURL = "https://gitee.com/focus-creative-games/hybridclr";
[Header("il2cpp_plus 仓库 URL")]
public string il2cppPlusRepoURL = "https://gitee.com/focus-creative-games/il2cpp_plus";
[Header("热更新Assembly Definitions")]
public AssemblyDefinitionAsset[] hotUpdateAssemblyDefinitions;

View File

@ -1,6 +1,6 @@
{
"name": "com.focus-creative-games.hybridclr_unity",
"version": "1.0.0",
"version": "1.0.1",
"displayName": "HybridCLR",
"description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR",
"category": "Runtime",