parent
99f89b3c44
commit
480325827b
|
@ -13,17 +13,18 @@ namespace YooAsset.Editor
|
||||||
private readonly BuildContext _buildContext = new BuildContext();
|
private readonly BuildContext _buildContext = new BuildContext();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 开始构建
|
/// 构建资源包
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildResult Run(BuildParameters buildParameters)
|
public BuildResult Run(BuildParameters buildParameters, List<IBuildTask> buildPipeline)
|
||||||
{
|
{
|
||||||
// 清空旧数据
|
|
||||||
_buildContext.ClearAllContext();
|
|
||||||
|
|
||||||
// 检测构建参数是否为空
|
// 检测构建参数是否为空
|
||||||
if (buildParameters == null)
|
if (buildParameters == null)
|
||||||
throw new Exception($"{nameof(buildParameters)} is null !");
|
throw new Exception($"{nameof(buildParameters)} is null !");
|
||||||
|
|
||||||
|
// 检测构建参数是否为空
|
||||||
|
if (buildPipeline.Count == 0)
|
||||||
|
throw new Exception($"Build pipeline is empty !");
|
||||||
|
|
||||||
// 检测可编程构建管线参数
|
// 检测可编程构建管线参数
|
||||||
if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||||
{
|
{
|
||||||
|
@ -37,6 +38,9 @@ namespace YooAsset.Editor
|
||||||
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.ForceRebuild)} build mode !");
|
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.ForceRebuild)} build mode !");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 清空旧数据
|
||||||
|
_buildContext.ClearAllContext();
|
||||||
|
|
||||||
// 构建参数
|
// 构建参数
|
||||||
var buildParametersContext = new BuildParametersContext(buildParameters);
|
var buildParametersContext = new BuildParametersContext(buildParameters);
|
||||||
_buildContext.SetContextObject(buildParametersContext);
|
_buildContext.SetContextObject(buildParametersContext);
|
||||||
|
@ -45,8 +49,7 @@ namespace YooAsset.Editor
|
||||||
BuildLogger.InitLogger(buildParameters.EnableLog);
|
BuildLogger.InitLogger(buildParameters.EnableLog);
|
||||||
|
|
||||||
// 执行构建流程
|
// 执行构建流程
|
||||||
var pipeline = GetBuildTasks(buildParameters.BuildPipeline);
|
var buildResult = BuildRunner.Run(buildPipeline, _buildContext);
|
||||||
var buildResult = BuildRunner.Run(pipeline, _buildContext);
|
|
||||||
if (buildResult.Success)
|
if (buildResult.Success)
|
||||||
{
|
{
|
||||||
buildResult.OutputPackageDirectory = buildParametersContext.GetPackageOutputDirectory();
|
buildResult.OutputPackageDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
|
@ -62,13 +65,23 @@ namespace YooAsset.Editor
|
||||||
return buildResult;
|
return buildResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<IBuildTask> GetBuildTasks(EBuildPipeline buildPipeline)
|
/// <summary>
|
||||||
|
/// 构建资源包
|
||||||
|
/// </summary>
|
||||||
|
public BuildResult Run(BuildParameters buildParameters)
|
||||||
|
{
|
||||||
|
var buildPipeline = GetDefaultBuildPipeline(buildParameters.BuildPipeline);
|
||||||
|
return Run(buildParameters, buildPipeline);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取默认的构建流程
|
||||||
|
/// </summary>
|
||||||
|
private List<IBuildTask> GetDefaultBuildPipeline(EBuildPipeline buildPipeline)
|
||||||
{
|
{
|
||||||
// 获取任务节点的属性集合
|
// 获取任务节点的属性集合
|
||||||
List<TaskAttribute> attrList = new List<TaskAttribute>();
|
|
||||||
if (buildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
if (buildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
List<IBuildTask> pipeline = new List<IBuildTask>
|
List<IBuildTask> pipeline = new List<IBuildTask>
|
||||||
{
|
{
|
||||||
new TaskPrepare(), //前期准备工作
|
new TaskPrepare(), //前期准备工作
|
||||||
|
@ -83,23 +96,10 @@ namespace YooAsset.Editor
|
||||||
new TaskCreatePackage(), //制作包裹
|
new TaskCreatePackage(), //制作包裹
|
||||||
new TaskCopyBuildinFiles(), //拷贝内置文件
|
new TaskCopyBuildinFiles(), //拷贝内置文件
|
||||||
};
|
};
|
||||||
*/
|
return pipeline;
|
||||||
|
|
||||||
var classTypes = EditorTools.GetAssignableTypes(typeof(IBuildTask));
|
|
||||||
foreach (var classType in classTypes)
|
|
||||||
{
|
|
||||||
var attribute = classType.GetCustomAttribute<TaskAttribute>();
|
|
||||||
if (attribute == null)
|
|
||||||
throw new Exception($"Not found {nameof(TaskAttribute)} int type : {classType.FullName}");
|
|
||||||
|
|
||||||
attribute.ClassType = classType;
|
|
||||||
if (attribute.Pipeline == ETaskPipeline.AllPipeline || attribute.Pipeline == ETaskPipeline.BuiltinBuildPipeline)
|
|
||||||
attrList.Add(attribute);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (buildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
else if (buildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
List<IBuildTask> pipeline = new List<IBuildTask>
|
List<IBuildTask> pipeline = new List<IBuildTask>
|
||||||
{
|
{
|
||||||
new TaskPrepare(), //前期准备工作
|
new TaskPrepare(), //前期准备工作
|
||||||
|
@ -114,42 +114,12 @@ namespace YooAsset.Editor
|
||||||
new TaskCreatePackage(), //制作补丁包
|
new TaskCreatePackage(), //制作补丁包
|
||||||
new TaskCopyBuildinFiles(), //拷贝内置文件
|
new TaskCopyBuildinFiles(), //拷贝内置文件
|
||||||
};
|
};
|
||||||
*/
|
return pipeline;
|
||||||
|
|
||||||
var classTypes = EditorTools.GetAssignableTypes(typeof(IBuildTask));
|
|
||||||
foreach (var classType in classTypes)
|
|
||||||
{
|
|
||||||
var attribute = classType.GetCustomAttribute<TaskAttribute>();
|
|
||||||
if (attribute == null)
|
|
||||||
throw new Exception($"Not found {nameof(TaskAttribute)} int type : {classType.FullName}");
|
|
||||||
|
|
||||||
attribute.ClassType = classType;
|
|
||||||
if (attribute.Pipeline == ETaskPipeline.AllPipeline || attribute.Pipeline == ETaskPipeline.ScriptableBuildPipeline)
|
|
||||||
attrList.Add(attribute);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 对任务节点进行排序
|
|
||||||
attrList.Sort((a, b) =>
|
|
||||||
{
|
|
||||||
if (a.TaskOrder > b.TaskOrder) { return 1; }
|
|
||||||
else if (a.TaskOrder < b.TaskOrder) { return -1; }
|
|
||||||
else { return 0; }
|
|
||||||
});
|
|
||||||
|
|
||||||
// 创建任务节点实例
|
|
||||||
List<IBuildTask> pipeline = new List<IBuildTask>(attrList.Count);
|
|
||||||
foreach (var taskAttr in attrList)
|
|
||||||
{
|
|
||||||
var task = Activator.CreateInstance(taskAttr.ClassType) as IBuildTask;
|
|
||||||
pipeline.Add(task);
|
|
||||||
}
|
|
||||||
|
|
||||||
return pipeline;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,22 +0,0 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
|
||||||
{
|
|
||||||
public enum ETaskPipeline
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 所有的构建管线
|
|
||||||
/// </summary>
|
|
||||||
AllPipeline,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 内置构建管线
|
|
||||||
/// </summary>
|
|
||||||
BuiltinBuildPipeline,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 可编程构建管线
|
|
||||||
/// </summary>
|
|
||||||
ScriptableBuildPipeline,
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: 32477ef3a448a9144aa1574a052fe54e
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
|
@ -5,28 +5,13 @@ namespace YooAsset.Editor
|
||||||
[AttributeUsage(AttributeTargets.Class)]
|
[AttributeUsage(AttributeTargets.Class)]
|
||||||
public class TaskAttribute : Attribute
|
public class TaskAttribute : Attribute
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 任务所属的构建流水线
|
|
||||||
/// </summary>
|
|
||||||
public ETaskPipeline Pipeline;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 执行顺序
|
|
||||||
/// </summary>
|
|
||||||
public int TaskOrder;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 任务说明
|
/// 任务说明
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string TaskDesc;
|
public string TaskDesc;
|
||||||
|
|
||||||
// 关联的任务类
|
public TaskAttribute(string taskDesc)
|
||||||
public Type ClassType { set; get; }
|
|
||||||
|
|
||||||
public TaskAttribute(ETaskPipeline pipeline, int taskOrder, string taskDesc)
|
|
||||||
{
|
{
|
||||||
Pipeline = pipeline;
|
|
||||||
TaskOrder = taskOrder;
|
|
||||||
TaskDesc = taskDesc;
|
TaskDesc = taskDesc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute(ETaskPipeline.BuiltinBuildPipeline, 300, "资源构建内容打包")]
|
[TaskAttribute("资源构建内容打包")]
|
||||||
public class TaskBuilding : IBuildTask
|
public class TaskBuilding : IBuildTask
|
||||||
{
|
{
|
||||||
public class BuildResultContext : IContextObject
|
public class BuildResultContext : IContextObject
|
||||||
|
|
|
@ -9,7 +9,7 @@ using UnityEditor.Build.Pipeline.Tasks;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute(ETaskPipeline.ScriptableBuildPipeline, 300, "资源构建内容打包")]
|
[TaskAttribute("资源构建内容打包")]
|
||||||
public class TaskBuilding_SBP : IBuildTask
|
public class TaskBuilding_SBP : IBuildTask
|
||||||
{
|
{
|
||||||
public class BuildResultContext : IContextObject
|
public class BuildResultContext : IContextObject
|
||||||
|
|
|
@ -6,7 +6,7 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute(ETaskPipeline.AllPipeline, 1100, "拷贝内置文件到流目录")]
|
[TaskAttribute("拷贝内置文件到流目录")]
|
||||||
public class TaskCopyBuildinFiles : IBuildTask
|
public class TaskCopyBuildinFiles : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -5,7 +5,7 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute(ETaskPipeline.AllPipeline, 400, "拷贝原生文件")]
|
[TaskAttribute("拷贝原生文件")]
|
||||||
public class TaskCopyRawFile : IBuildTask
|
public class TaskCopyRawFile : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace YooAsset.Editor
|
||||||
internal PackageManifest Manifest;
|
internal PackageManifest Manifest;
|
||||||
}
|
}
|
||||||
|
|
||||||
[TaskAttribute(ETaskPipeline.AllPipeline, 800, "创建清单文件")]
|
[TaskAttribute("创建清单文件")]
|
||||||
public class TaskCreateManifest : IBuildTask
|
public class TaskCreateManifest : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute(ETaskPipeline.AllPipeline, 1000, "制作包裹")]
|
[TaskAttribute("制作包裹")]
|
||||||
public class TaskCreatePackage : IBuildTask
|
public class TaskCreatePackage : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -6,7 +6,7 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute(ETaskPipeline.AllPipeline, 900, "创建构建报告文件")]
|
[TaskAttribute("创建构建报告文件")]
|
||||||
public class TaskCreateReport : IBuildTask
|
public class TaskCreateReport : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute(ETaskPipeline.AllPipeline, 600, "资源包加密")]
|
[TaskAttribute("资源包加密")]
|
||||||
public class TaskEncryption : IBuildTask
|
public class TaskEncryption : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -7,7 +7,7 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute(ETaskPipeline.AllPipeline, 200, "获取资源构建内容")]
|
[TaskAttribute("获取资源构建内容")]
|
||||||
public class TaskGetBuildMap : IBuildTask
|
public class TaskGetBuildMap : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -6,7 +6,7 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute(ETaskPipeline.AllPipeline, 100, "资源构建准备工作")]
|
[TaskAttribute("资源构建准备工作")]
|
||||||
public class TaskPrepare : IBuildTask
|
public class TaskPrepare : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -6,7 +6,7 @@ using UnityEditor;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute(ETaskPipeline.AllPipeline, 700, "更新资源包信息")]
|
[TaskAttribute("更新资源包信息")]
|
||||||
public class TaskUpdateBundleInfo : IBuildTask
|
public class TaskUpdateBundleInfo : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -8,7 +8,7 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute(ETaskPipeline.BuiltinBuildPipeline, 500, "验证构建结果")]
|
[TaskAttribute("验证构建结果")]
|
||||||
public class TaskVerifyBuildResult : IBuildTask
|
public class TaskVerifyBuildResult : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
|
@ -9,7 +9,7 @@ using UnityEditor.Build.Pipeline.Interfaces;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
[TaskAttribute(ETaskPipeline.ScriptableBuildPipeline, 500, "验证构建结果")]
|
[TaskAttribute("验证构建结果")]
|
||||||
public class TaskVerifyBuildResult_SBP : IBuildTask
|
public class TaskVerifyBuildResult_SBP : IBuildTask
|
||||||
{
|
{
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
|
Loading…
Reference in New Issue