[fix]:支持hybridclr与il2cpp_plus仓库更新 (#11)

* fix: Data~文件读取修正

* [fix]:支持hybridclr与il2cpp_plus仓库更新
main
ForeseePretty 2022-10-25 17:26:21 +08:00 committed by GitHub
parent fc5bf86887
commit 1b69c9ca78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 73 additions and 6 deletions

View File

@ -26,6 +26,11 @@ namespace HybridCLR.Editor.Installer
public partial class InstallerController 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; private string m_Il2CppInstallDirectory;
public string Il2CppInstallDirectory public string Il2CppInstallDirectory
@ -295,14 +300,14 @@ namespace HybridCLR.Editor.Installer
BashUtil.CopyDir($"{SettingsUtil.HybridCLRDataPathInPackage}/iOSBuild", buildiOSDir, true); BashUtil.CopyDir($"{SettingsUtil.HybridCLRDataPathInPackage}/iOSBuild", buildiOSDir, true);
// clone hybridclr // clone hybridclr
string hybridclrRepoDir = $"{workDir}/hybridclr_repo"; string hybridclrRepoDir = $"{workDir}/{hybridclr_repo_path}";
{ {
BashUtil.RemoveDir(hybridclrRepoDir); BashUtil.RemoveDir(hybridclrRepoDir);
var ret = BashUtil.RunCommand(workDir, "git", new string[] var ret = BashUtil.RunCommand(workDir, "git", new string[]
{ {
"clone", "clone",
"--depth=1", "--depth=1",
GetRepoUrl("hybridclr"), GetRepoUrl(hybridclr_url),
hybridclrRepoDir, hybridclrRepoDir,
}); });
//if (ret != 0) //if (ret != 0)
@ -312,7 +317,7 @@ namespace HybridCLR.Editor.Installer
} }
// clone il2cpp_plus // clone il2cpp_plus
string il2cppPlusRepoDir = $"{workDir}/il2cpp_plus_repo"; string il2cppPlusRepoDir = $"{workDir}/{il2cpp_plus_repo_path}";
{ {
BashUtil.RemoveDir(il2cppPlusRepoDir); BashUtil.RemoveDir(il2cppPlusRepoDir);
var ret = BashUtil.RunCommand(workDir, "git", new string[] var ret = BashUtil.RunCommand(workDir, "git", new string[]
@ -321,7 +326,7 @@ namespace HybridCLR.Editor.Installer
"--depth=1", "--depth=1",
"-b", "-b",
il2cppBranch, il2cppBranch,
GetRepoUrl("il2cpp_plus"), GetRepoUrl(il2cpp_plus_url),
il2cppPlusRepoDir, il2cppPlusRepoDir,
}); });
//if (ret != 0) //if (ret != 0)

View File

@ -45,7 +45,13 @@ namespace HybridCLR.Editor.Installer
GUILayout.Space(10f); GUILayout.Space(10f);
EditorGUILayout.BeginVertical("box"); EditorGUILayout.BeginVertical("box");
EditorGUILayout.LabelField($"安装状态:{(m_Controller.HasInstalledHybridCLR() ? "" : "")}", EditorStyles.boldLabel); bool hasInstall = m_Controller.HasInstalledHybridCLR();
EditorGUILayout.LabelField($"安装状态:{(hasInstall ? "" : "")}", EditorStyles.boldLabel);
if (hasInstall)
{
GUIInstallButton("检查更新", "检查", UpdateHybridCLR);
}
GUILayout.Space(5f); GUILayout.Space(5f);
EditorGUILayout.LabelField($"当前Unity版本: {Application.unityVersion}匹配的il2cpp_plus分支: {m_Controller.Il2CppBranch}"); EditorGUILayout.LabelField($"当前Unity版本: {Application.unityVersion}匹配的il2cpp_plus分支: {m_Controller.Il2CppBranch}");
GUISelectUnityDirectory($"il2cpp_plus分支对应的Unity兼容版本的il2cpp路径", "Select"); GUISelectUnityDirectory($"il2cpp_plus分支对应的Unity兼容版本的il2cpp路径", "Select");
@ -120,5 +126,22 @@ namespace HybridCLR.Editor.Installer
{ {
m_Controller.InitHybridCLR(m_Controller.Il2CppBranch, m_Controller.Il2CppInstallDirectory); m_Controller.InitHybridCLR(m_Controller.Il2CppBranch, m_Controller.Il2CppInstallDirectory);
} }
private void UpdateHybridCLR()
{
bool hasUpdateIl2Cpp = m_Controller.HasUpdateIl2Cpp(m_Controller.Il2CppBranch);
if (hasUpdateIl2Cpp)
{
bool ret = EditorUtility.DisplayDialog("检查更新", "版本不一致", "更新","取消");
if (ret)
{
InitHybridCLR();
}
}
else
{
EditorUtility.DisplayDialog("检查更新", "暂无更新", "确定");
}
}
} }
} }

View File

@ -0,0 +1,36 @@
namespace HybridCLR.Editor.Installer
{
public partial class InstallerController
{
public bool HasUpdateIl2Cpp(string il2cppBranch)
{
string workDir = SettingsUtil.HybridCLRDataDir;
// last hash hybridclr
string hybridclrRepoDir = $"{workDir}/{hybridclr_repo_path}";
{
var ret1 = BashUtil.RunCommand2(hybridclrRepoDir, "git",
new string[] { "log", "HEAD", "-n", "1", "--pretty=format:\"%H\"", });
var ret2 = BashUtil.RunCommand2(hybridclrRepoDir, "git",
new string[] { "log", "remotes/origin/HEAD", "-n", "1", "--pretty=format:\"%H\"", });
if (ret1.StdOut != ret2.StdOut)
{
return true;
}
}
// last hash il2cpp_plus
string il2cppPlusRepoDir = $"{workDir}/{il2cpp_plus_repo_path}";
{
var ret1 = BashUtil.RunCommand2(il2cppPlusRepoDir, "git",
new string[] { "log", $"{il2cppBranch}", "-n", "1", "--pretty=format:\"%H\"", });
var ret2 = BashUtil.RunCommand2(il2cppPlusRepoDir, "git",
new string[] { "log", $"remotes/origin/{il2cppBranch}", "-n", "1", "--pretty=format:\"%H\"", });
if (ret1.StdOut != ret2.StdOut)
{
return true;
}
}
return false;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 91454a4f0a354d11830642b4d4474d7e
timeCreated: 1665546286