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