2023-10-19 15:00:19 +08:00
|
|
|
|
using System;
|
2024-05-15 17:15:25 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEditor;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
using HybridCLR.Editor.Commands;
|
2024-02-26 12:58:19 +08:00
|
|
|
|
using PhxhSDK.AOT.VersionUpdate;
|
2024-05-15 17:15:25 +08:00
|
|
|
|
using Debug = UnityEngine.Debug;
|
|
|
|
|
|
using System.Collections.Generic;
|
2024-08-12 12:52:59 +08:00
|
|
|
|
using AutoBuild.Helper;
|
2024-05-15 17:15:25 +08:00
|
|
|
|
using HybridCLR.Editor.Installer;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
using UnityEditor.SceneManagement;
|
|
|
|
|
|
using BuildTarget = UnityEditor.BuildTarget;
|
2024-08-21 17:45:27 +08:00
|
|
|
|
using HybridCLR.Editor.HotUpdate;
|
|
|
|
|
|
using HybridCLR.Editor;
|
|
|
|
|
|
using System.IO;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
|
2024-05-15 17:15:25 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 编辑器下打包
|
|
|
|
|
|
/// </summary>
|
2023-10-19 15:00:19 +08:00
|
|
|
|
class BuildLauncher
|
|
|
|
|
|
{
|
|
|
|
|
|
private const string HybirdCLRGenerateDir = "/HybridCLRGenerate";
|
2023-11-27 19:53:34 +08:00
|
|
|
|
private const string HybirdCLRGenerateLinkPath = "Assets/HybridCLRGenerate/link.xml";
|
2023-11-07 19:07:35 +08:00
|
|
|
|
private const string GameLauncherSceneName = "Assets/Scenes/GameLauncher.unity";
|
2023-11-23 14:44:42 +08:00
|
|
|
|
|
2024-05-15 17:15:25 +08:00
|
|
|
|
//"/var/www/html/nld/Build/$WORKSPACE/$PLATFORM/$VERSION"
|
|
|
|
|
|
private const string RemotePath = "/var/www/html/nld/Build/{0}/{1}/{2}";
|
2024-05-15 18:38:52 +08:00
|
|
|
|
private const string RemoteHost = "132.232.113.98";
|
|
|
|
|
|
private const string RemoteUser = "root";
|
2023-11-23 14:44:42 +08:00
|
|
|
|
|
2024-05-15 17:15:25 +08:00
|
|
|
|
private static bool enableHotUpdate;
|
|
|
|
|
|
private static bool hasYooAsset = true;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
|
2024-05-15 17:15:25 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 开启热更
|
|
|
|
|
|
/// </summary>
|
2023-11-07 19:07:35 +08:00
|
|
|
|
public static void SetEnableHotUpdate(bool isEnable)
|
2023-10-19 15:00:19 +08:00
|
|
|
|
{
|
2023-11-07 19:07:35 +08:00
|
|
|
|
Debug.Log($"是否开启热更新:{isEnable}");
|
|
|
|
|
|
var gameLauncherScene = EditorSceneManager.OpenScene(GameLauncherSceneName, OpenSceneMode.Additive);
|
|
|
|
|
|
if (!gameLauncherScene.IsValid())
|
2023-10-19 15:00:19 +08:00
|
|
|
|
{
|
2023-11-07 19:07:35 +08:00
|
|
|
|
Debug.LogError($"无法加载场景{GameLauncherSceneName}");
|
|
|
|
|
|
return;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
}
|
2024-05-15 17:15:25 +08:00
|
|
|
|
|
2023-11-07 19:07:35 +08:00
|
|
|
|
var gameLauncher = UnityEngine.Object.FindObjectOfType<GameLauncher>();
|
|
|
|
|
|
if (gameLauncher == null)
|
2023-10-19 15:00:19 +08:00
|
|
|
|
{
|
2023-11-07 19:07:35 +08:00
|
|
|
|
Debug.LogError("找不到GameLauncher");
|
|
|
|
|
|
return;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
}
|
2024-05-15 17:15:25 +08:00
|
|
|
|
|
2023-11-07 19:07:35 +08:00
|
|
|
|
gameLauncher.enableHotUpdate = isEnable;
|
|
|
|
|
|
EditorSceneManager.MarkSceneDirty(gameLauncherScene);
|
|
|
|
|
|
EditorSceneManager.SaveScene(gameLauncherScene);
|
|
|
|
|
|
EditorSceneManager.CloseScene(gameLauncherScene, false);
|
|
|
|
|
|
HybridCLR.Editor.SettingsUtil.Enable = isEnable;
|
2023-11-27 19:53:34 +08:00
|
|
|
|
if (!isEnable)
|
|
|
|
|
|
{
|
|
|
|
|
|
//删除HybirdCLR生成的link文件
|
|
|
|
|
|
AssetDatabase.DeleteAsset(HybirdCLRGenerateLinkPath);
|
|
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
|
}
|
2024-05-15 17:15:25 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 构建热更
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static void BuildHotUpdateDlls()
|
|
|
|
|
|
{
|
|
|
|
|
|
var controller = new InstallerController();
|
|
|
|
|
|
if (!controller.HasInstalledHybridCLR())
|
|
|
|
|
|
controller.InstallDefaultHybridCLR();
|
|
|
|
|
|
BuildUtils.SetFileReadable(Application.dataPath + HybirdCLRGenerateDir);
|
|
|
|
|
|
PrebuildCommand.GenerateAll();
|
|
|
|
|
|
HotUpadeEditorHelper.CopyHotUpdateDll();
|
|
|
|
|
|
HotUpadeEditorHelper.CopyMetaDataDll();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 打包面板初始化
|
|
|
|
|
|
/// </summary>
|
2024-08-12 12:52:59 +08:00
|
|
|
|
public static void Init(BuildTarget buildTarget,
|
|
|
|
|
|
string workSpace,
|
|
|
|
|
|
string appVersion,
|
|
|
|
|
|
string profileName,
|
2024-05-15 17:15:25 +08:00
|
|
|
|
bool developmentBuild,
|
|
|
|
|
|
bool hotUpdate)
|
|
|
|
|
|
{
|
|
|
|
|
|
EditorUserBuildSettings.development = developmentBuild;
|
|
|
|
|
|
YooAssetBuildBase.BuildTargetPlatform = buildTarget;
|
|
|
|
|
|
YooAssetBuildBase.profileName = profileName;
|
|
|
|
|
|
YooAssetBuildBase.JudgmentPlatform(buildTarget.ToString());
|
|
|
|
|
|
YooAssetBuildBase.workSpace = string.IsNullOrEmpty(workSpace) ? "WorkSpace" : workSpace;
|
|
|
|
|
|
PlayerSettings.bundleVersion = appVersion;
|
|
|
|
|
|
YooAssetBuildBase.appVersion = appVersion;
|
|
|
|
|
|
enableHotUpdate = hotUpdate;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-21 17:04:32 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 编辑器下构建资源
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static void BuildResource()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (hasYooAsset)
|
|
|
|
|
|
{
|
|
|
|
|
|
var info = new UpdateLocalInfo();
|
|
|
|
|
|
info.workSpace = YooAssetBuildBase.workSpace;
|
|
|
|
|
|
info.version = YooAssetBuildBase.appVersion;
|
2024-09-26 12:56:47 +08:00
|
|
|
|
info.isOss = YooAssetBuildBase.isOss;
|
2024-08-08 13:44:12 +08:00
|
|
|
|
info.buildTicks = DateTime.Now.Ticks;
|
2024-05-21 17:04:32 +08:00
|
|
|
|
PackDataInst.CreateResourceJson(info);
|
|
|
|
|
|
|
2024-08-12 12:52:59 +08:00
|
|
|
|
ExtBuildInfoHelper.CreateFirstExtBuildInfo(info.buildTicks, info.workSpace, info.version);
|
2024-05-21 17:04:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SetEnableHotUpdate(enableHotUpdate);
|
|
|
|
|
|
if (enableHotUpdate)
|
|
|
|
|
|
{
|
|
|
|
|
|
BuildHotUpdateDlls();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
YooAssetBuildBase.BuildResourceInEditor();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-15 17:15:25 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 编辑器下构建资源和Player
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static void BuildResourceAndPlayer()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (hasYooAsset)
|
|
|
|
|
|
{
|
|
|
|
|
|
var info = new UpdateLocalInfo();
|
|
|
|
|
|
info.workSpace = YooAssetBuildBase.workSpace;
|
|
|
|
|
|
info.version = YooAssetBuildBase.appVersion;
|
2024-09-26 12:56:47 +08:00
|
|
|
|
info.isOss = YooAssetBuildBase.isOss;
|
2024-08-08 13:44:12 +08:00
|
|
|
|
info.buildTicks = DateTime.Now.Ticks;
|
2024-05-15 17:15:25 +08:00
|
|
|
|
PackDataInst.CreateResourceJson(info);
|
|
|
|
|
|
|
2024-08-12 12:52:59 +08:00
|
|
|
|
ExtBuildInfoHelper.CreateFirstExtBuildInfo(info.buildTicks, info.workSpace, info.version);
|
2024-05-15 17:15:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SetEnableHotUpdate(enableHotUpdate);
|
|
|
|
|
|
if (enableHotUpdate)
|
|
|
|
|
|
{
|
|
|
|
|
|
BuildHotUpdateDlls();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
YooAssetBuildBase.BuildContentAndPlayerInEditor(RemoteUser, RemoteHost, RemotePath);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 只构建Player
|
|
|
|
|
|
/// </summary>
|
2024-08-12 12:52:59 +08:00
|
|
|
|
public static void BuildPlayer(BuildTarget buildTarget,
|
|
|
|
|
|
bool isDev = false)
|
2024-05-15 17:15:25 +08:00
|
|
|
|
{
|
|
|
|
|
|
YooAssetBuildBase.BuildPlayerInEditor();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-05-15 18:38:52 +08:00
|
|
|
|
/// 编辑器下热更
|
2024-05-15 17:15:25 +08:00
|
|
|
|
/// </summary>
|
2024-08-12 12:52:59 +08:00
|
|
|
|
public static void UpdatePreviousBuild(string workSpace,
|
|
|
|
|
|
string version,
|
|
|
|
|
|
BuildTarget buildTarget)
|
2023-10-19 15:00:19 +08:00
|
|
|
|
{
|
2024-05-15 18:38:52 +08:00
|
|
|
|
try
|
2023-11-28 13:00:46 +08:00
|
|
|
|
{
|
2024-05-15 18:38:52 +08:00
|
|
|
|
if (enableHotUpdate)
|
|
|
|
|
|
BuildHotUpdateDlls();
|
|
|
|
|
|
YooAssetBuildBase.BuildOnlyResUpdate();
|
|
|
|
|
|
YooAssetBuildBase.UploadToServerYooAsset(workSpace, version, buildTarget, RemoteUser, RemoteHost,
|
|
|
|
|
|
RemotePath);
|
2023-11-28 13:00:46 +08:00
|
|
|
|
}
|
2024-05-15 18:38:52 +08:00
|
|
|
|
catch (Exception e)
|
2023-10-19 15:00:19 +08:00
|
|
|
|
{
|
2024-05-15 18:38:52 +08:00
|
|
|
|
DebugUtil.LogError($"[Build Exception]:{e.Message} \r\n {e.StackTrace}");
|
|
|
|
|
|
throw;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-15 17:15:25 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Jenkins打包
|
|
|
|
|
|
/// </summary>
|
2023-10-19 15:00:19 +08:00
|
|
|
|
internal class BatchBuild
|
|
|
|
|
|
{
|
2024-04-12 18:06:06 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 批处理更新设置
|
|
|
|
|
|
/// jenkins打包新包时使用该方法
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static void ApplyPlayerSetting()
|
|
|
|
|
|
{
|
2024-05-15 17:15:25 +08:00
|
|
|
|
YooAssetBuildBase.Init();
|
2023-10-19 15:00:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-02-26 17:54:26 +08:00
|
|
|
|
private static string _oldDefines;
|
2024-05-15 17:15:25 +08:00
|
|
|
|
|
2024-09-26 16:35:41 +08:00
|
|
|
|
/// <summary>
|
2024-09-27 17:11:55 +08:00
|
|
|
|
/// 只在DEBUG下有
|
2024-09-26 16:35:41 +08:00
|
|
|
|
/// </summary>
|
2024-09-27 17:11:55 +08:00
|
|
|
|
private const string DEBUG = "DEBUG";
|
|
|
|
|
|
private const string DefineListKey = "Define_list:";
|
2024-07-31 14:20:52 +08:00
|
|
|
|
private const string PackageNameKey = "PackageName:";
|
2024-09-27 15:30:51 +08:00
|
|
|
|
private const string CRASH_SIGHT_KEY_ANDROID = "CrashSight_Android:";
|
|
|
|
|
|
private const string CRASH_SIGHT_KEY_IOS = "CrashSight_iOS:";
|
2024-07-31 14:20:52 +08:00
|
|
|
|
private const string NewPlayerSettingsPath = "/../PlayerSettings.txt";
|
|
|
|
|
|
|
|
|
|
|
|
//[MenuItem("Tools/Modify Settings from Text File")]
|
2024-02-26 17:54:26 +08:00
|
|
|
|
private static void _InitScriptDefines()
|
2023-10-19 15:00:19 +08:00
|
|
|
|
{
|
2024-02-26 17:54:26 +08:00
|
|
|
|
var hasYooAsset = false;
|
|
|
|
|
|
// 判断本地是否有define_list.txt文件
|
2024-08-13 19:36:33 +08:00
|
|
|
|
string filePath = Application.dataPath + NewPlayerSettingsPath;
|
|
|
|
|
|
List<string> appendDefineList = new();
|
2024-09-27 17:11:55 +08:00
|
|
|
|
if (EditorUserBuildSettings.development)
|
|
|
|
|
|
{
|
|
|
|
|
|
appendDefineList.Add(DEBUG);
|
|
|
|
|
|
Debug.Log("追加宏定义:" + DEBUG);
|
|
|
|
|
|
}
|
2024-08-19 13:32:23 +08:00
|
|
|
|
|
2024-07-31 14:20:52 +08:00
|
|
|
|
string newPackageName = "";
|
2024-08-21 17:45:27 +08:00
|
|
|
|
if (System.IO.File.Exists(filePath))
|
2023-11-23 14:41:25 +08:00
|
|
|
|
{
|
2024-08-13 19:36:33 +08:00
|
|
|
|
string fileContents = System.IO.File.ReadAllText(filePath);
|
2024-07-31 14:20:52 +08:00
|
|
|
|
string[] lines = fileContents.Split('\n');
|
|
|
|
|
|
|
2024-08-13 19:36:33 +08:00
|
|
|
|
foreach (string line in lines)
|
2023-11-23 14:41:25 +08:00
|
|
|
|
{
|
2024-07-31 14:20:52 +08:00
|
|
|
|
if (line.StartsWith(DefineListKey))
|
2024-01-24 13:18:47 +08:00
|
|
|
|
{
|
2024-07-31 14:20:52 +08:00
|
|
|
|
// 解析宏定义
|
2024-08-13 19:36:33 +08:00
|
|
|
|
string definePart = line[DefineListKey.Length..].Trim(); // 去掉 "definde:" 后的部分
|
2024-07-31 14:20:52 +08:00
|
|
|
|
string[] defines = definePart.Split(',');
|
|
|
|
|
|
|
2024-09-26 16:35:41 +08:00
|
|
|
|
foreach (string define in defines)
|
|
|
|
|
|
{
|
|
|
|
|
|
string cleanDefine = define.Trim(new char[]
|
|
|
|
|
|
{
|
|
|
|
|
|
'"', ' ',
|
|
|
|
|
|
'\r', '\n'
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(cleanDefine))
|
|
|
|
|
|
{
|
|
|
|
|
|
appendDefineList.Add(cleanDefine);
|
|
|
|
|
|
Debug.Log("追加宏定义:" + cleanDefine);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-08-13 19:36:33 +08:00
|
|
|
|
|
2024-07-31 14:20:52 +08:00
|
|
|
|
else if (line.StartsWith(PackageNameKey))
|
|
|
|
|
|
{
|
|
|
|
|
|
// 解析包名
|
2024-08-13 19:36:33 +08:00
|
|
|
|
int prefixLength = PackageNameKey.Length;
|
|
|
|
|
|
newPackageName = line[prefixLength..].Trim();
|
2024-07-31 14:20:52 +08:00
|
|
|
|
Debug.Log("设置新包名:" + newPackageName);
|
2024-01-24 13:18:47 +08:00
|
|
|
|
}
|
2024-09-27 15:05:11 +08:00
|
|
|
|
|
2024-09-27 15:30:51 +08:00
|
|
|
|
else if (line.StartsWith(CRASH_SIGHT_KEY_ANDROID))
|
2024-09-27 15:05:11 +08:00
|
|
|
|
{
|
|
|
|
|
|
Debug.Log("检测到CrashSight配置:" + line);
|
2024-09-27 15:30:51 +08:00
|
|
|
|
// 判断当前打包平台
|
|
|
|
|
|
if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.Android)
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.LogError("当前打包平台不是Android,无法设置CrashSight配置");
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
// CrashSight: id, key
|
|
|
|
|
|
string crashSightPart = line[CRASH_SIGHT_KEY_ANDROID.Length..].Trim();
|
|
|
|
|
|
string[] crashSight = crashSightPart.Split(',');
|
|
|
|
|
|
var crashSightData = new PhxhSDK.Data.CrashSightData
|
|
|
|
|
|
{
|
|
|
|
|
|
id = crashSight[0].Trim(),
|
|
|
|
|
|
key = crashSight[1].Trim()
|
|
|
|
|
|
};
|
|
|
|
|
|
// 保存到Resources
|
|
|
|
|
|
var crashSightPath = "Assets/Resources/CrashSightData.json";
|
|
|
|
|
|
var json = JsonUtility.ToJson(crashSightData);
|
|
|
|
|
|
System.IO.File.WriteAllText(crashSightPath, json);
|
|
|
|
|
|
|
|
|
|
|
|
Debug.Log("CrashSight配置已保存:" + crashSightData.id + "|" + crashSightData.key);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
else if (line.StartsWith(CRASH_SIGHT_KEY_IOS))
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.Log("检测到CrashSight配置:" + line);
|
|
|
|
|
|
// 判断当前打包平台
|
|
|
|
|
|
if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.iOS)
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.LogError("当前打包平台不是iOS,无法设置CrashSight配置");
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2024-09-27 15:05:11 +08:00
|
|
|
|
// CrashSight: id, key
|
2024-09-27 15:30:51 +08:00
|
|
|
|
string crashSightPart = line[CRASH_SIGHT_KEY_IOS.Length..].Trim();
|
2024-09-27 15:05:11 +08:00
|
|
|
|
string[] crashSight = crashSightPart.Split(',');
|
|
|
|
|
|
var crashSightData = new PhxhSDK.Data.CrashSightData
|
|
|
|
|
|
{
|
|
|
|
|
|
id = crashSight[0].Trim(),
|
|
|
|
|
|
key = crashSight[1].Trim()
|
|
|
|
|
|
};
|
|
|
|
|
|
// 保存到Resources
|
|
|
|
|
|
var crashSightPath = "Assets/Resources/CrashSightData.json";
|
|
|
|
|
|
var json = JsonUtility.ToJson(crashSightData);
|
|
|
|
|
|
System.IO.File.WriteAllText(crashSightPath, json);
|
|
|
|
|
|
|
|
|
|
|
|
Debug.Log("CrashSight配置已保存:" + crashSightData.id + "|" + crashSightData.key);
|
|
|
|
|
|
}
|
2023-11-23 14:41:25 +08:00
|
|
|
|
}
|
2024-02-26 17:54:26 +08:00
|
|
|
|
}
|
2024-01-24 13:18:47 +08:00
|
|
|
|
|
2024-02-26 17:54:26 +08:00
|
|
|
|
var currentTargetGroup = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget);
|
|
|
|
|
|
var oldDefines = PlayerSettings.GetScriptingDefineSymbolsForGroup(currentTargetGroup);
|
|
|
|
|
|
_oldDefines = oldDefines;
|
|
|
|
|
|
// 判断是否有需要追加的宏
|
|
|
|
|
|
if (appendDefineList.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
var newDefineList = new List<string>();
|
|
|
|
|
|
newDefineList.AddRange(oldDefines.Split(';'));
|
|
|
|
|
|
for (var i = 0; i < newDefineList.Count; i++)
|
2024-01-24 13:18:47 +08:00
|
|
|
|
{
|
2024-02-26 17:54:26 +08:00
|
|
|
|
var define = newDefineList[i];
|
|
|
|
|
|
if (string.IsNullOrEmpty(define))
|
|
|
|
|
|
continue;
|
|
|
|
|
|
if (define == "USE_YOO")
|
2024-01-24 13:18:47 +08:00
|
|
|
|
{
|
2024-02-26 17:54:26 +08:00
|
|
|
|
hasYooAsset = true;
|
2024-01-24 13:18:47 +08:00
|
|
|
|
}
|
2024-05-15 17:15:25 +08:00
|
|
|
|
|
2024-02-26 17:54:26 +08:00
|
|
|
|
if (appendDefineList.Contains(define))
|
|
|
|
|
|
appendDefineList.Remove(define);
|
2024-01-24 13:18:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-02-26 17:54:26 +08:00
|
|
|
|
newDefineList.AddRange(appendDefineList);
|
|
|
|
|
|
PlayerSettings.SetScriptingDefineSymbolsForGroup(currentTargetGroup, string.Join(";", newDefineList));
|
|
|
|
|
|
}
|
2024-07-31 14:20:52 +08:00
|
|
|
|
//只有安卓平台下修改
|
|
|
|
|
|
if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android && !string.IsNullOrEmpty(newPackageName))
|
|
|
|
|
|
{
|
|
|
|
|
|
PlayerSettings.applicationIdentifier = newPackageName;
|
|
|
|
|
|
//PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, newPackageName);
|
|
|
|
|
|
}
|
2024-05-15 17:15:25 +08:00
|
|
|
|
|
2024-02-27 15:56:29 +08:00
|
|
|
|
// 现已修改为使用YooAsset
|
2024-02-26 17:54:26 +08:00
|
|
|
|
}
|
2024-05-15 17:15:25 +08:00
|
|
|
|
|
2024-02-26 17:54:26 +08:00
|
|
|
|
private static void _RevertScriptDefines()
|
|
|
|
|
|
{
|
|
|
|
|
|
var currentTargetGroup = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget);
|
|
|
|
|
|
PlayerSettings.SetScriptingDefineSymbolsForGroup(currentTargetGroup, _oldDefines);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2024-05-15 17:15:25 +08:00
|
|
|
|
/// 批处理构建Resources和Player
|
2024-02-26 17:54:26 +08:00
|
|
|
|
/// jenkins打包新包时使用该方法
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static void BuildContentAndPlayer()
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
_InitScriptDefines();
|
|
|
|
|
|
|
2024-05-15 17:15:25 +08:00
|
|
|
|
var enableHotUpdate = YooAssetBuildBase.Init();
|
2024-02-26 12:58:19 +08:00
|
|
|
|
|
2024-08-12 12:52:59 +08:00
|
|
|
|
// 写入版本信息到Resources/LocalInfo.json
|
2024-09-25 13:51:04 +08:00
|
|
|
|
UpdateLocalInfo info = new()
|
|
|
|
|
|
{
|
|
|
|
|
|
workSpace = YooAssetBuildBase.workSpace,
|
|
|
|
|
|
version = YooAssetBuildBase.appVersion,
|
2024-09-26 12:56:47 +08:00
|
|
|
|
isOss = YooAssetBuildBase.isOss,
|
2024-09-25 13:51:04 +08:00
|
|
|
|
buildTicks = DateTime.Now.Ticks
|
|
|
|
|
|
};
|
2024-08-12 12:52:59 +08:00
|
|
|
|
PackDataInst.CreateResourceJson(info);
|
|
|
|
|
|
|
|
|
|
|
|
// 写入打包信息到Yoo_Build_Cache
|
|
|
|
|
|
ExtBuildInfoHelper.CreateFirstExtBuildInfo(info.buildTicks, info.workSpace, info.version);
|
2024-05-15 17:15:25 +08:00
|
|
|
|
|
2024-01-24 13:18:47 +08:00
|
|
|
|
BuildLauncher.SetEnableHotUpdate(enableHotUpdate);
|
|
|
|
|
|
if (enableHotUpdate)
|
|
|
|
|
|
BuildLauncher.BuildHotUpdateDlls();
|
|
|
|
|
|
|
2024-05-15 17:15:25 +08:00
|
|
|
|
YooAssetBuildBase.BuildContentAndPlayer();
|
2024-09-02 13:32:23 +08:00
|
|
|
|
|
|
|
|
|
|
// 写入打包信息到Yoo_Build_Cache
|
|
|
|
|
|
ExtBuildInfoHelper.CreateVertifyBuildInfo(info.workSpace, info.version);
|
2024-01-24 13:18:47 +08:00
|
|
|
|
|
|
|
|
|
|
// 还原宏
|
2024-02-26 17:54:26 +08:00
|
|
|
|
_RevertScriptDefines();
|
2024-08-21 17:45:27 +08:00
|
|
|
|
|
|
|
|
|
|
#region 打整包时缓存当前版本的AotDll
|
|
|
|
|
|
string aotDllStorePath = GetAotDllStorePath(info.version);
|
|
|
|
|
|
string aotDllPath = SettingsUtil.GetAssembliesPostIl2CppStripDir(EditorUserBuildSettings.activeBuildTarget);
|
|
|
|
|
|
DirectoryInfo dir = new(aotDllPath);
|
2024-08-22 14:10:32 +08:00
|
|
|
|
if (Directory.Exists(aotDllStorePath))
|
2024-08-22 14:36:11 +08:00
|
|
|
|
Directory.Delete(aotDllStorePath, true);
|
2024-08-22 14:10:32 +08:00
|
|
|
|
|
|
|
|
|
|
Directory.CreateDirectory(aotDllStorePath);
|
2024-08-21 17:45:27 +08:00
|
|
|
|
|
|
|
|
|
|
FileInfo[] files = dir.GetFiles();
|
|
|
|
|
|
foreach (FileInfo file in files)
|
|
|
|
|
|
{
|
|
|
|
|
|
file.CopyTo(Path.Combine(aotDllStorePath, file.Name), false);
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2023-11-23 14:41:25 +08:00
|
|
|
|
}
|
2024-01-24 13:18:47 +08:00
|
|
|
|
catch (Exception e)
|
2023-11-27 19:53:34 +08:00
|
|
|
|
{
|
2024-01-24 15:51:08 +08:00
|
|
|
|
//Build Exception用于在日志文件中定位此次打包的异常
|
2024-01-24 13:18:47 +08:00
|
|
|
|
Debug.LogError($"[Build Exception]:{e.Message} \r\n {e.StackTrace}");
|
|
|
|
|
|
throw;
|
2023-11-27 19:53:34 +08:00
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 批处理增量更新资源
|
2024-02-26 12:58:19 +08:00
|
|
|
|
/// jenkins打包增量更新时使用该方法
|
2023-10-19 15:00:19 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static void UpdatePreviousBuild()
|
|
|
|
|
|
{
|
2024-01-24 15:51:08 +08:00
|
|
|
|
try
|
|
|
|
|
|
{
|
2024-02-26 17:54:26 +08:00
|
|
|
|
_InitScriptDefines();
|
2024-08-12 12:52:59 +08:00
|
|
|
|
|
2024-05-15 17:15:25 +08:00
|
|
|
|
var enableHotUpdate = YooAssetBuildBase.Init();
|
2024-09-02 13:32:23 +08:00
|
|
|
|
|
|
|
|
|
|
ExtBuildInfoHelper.VertifyExitBuildInfo(YooAssetBuildBase.workSpace, YooAssetBuildBase.appVersion);
|
|
|
|
|
|
|
2024-01-24 15:51:08 +08:00
|
|
|
|
if (enableHotUpdate)
|
2024-08-21 19:06:36 +08:00
|
|
|
|
{
|
2024-08-27 19:32:49 +08:00
|
|
|
|
Debug.Log("开始检查AOT版本");
|
2024-08-22 14:10:32 +08:00
|
|
|
|
if (CheckAotOutDate(YooAssetBuildBase.appVersion))
|
2024-08-27 19:32:49 +08:00
|
|
|
|
{
|
|
|
|
|
|
Debug.Log("AOT版本检查通过");
|
2024-08-22 14:10:32 +08:00
|
|
|
|
BuildLauncher.BuildHotUpdateDlls();
|
2024-08-27 19:32:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.LogError("AOT版本不匹配,请重新打AOT包");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.Log("未开启热更");
|
2024-08-21 19:06:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-13 15:28:35 +08:00
|
|
|
|
// 写入打包信息到Yoo_Build_Cache
|
|
|
|
|
|
ExtBuildInfoHelper.UpdateExtBuildInfo(YooAssetBuildBase.workSpace, YooAssetBuildBase.appVersion);
|
2024-05-15 17:15:25 +08:00
|
|
|
|
|
|
|
|
|
|
YooAssetBuildBase.BuildOnlyResUpdate();
|
2024-09-02 13:32:23 +08:00
|
|
|
|
|
|
|
|
|
|
ExtBuildInfoHelper.CreateVertifyBuildInfo(YooAssetBuildBase.workSpace, YooAssetBuildBase.appVersion);
|
2024-05-15 17:15:25 +08:00
|
|
|
|
|
2024-02-26 17:54:26 +08:00
|
|
|
|
_RevertScriptDefines();
|
2024-01-24 15:51:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
//Build Exception用于在日志文件中定位此次打包的异常
|
|
|
|
|
|
Debug.LogError($"[Build Exception]:{e.Message} \r\n {e.StackTrace}");
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
2023-10-19 15:00:19 +08:00
|
|
|
|
}
|
2024-08-21 17:45:27 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// jenkins检查AOT裁剪代码
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="version"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2024-08-22 14:10:32 +08:00
|
|
|
|
public static bool CheckAotOutDate(string version)
|
2024-08-21 17:45:27 +08:00
|
|
|
|
{
|
|
|
|
|
|
Debug.Log($"开始检查aot版本:{version}");
|
|
|
|
|
|
string stripedDllPath = GetAotDllStorePath(version);
|
|
|
|
|
|
// 先编译dll
|
|
|
|
|
|
CompileDllCommand.CompileDllActiveBuildTarget();
|
2024-08-21 19:06:36 +08:00
|
|
|
|
// 再检查编译出来的dll是否满足以前的Aotdll
|
2024-08-21 17:45:27 +08:00
|
|
|
|
MissingMetadataChecker checker = new(stripedDllPath, new List<string>());
|
|
|
|
|
|
string hotUpdateDir = SettingsUtil.GetHotUpdateDllsOutputDirByTarget(EditorUserBuildSettings.activeBuildTarget);
|
|
|
|
|
|
foreach (string dll in SettingsUtil.HotUpdateAssemblyFilesExcludePreserved)
|
|
|
|
|
|
{
|
|
|
|
|
|
string dllPath = $"{hotUpdateDir}/{dll}";
|
|
|
|
|
|
bool notAnyMissing = checker.Check(dllPath);
|
|
|
|
|
|
if (!notAnyMissing)
|
2024-08-22 14:10:32 +08:00
|
|
|
|
throw new Exception("AOT缺失Dll,请重新打AOT包");
|
2024-08-21 17:45:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取缓存的AOT Dll路径
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="version"></param>
|
|
|
|
|
|
private static string GetAotDllStorePath(string version)
|
|
|
|
|
|
{
|
|
|
|
|
|
return $"../StoreAotDll/{version}";
|
|
|
|
|
|
}
|
2024-08-12 12:52:59 +08:00
|
|
|
|
}
|