2022-11-09 11:28:09 +08:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
namespace HybridCLR.Editor.Installer
|
2022-10-25 17:26:21 +08:00
|
|
|
|
{
|
|
|
|
|
public partial class InstallerController
|
|
|
|
|
{
|
2022-11-28 12:20:52 +08:00
|
|
|
|
private string _hybridclrLocalVersion;
|
|
|
|
|
|
2022-11-30 09:21:25 +08:00
|
|
|
|
public string HybridclrLocalVersion => _hybridclrLocalVersion != null ? _hybridclrLocalVersion : _hybridclrLocalVersion = GetHybridCLRLocalVersion();
|
2022-11-28 12:20:52 +08:00
|
|
|
|
|
|
|
|
|
private string GetHybridCLRLocalVersion()
|
2022-11-09 11:28:09 +08:00
|
|
|
|
{
|
|
|
|
|
string workDir = SettingsUtil.HybridCLRDataDir;
|
|
|
|
|
string hybridclrRepoDir = $"{workDir}/{hybridclr_repo_path}";
|
|
|
|
|
if (Directory.Exists(hybridclrRepoDir))
|
|
|
|
|
{
|
|
|
|
|
var ret = BashUtil.RunCommand2(hybridclrRepoDir, "git",
|
|
|
|
|
new string[] { "log", "HEAD", "-n", "1", "--pretty=format:\"%H\"", },
|
|
|
|
|
false);
|
|
|
|
|
if (ret.ExitCode == 0)
|
|
|
|
|
{
|
|
|
|
|
return ret.StdOut.Trim();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return "ERROR";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-28 12:20:52 +08:00
|
|
|
|
private string _il2cppPlusLocalVersion;
|
|
|
|
|
|
2022-11-30 09:21:25 +08:00
|
|
|
|
public string Il2cppPlusLocalVersion => _il2cppPlusLocalVersion != null ? _il2cppPlusLocalVersion : _il2cppPlusLocalVersion = GetIl2cppPlusLocalVersion();
|
2022-11-28 12:20:52 +08:00
|
|
|
|
|
|
|
|
|
private string GetIl2cppPlusLocalVersion()
|
2022-11-09 11:28:09 +08:00
|
|
|
|
{
|
|
|
|
|
string workDir = SettingsUtil.HybridCLRDataDir;
|
|
|
|
|
string il2cppPlusRepoDir = $"{workDir}/{il2cpp_plus_repo_path}";
|
|
|
|
|
if (Directory.Exists(il2cppPlusRepoDir))
|
|
|
|
|
{
|
|
|
|
|
var ret = BashUtil.RunCommand2(il2cppPlusRepoDir, "git",
|
2022-11-28 12:20:52 +08:00
|
|
|
|
new string[] { "log", "HEAD", "-n", "1", "--pretty=format:\"%H\"", },
|
2022-11-09 11:28:09 +08:00
|
|
|
|
false);
|
|
|
|
|
if (ret.ExitCode == 0)
|
|
|
|
|
{
|
|
|
|
|
return ret.StdOut.Trim();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return "ERROR";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-25 17:26:21 +08:00
|
|
|
|
public bool HasUpdateIl2Cpp(string il2cppBranch)
|
|
|
|
|
{
|
|
|
|
|
string workDir = SettingsUtil.HybridCLRDataDir;
|
|
|
|
|
// last hash hybridclr
|
|
|
|
|
{
|
2022-10-28 13:52:32 +08:00
|
|
|
|
string hybridclrRepoDir = $"{workDir}/{hybridclr_repo_path}";
|
2022-11-09 11:28:09 +08:00
|
|
|
|
var ret1 = BashUtil.RunCommand2(hybridclrRepoDir, "git", new string[] { "log", "HEAD", "-n", "1", "--pretty=format:\"%H\"", }, false);
|
|
|
|
|
BashUtil.RunCommand2(hybridclrRepoDir, "git", new string[] { "fetch", "--depth=1" }, false);
|
2022-10-25 17:26:21 +08:00
|
|
|
|
var ret2 = BashUtil.RunCommand2(hybridclrRepoDir, "git",
|
2022-11-09 11:28:09 +08:00
|
|
|
|
new string[] { "log", "remotes/origin/HEAD", "-n", "1", "--pretty=format:\"%H\"", }
|
|
|
|
|
, false);
|
2022-10-25 17:26:21 +08:00
|
|
|
|
if (ret1.StdOut != ret2.StdOut)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// last hash il2cpp_plus
|
|
|
|
|
{
|
2022-10-28 13:52:32 +08:00
|
|
|
|
string il2cppPlusRepoDir = $"{workDir}/{il2cpp_plus_repo_path}";
|
2022-10-25 17:26:21 +08:00
|
|
|
|
var ret1 = BashUtil.RunCommand2(il2cppPlusRepoDir, "git",
|
2022-11-09 11:28:09 +08:00
|
|
|
|
new string[] { "log", $"{il2cppBranch}", "-n", "1", "--pretty=format:\"%H\"", }, false);
|
2022-10-28 13:52:32 +08:00
|
|
|
|
BashUtil.RunCommand2(il2cppPlusRepoDir, "git",
|
2022-11-09 11:28:09 +08:00
|
|
|
|
new string[] { "fetch", "--depth=1" }, false);
|
2022-10-25 17:26:21 +08:00
|
|
|
|
var ret2 = BashUtil.RunCommand2(il2cppPlusRepoDir, "git",
|
2022-11-09 11:28:09 +08:00
|
|
|
|
new string[] { "log", $"remotes/origin/{il2cppBranch}", "-n", "1", "--pretty=format:\"%H\"", }, false);
|
2022-10-25 17:26:21 +08:00
|
|
|
|
if (ret1.StdOut != ret2.StdOut)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|