parent
c95b7eaf3b
commit
429845bf9e
|
@ -10,7 +10,7 @@ namespace HybridCLR.Editor.Installer
|
|||
{
|
||||
public static class BashUtil
|
||||
{
|
||||
public static int RunCommand(string workingDir, string program, string[] args)
|
||||
public static int RunCommand(string workingDir, string program, string[] args, bool log = true)
|
||||
{
|
||||
using (Process p = new Process())
|
||||
{
|
||||
|
@ -20,7 +20,10 @@ namespace HybridCLR.Editor.Installer
|
|||
p.StartInfo.CreateNoWindow = true;
|
||||
string argsStr = string.Join(" ", args.Select(arg => "\"" + arg + "\""));
|
||||
p.StartInfo.Arguments = argsStr;
|
||||
UnityEngine.Debug.Log($"[BashUtil] run => {program} {argsStr}");
|
||||
if (log)
|
||||
{
|
||||
UnityEngine.Debug.Log($"[BashUtil] run => {program} {argsStr}");
|
||||
}
|
||||
p.Start();
|
||||
p.WaitForExit();
|
||||
return p.ExitCode;
|
||||
|
@ -28,7 +31,7 @@ namespace HybridCLR.Editor.Installer
|
|||
}
|
||||
|
||||
|
||||
public static (int ExitCode, string StdOut, string StdErr) RunCommand2(string workingDir, string program, string[] args)
|
||||
public static (int ExitCode, string StdOut, string StdErr) RunCommand2(string workingDir, string program, string[] args, bool log = true)
|
||||
{
|
||||
using (Process p = new Process())
|
||||
{
|
||||
|
@ -40,7 +43,10 @@ namespace HybridCLR.Editor.Installer
|
|||
p.StartInfo.RedirectStandardError = true;
|
||||
string argsStr = string.Join(" ", args.Select(arg => "\"" + arg + "\""));
|
||||
p.StartInfo.Arguments = argsStr;
|
||||
UnityEngine.Debug.Log($"[BashUtil] run => {program} {argsStr}");
|
||||
if (log)
|
||||
{
|
||||
UnityEngine.Debug.Log($"[BashUtil] run => {program} {argsStr}");
|
||||
}
|
||||
p.Start();
|
||||
p.WaitForExit();
|
||||
|
||||
|
|
|
@ -274,8 +274,8 @@ namespace HybridCLR.Editor.Installer
|
|||
|
||||
private static string GetRepoUrl(string repoName)
|
||||
{
|
||||
string repoProvider = SettingsUtil.HybridCLRSettings.cloneFromGitee ? "gitee" : "github";
|
||||
return $"https://{repoProvider}.com/focus-creative-games/{repoName}";
|
||||
string repoProvider = SettingsUtil.HybridCLRSettings.cloneHomeURL;
|
||||
return $"{repoProvider}/{repoName}";
|
||||
}
|
||||
|
||||
private void RunInitLocalIl2CppData(string il2cppBranch, string il2cppInstallPath)
|
||||
|
|
|
@ -44,16 +44,22 @@ namespace HybridCLR.Editor.Installer
|
|||
|
||||
GUILayout.Space(10f);
|
||||
|
||||
EditorGUILayout.LabelField($"当前Unity版本: {Application.unityVersion},匹配的il2cpp_plus分支: {m_Controller.Il2CppBranch}");
|
||||
GUILayout.Space(5f);
|
||||
|
||||
EditorGUILayout.BeginVertical("box");
|
||||
bool hasInstall = m_Controller.HasInstalledHybridCLR();
|
||||
EditorGUILayout.LabelField($"安装状态:{(hasInstall ? "已安装" : "未安装")}", EditorStyles.boldLabel);
|
||||
if (hasInstall)
|
||||
{
|
||||
EditorGUILayout.LabelField($"HybridCLR 版本: {m_Controller.GetHybridCLRLocalVersion()}");
|
||||
GUILayout.Space(5f);
|
||||
EditorGUILayout.LabelField($"il2cpp_plus 版本: {m_Controller.GetIl2cppPlusLocalVersion(m_Controller.Il2CppBranch)}");
|
||||
GUILayout.Space(5f);
|
||||
GUIInstallButton("检查更新", "检查", UpdateHybridCLR);
|
||||
GUILayout.Space(40f);
|
||||
}
|
||||
|
||||
GUILayout.Space(5f);
|
||||
EditorGUILayout.LabelField($"当前Unity版本: {Application.unityVersion},匹配的il2cpp_plus分支: {m_Controller.Il2CppBranch}");
|
||||
GUISelectUnityDirectory($"il2cpp_plus分支对应的Unity兼容版本的il2cpp路径", "Select");
|
||||
GUILayout.Space(10f);
|
||||
GUIInstallButton("安装最新HybridCLR插件代码到本项目", "安装", InitHybridCLR);
|
||||
|
|
|
@ -1,19 +1,62 @@
|
|||
namespace HybridCLR.Editor.Installer
|
||||
using System.IO;
|
||||
|
||||
namespace HybridCLR.Editor.Installer
|
||||
{
|
||||
public partial class InstallerController
|
||||
{
|
||||
public string GetHybridCLRLocalVersion()
|
||||
{
|
||||
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 "";
|
||||
}
|
||||
|
||||
public string GetIl2cppPlusLocalVersion(string il2cppBranch)
|
||||
{
|
||||
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\"", },
|
||||
false);
|
||||
if (ret.ExitCode == 0)
|
||||
{
|
||||
return ret.StdOut.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
return "ERROR";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
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\"", });
|
||||
BashUtil.RunCommand2(hybridclrRepoDir, "git",
|
||||
new string[] { "fetch", "--depth=1" });
|
||||
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);
|
||||
var ret2 = BashUtil.RunCommand2(hybridclrRepoDir, "git",
|
||||
new string[] { "log", "remotes/origin/HEAD", "-n", "1", "--pretty=format:\"%H\"", });
|
||||
new string[] { "log", "remotes/origin/HEAD", "-n", "1", "--pretty=format:\"%H\"", }
|
||||
, false);
|
||||
if (ret1.StdOut != ret2.StdOut)
|
||||
{
|
||||
return true;
|
||||
|
@ -23,11 +66,11 @@
|
|||
{
|
||||
string il2cppPlusRepoDir = $"{workDir}/{il2cpp_plus_repo_path}";
|
||||
var ret1 = BashUtil.RunCommand2(il2cppPlusRepoDir, "git",
|
||||
new string[] { "log", $"{il2cppBranch}", "-n", "1", "--pretty=format:\"%H\"", });
|
||||
new string[] { "log", $"{il2cppBranch}", "-n", "1", "--pretty=format:\"%H\"", }, false);
|
||||
BashUtil.RunCommand2(il2cppPlusRepoDir, "git",
|
||||
new string[] { "fetch", "--depth=1" });
|
||||
new string[] { "fetch", "--depth=1" }, false);
|
||||
var ret2 = BashUtil.RunCommand2(il2cppPlusRepoDir, "git",
|
||||
new string[] { "log", $"remotes/origin/{il2cppBranch}", "-n", "1", "--pretty=format:\"%H\"", });
|
||||
new string[] { "log", $"remotes/origin/{il2cppBranch}", "-n", "1", "--pretty=format:\"%H\"", }, false);
|
||||
if (ret1.StdOut != ret2.StdOut)
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace HybridCLR.Editor
|
|||
private SerializedObject _serializedObject;
|
||||
private SerializedProperty _enable;
|
||||
private SerializedProperty _useGlobalIl2cpp;
|
||||
private SerializedProperty _cloneFromGitee;
|
||||
private SerializedProperty _cloneHomeURL;
|
||||
private SerializedProperty _hotUpdateAssemblyDefinitions;
|
||||
private SerializedProperty _hotUpdateAssemblies;
|
||||
private SerializedProperty _preserveHotUpdateAssemblies;
|
||||
|
@ -39,7 +39,7 @@ namespace HybridCLR.Editor
|
|||
_serializedObject = new SerializedObject(setting);
|
||||
_enable = _serializedObject.FindProperty("enable");
|
||||
_useGlobalIl2cpp = _serializedObject.FindProperty("useGlobalIl2cpp");
|
||||
_cloneFromGitee = _serializedObject.FindProperty("cloneFromGitee");
|
||||
_cloneHomeURL = _serializedObject.FindProperty("cloneHomeURL");
|
||||
_hotUpdateAssemblyDefinitions = _serializedObject.FindProperty("hotUpdateAssemblyDefinitions");
|
||||
_hotUpdateAssemblies = _serializedObject.FindProperty("hotUpdateAssemblies");
|
||||
_preserveHotUpdateAssemblies = _serializedObject.FindProperty("preserveHotUpdateAssemblies");
|
||||
|
@ -127,7 +127,7 @@ namespace HybridCLR.Editor
|
|||
_serializedObject.Update();
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(_enable);
|
||||
EditorGUILayout.PropertyField(_cloneFromGitee);
|
||||
EditorGUILayout.PropertyField(_cloneHomeURL);
|
||||
EditorGUILayout.PropertyField(_useGlobalIl2cpp);
|
||||
EditorGUILayout.PropertyField(_hotUpdateAssemblyDefinitions);
|
||||
EditorGUILayout.PropertyField(_hotUpdateAssemblies);
|
||||
|
|
|
@ -11,8 +11,8 @@ namespace HybridCLR.Editor
|
|||
[Header("使用全局安装的il2cpp")]
|
||||
public bool useGlobalIl2cpp;
|
||||
|
||||
[Header("从gitee clone插件代码")]
|
||||
public bool cloneFromGitee = true; // false 则从github上拉取
|
||||
[Header("基准 git clone URL")]
|
||||
public string cloneHomeURL = "https://gitee.com/focus-creative-games";
|
||||
|
||||
[Header("热更新Assembly Definitions")]
|
||||
public AssemblyDefinitionAsset[] hotUpdateAssemblyDefinitions;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "com.focus-creative-games.hybridclr_unity",
|
||||
"version": "0.10.3",
|
||||
"version": "0.10.4",
|
||||
"displayName": "HybridCLR",
|
||||
"description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR",
|
||||
"category": "Runtime",
|
||||
|
|
Loading…
Reference in New Issue