[new] Installer支持从本地目录复制改造后的libil2cpp目录
parent
0ccdd424ab
commit
8fd9b2ec82
|
@ -1,6 +1,7 @@
|
||||||
# change logs
|
# change logs
|
||||||
|
|
||||||
|
- 2023.04.29 Installer支持从本地目录复制改造后的libil2cpp
|
||||||
- 2023.03.28 `HybridCLR/Generate/Il2CppDef`生成的代码位置移到`hybridclr/generated`下
|
- 2023.03.28 `HybridCLR/Generate/Il2CppDef`生成的代码位置移到`hybridclr/generated`下
|
||||||
- 2022.8.30 创建
|
- 2022.08.30 创建
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,8 @@ namespace HybridCLR.Editor.Installer
|
||||||
|
|
||||||
public void InstallDefaultHybridCLR()
|
public void InstallDefaultHybridCLR()
|
||||||
{
|
{
|
||||||
RunInitLocalIl2CppData(GetIl2CppPathByContentPath(EditorApplication.applicationContentsPath), _curVersion);
|
string libil2cppDir = PrepareLibil2cppWithHybridclrFromGitRepo();
|
||||||
|
RunInitLocalIl2CppData(GetIl2CppPathByContentPath(EditorApplication.applicationContentsPath), libil2cppDir, _curVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasInstalledHybridCLR()
|
public bool HasInstalledHybridCLR()
|
||||||
|
@ -202,7 +203,37 @@ namespace HybridCLR.Editor.Installer
|
||||||
BashUtil.RunCommand(workDir, "git", new string[] {"clone", "-b", branch, "--depth", "1", repoUrl, repoDir});
|
BashUtil.RunCommand(workDir, "git", new string[] {"clone", "-b", branch, "--depth", "1", repoUrl, repoDir});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RunInitLocalIl2CppData(string editorIl2cppPath, UnityVersion version)
|
private string PrepareLibil2cppWithHybridclrFromGitRepo()
|
||||||
|
{
|
||||||
|
string workDir = SettingsUtil.HybridCLRDataDir;
|
||||||
|
Directory.CreateDirectory(workDir);
|
||||||
|
//BashUtil.RecreateDir(workDir);
|
||||||
|
|
||||||
|
// clone hybridclr
|
||||||
|
string hybridclrRepoURL = HybridCLRSettings.Instance.hybridclrRepoURL;
|
||||||
|
string hybridclrRepoDir = $"{workDir}/{hybridclr_repo_path}";
|
||||||
|
CloneBranch(workDir, hybridclrRepoURL, _curDefaultVersion.hybridclr.branch, hybridclrRepoDir);
|
||||||
|
|
||||||
|
if (!Directory.Exists(hybridclrRepoDir))
|
||||||
|
{
|
||||||
|
throw new Exception($"clone hybridclr fail. url: {hybridclrRepoURL}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// clone il2cpp_plus
|
||||||
|
string il2cppPlusRepoURL = HybridCLRSettings.Instance.il2cppPlusRepoURL;
|
||||||
|
string il2cppPlusRepoDir = $"{workDir}/{il2cpp_plus_repo_path}";
|
||||||
|
CloneBranch(workDir, il2cppPlusRepoURL, _curDefaultVersion.il2cpp_plus.branch, il2cppPlusRepoDir);
|
||||||
|
|
||||||
|
if (!Directory.Exists(il2cppPlusRepoDir))
|
||||||
|
{
|
||||||
|
throw new Exception($"clone il2cpp_plus fail. url: {il2cppPlusRepoDir}");
|
||||||
|
}
|
||||||
|
|
||||||
|
Directory.Move($"{hybridclrRepoDir}/hybridclr", $"{il2cppPlusRepoDir}/libil2cpp/hybridclr");
|
||||||
|
return $"{il2cppPlusRepoDir}/libil2cpp";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RunInitLocalIl2CppData(string editorIl2cppPath, string libil2cppWithHybridclrSourceDir, UnityVersion version)
|
||||||
{
|
{
|
||||||
if (!IsComaptibleVersion())
|
if (!IsComaptibleVersion())
|
||||||
{
|
{
|
||||||
|
@ -217,15 +248,6 @@ namespace HybridCLR.Editor.Installer
|
||||||
BashUtil.RemoveDir(buildiOSDir);
|
BashUtil.RemoveDir(buildiOSDir);
|
||||||
BashUtil.CopyDir($"{SettingsUtil.HybridCLRDataPathInPackage}/iOSBuild", buildiOSDir, true);
|
BashUtil.CopyDir($"{SettingsUtil.HybridCLRDataPathInPackage}/iOSBuild", buildiOSDir, true);
|
||||||
|
|
||||||
// clone hybridclr
|
|
||||||
string hybridclrRepoURL = HybridCLRSettings.Instance.hybridclrRepoURL;
|
|
||||||
string hybridclrRepoDir = $"{workDir}/{hybridclr_repo_path}";
|
|
||||||
CloneBranch(workDir, hybridclrRepoURL, _curDefaultVersion.hybridclr.branch, hybridclrRepoDir);
|
|
||||||
|
|
||||||
// clone il2cpp_plus
|
|
||||||
string il2cppPlusRepoURL = HybridCLRSettings.Instance.il2cppPlusRepoURL;
|
|
||||||
string il2cppPlusRepoDir = $"{workDir}/{il2cpp_plus_repo_path}";
|
|
||||||
CloneBranch(workDir, il2cppPlusRepoURL, _curDefaultVersion.il2cpp_plus.branch, il2cppPlusRepoDir);
|
|
||||||
|
|
||||||
// create LocalIl2Cpp
|
// create LocalIl2Cpp
|
||||||
string localUnityDataDir = SettingsUtil.LocalUnityDataDir;
|
string localUnityDataDir = SettingsUtil.LocalUnityDataDir;
|
||||||
|
@ -239,8 +261,7 @@ namespace HybridCLR.Editor.Installer
|
||||||
|
|
||||||
// replace libil2cpp
|
// replace libil2cpp
|
||||||
string dstLibil2cppDir = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp";
|
string dstLibil2cppDir = $"{SettingsUtil.LocalIl2CppDir}/libil2cpp";
|
||||||
BashUtil.CopyDir($"{il2cppPlusRepoDir}/libil2cpp", dstLibil2cppDir, true);
|
BashUtil.CopyDir($"{libil2cppWithHybridclrSourceDir}", dstLibil2cppDir, true);
|
||||||
BashUtil.CopyDir($"{hybridclrRepoDir}/hybridclr", $"{dstLibil2cppDir}/hybridclr", true);
|
|
||||||
|
|
||||||
// clean Il2cppBuildCache
|
// clean Il2cppBuildCache
|
||||||
BashUtil.RemoveDir($"{SettingsUtil.ProjectDir}/Library/Il2cppBuildCache", true);
|
BashUtil.RemoveDir($"{SettingsUtil.ProjectDir}/Library/Il2cppBuildCache", true);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
@ -10,6 +11,10 @@ namespace HybridCLR.Editor.Installer
|
||||||
{
|
{
|
||||||
private InstallerController _controller;
|
private InstallerController _controller;
|
||||||
|
|
||||||
|
private bool _installFromDir;
|
||||||
|
|
||||||
|
private string _installLibil2cppWithHybridclrSourceDir;
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
_controller = new InstallerController();
|
_controller = new InstallerController();
|
||||||
|
@ -66,6 +71,17 @@ namespace HybridCLR.Editor.Installer
|
||||||
|
|
||||||
private void GUIInstallButton(string content, string button)
|
private void GUIInstallButton(string content, string button)
|
||||||
{
|
{
|
||||||
|
EditorGUILayout.BeginHorizontal();
|
||||||
|
_installFromDir = EditorGUILayout.Toggle("从本地复制libil2cpp", _installFromDir);
|
||||||
|
EditorGUI.BeginDisabledGroup(!_installFromDir);
|
||||||
|
EditorGUILayout.TextField(_installLibil2cppWithHybridclrSourceDir, GUILayout.Width(400));
|
||||||
|
if (GUILayout.Button("选择目录", GUILayout.Width(100)))
|
||||||
|
{
|
||||||
|
_installLibil2cppWithHybridclrSourceDir = EditorUtility.OpenFolderPanel("选择libil2cpp目录", Application.dataPath, "libil2cpp");
|
||||||
|
}
|
||||||
|
EditorGUI.EndDisabledGroup();
|
||||||
|
EditorGUILayout.EndHorizontal();
|
||||||
|
|
||||||
EditorGUILayout.BeginHorizontal();
|
EditorGUILayout.BeginHorizontal();
|
||||||
EditorGUILayout.LabelField(content);
|
EditorGUILayout.LabelField(content);
|
||||||
if (GUILayout.Button(button, GUILayout.Width(100)))
|
if (GUILayout.Button(button, GUILayout.Width(100)))
|
||||||
|
@ -79,6 +95,20 @@ namespace HybridCLR.Editor.Installer
|
||||||
|
|
||||||
private void InstallLocalHybridCLR()
|
private void InstallLocalHybridCLR()
|
||||||
{
|
{
|
||||||
|
if (_installFromDir)
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(_installLibil2cppWithHybridclrSourceDir))
|
||||||
|
{
|
||||||
|
Debug.LogError($"本地libil2cpp复制目录不存在. '{_installLibil2cppWithHybridclrSourceDir}'");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!File.Exists($"{_installLibil2cppWithHybridclrSourceDir}/il2cpp-config.h") || !File.Exists($"{_installLibil2cppWithHybridclrSourceDir}/hybridclr/RuntimeApi.cpp"))
|
||||||
|
{
|
||||||
|
Debug.LogError($"本地libil2cpp不是合法有效的源码目录. '{_installLibil2cppWithHybridclrSourceDir}'");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
_controller.InstallDefaultHybridCLR();
|
_controller.InstallDefaultHybridCLR();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue