parent
49c242e7bc
commit
500b469bce
|
@ -86,7 +86,6 @@ namespace YooAsset.Editor
|
|||
var buildResult = BuildRunner.Run(pipeline, _buildContext);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
buildResult.OutputPackageCRC = buildParametersContext.OutputPackageCRC;
|
||||
buildResult.OutputPackageDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
Debug.Log($"{buildParameters.BuildMode} pipeline build succeed !");
|
||||
}
|
||||
|
|
|
@ -75,9 +75,9 @@ namespace YooAsset.Editor
|
|||
/// <summary>
|
||||
/// 加载补丁清单文件
|
||||
/// </summary>
|
||||
internal static PatchManifest LoadPatchManifestFile(string fileDirectory, string packageName, string packageCRC)
|
||||
internal static PatchManifest LoadPatchManifestFile(string fileDirectory, string packageName, string packageVersion)
|
||||
{
|
||||
string filePath = $"{fileDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(packageName, packageCRC)}";
|
||||
string filePath = $"{fileDirectory}/{YooAssetSettingsData.GetPatchManifestFileName(packageName, packageVersion)}";
|
||||
if (File.Exists(filePath) == false)
|
||||
{
|
||||
throw new System.Exception($"Not found patch manifest file : {filePath}");
|
||||
|
|
|
@ -255,7 +255,8 @@ namespace YooAsset.Editor
|
|||
buildParameters.BuildTarget = _buildTarget;
|
||||
buildParameters.BuildPipeline = AssetBundleBuilderSettingData.Setting.BuildPipeline;
|
||||
buildParameters.BuildMode = AssetBundleBuilderSettingData.Setting.BuildMode;
|
||||
buildParameters.BuildPackage = AssetBundleBuilderSettingData.Setting.BuildPackage;
|
||||
buildParameters.PackageName = AssetBundleBuilderSettingData.Setting.BuildPackage;
|
||||
buildParameters.PackageVersion = GetDefaultPackageVersion();
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
||||
buildParameters.CompressOption = AssetBundleBuilderSettingData.Setting.CompressOption;
|
||||
|
@ -276,6 +277,11 @@ namespace YooAsset.Editor
|
|||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||
}
|
||||
}
|
||||
private string GetDefaultPackageVersion()
|
||||
{
|
||||
int totalMinutes = DateTime.Now.Hour * 60 + DateTime.Now.Minute;
|
||||
return DateTime.Now.ToString("yyyy-MM-dd") + "-" + totalMinutes;
|
||||
}
|
||||
|
||||
// 构建包裹相关
|
||||
private int GetDefaultPackageIndex(string packageName)
|
||||
|
|
|
@ -14,14 +14,15 @@ namespace YooAsset.Editor
|
|||
buildParameters.OutputRoot = defaultOutputRoot;
|
||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||
buildParameters.BuildPackage = packageName;
|
||||
buildParameters.PackageName = packageName;
|
||||
buildParameters.PackageVersion = "Simulate";
|
||||
|
||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||
var buildResult = builder.Run(buildParameters);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
string pipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(buildParameters.OutputRoot, buildParameters.BuildPackage, buildParameters.BuildTarget, buildParameters.BuildMode);
|
||||
string manifestFileName = YooAssetSettingsData.GetPatchManifestFileName(buildParameters.BuildPackage, buildResult.OutputPackageCRC);
|
||||
string pipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(buildParameters.OutputRoot, buildParameters.PackageName, buildParameters.BuildTarget, buildParameters.BuildMode);
|
||||
string manifestFileName = YooAssetSettingsData.GetPatchManifestFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string manifestFilePath = $"{pipelineOutputDirectory}/{manifestFileName}";
|
||||
return manifestFilePath;
|
||||
}
|
||||
|
|
|
@ -57,14 +57,14 @@ namespace YooAsset.Editor
|
|||
public EBuildMode BuildMode;
|
||||
|
||||
/// <summary>
|
||||
/// 构建的Package名称
|
||||
/// 构建的包裹名称
|
||||
/// </summary>
|
||||
public string BuildPackage;
|
||||
public string PackageName;
|
||||
|
||||
/// <summary>
|
||||
/// 人类可读的版本信息
|
||||
/// 构建的包裹版本
|
||||
/// </summary>
|
||||
public string HumanReadableVersion;
|
||||
public string PackageVersion;
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -11,30 +11,12 @@ namespace YooAsset.Editor
|
|||
|
||||
private string _pipelineOutputDirectory = string.Empty;
|
||||
private string _packageOutputDirectory = string.Empty;
|
||||
private string _outputPackageCRC = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 构建参数
|
||||
/// </summary>
|
||||
public BuildParameters Parameters { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 构建输出的包裹清单哈希值
|
||||
/// </summary>
|
||||
public string OutputPackageCRC
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(_outputPackageCRC))
|
||||
throw new Exception("Output package file CRC32 is empty !");
|
||||
return _outputPackageCRC;
|
||||
}
|
||||
set
|
||||
{
|
||||
_outputPackageCRC = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public BuildParametersContext(BuildParameters parameters)
|
||||
{
|
||||
|
@ -49,7 +31,7 @@ namespace YooAsset.Editor
|
|||
{
|
||||
if (string.IsNullOrEmpty(_pipelineOutputDirectory))
|
||||
{
|
||||
_pipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(Parameters.OutputRoot, Parameters.BuildPackage, Parameters.BuildTarget, Parameters.BuildMode);
|
||||
_pipelineOutputDirectory = AssetBundleBuilderHelper.MakePipelineOutputDirectory(Parameters.OutputRoot, Parameters.PackageName, Parameters.BuildTarget, Parameters.BuildMode);
|
||||
}
|
||||
return _pipelineOutputDirectory;
|
||||
}
|
||||
|
@ -61,7 +43,7 @@ namespace YooAsset.Editor
|
|||
{
|
||||
if (string.IsNullOrEmpty(_packageOutputDirectory))
|
||||
{
|
||||
_packageOutputDirectory = $"{Parameters.OutputRoot}/{Parameters.BuildPackage}/{Parameters.BuildTarget}/{OutputPackageCRC}";
|
||||
_packageOutputDirectory = $"{Parameters.OutputRoot}/{Parameters.PackageName}/{Parameters.BuildTarget}/{Parameters.PackageVersion}";
|
||||
}
|
||||
return _packageOutputDirectory;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
|
@ -56,6 +57,9 @@ namespace YooAsset.Editor
|
|||
|
||||
public static void Serialize(string savePath, BuildReport buildReport)
|
||||
{
|
||||
if (File.Exists(savePath))
|
||||
File.Delete(savePath);
|
||||
|
||||
string json = JsonUtility.ToJson(buildReport, true);
|
||||
FileUtility.CreateFile(savePath, json);
|
||||
}
|
||||
|
|
|
@ -44,9 +44,14 @@ namespace YooAsset.Editor
|
|||
public EBuildMode BuildMode;
|
||||
|
||||
/// <summary>
|
||||
/// 构建包裹
|
||||
/// 构建包裹名称
|
||||
/// </summary>
|
||||
public string BuildPackage;
|
||||
public string BuildPackageName;
|
||||
|
||||
/// <summary>
|
||||
/// 构建包裹版本
|
||||
/// </summary>
|
||||
public string BuildPackageVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 启用可寻址资源定位
|
||||
|
|
|
@ -25,10 +25,5 @@ namespace YooAsset.Editor
|
|||
/// 输出的补丁包目录
|
||||
/// </summary>
|
||||
public string OutputPackageDirectory;
|
||||
|
||||
/// <summary>
|
||||
/// 输出的包裹清单哈希值
|
||||
/// </summary>
|
||||
public string OutputPackageCRC;
|
||||
}
|
||||
}
|
|
@ -26,11 +26,11 @@ namespace YooAsset.Editor
|
|||
ECopyBuildinFileOption option = buildParametersContext.Parameters.CopyBuildinFileOption;
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
string streamingAssetsDirectory = AssetBundleBuilderHelper.GetStreamingAssetsFolderPath();
|
||||
string buildPackageName = buildParametersContext.Parameters.BuildPackage;
|
||||
string outputPackageCRC = buildParametersContext.OutputPackageCRC;
|
||||
string buildPackageName = buildParametersContext.Parameters.PackageName;
|
||||
string buildPackageVersion = buildParametersContext.Parameters.PackageVersion;
|
||||
|
||||
// 加载补丁清单
|
||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(packageOutputDirectory, buildPackageName, outputPackageCRC);
|
||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(packageOutputDirectory, buildPackageName, buildPackageVersion);
|
||||
|
||||
// 清空流目录
|
||||
if (option == ECopyBuildinFileOption.ClearAndCopyAll || option == ECopyBuildinFileOption.ClearAndCopyByTags)
|
||||
|
@ -40,7 +40,7 @@ namespace YooAsset.Editor
|
|||
|
||||
// 拷贝补丁清单文件
|
||||
{
|
||||
string manifestFileName = YooAssetSettingsData.GetPatchManifestFileName(buildPackageName, outputPackageCRC);
|
||||
string manifestFileName = YooAssetSettingsData.GetPatchManifestFileName(buildPackageName, buildPackageVersion);
|
||||
string sourcePath = $"{packageOutputDirectory}/{manifestFileName}";
|
||||
string destPath = $"{streamingAssetsDirectory}/{manifestFileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
|
|
|
@ -31,8 +31,8 @@ namespace YooAsset.Editor
|
|||
patchManifest.FileVersion = YooAssetSettings.PatchManifestFileVersion;
|
||||
patchManifest.EnableAddressable = buildMapContext.EnableAddressable;
|
||||
patchManifest.OutputNameStyle = (int)buildParameters.OutputNameStyle;
|
||||
patchManifest.PackageName = buildParameters.BuildPackage;
|
||||
patchManifest.HumanReadableVersion = buildParameters.HumanReadableVersion;
|
||||
patchManifest.PackageName = buildParameters.PackageName;
|
||||
patchManifest.PackageVersion = buildParameters.PackageVersion;
|
||||
patchManifest.BundleList = GetAllPatchBundle(context);
|
||||
patchManifest.AssetList = GetAllPatchAsset(context, patchManifest);
|
||||
|
||||
|
@ -47,24 +47,19 @@ namespace YooAsset.Editor
|
|||
}
|
||||
|
||||
// 创建补丁清单文件
|
||||
string manifestFileTempName = YooAssetSettingsData.GetPatchManifestTempFileName(buildParameters.BuildPackage);
|
||||
string manifestFileTempPath = $"{pipelineOutputDirectory}/{manifestFileTempName}";
|
||||
BuildRunner.Log($"创建补丁清单文件:{manifestFileTempPath}");
|
||||
PatchManifest.Serialize(manifestFileTempPath, patchManifest);
|
||||
|
||||
// 计算补丁清单文件的CRC32
|
||||
buildParametersContext.OutputPackageCRC = HashUtility.FileCRC32(manifestFileTempPath);
|
||||
|
||||
// 补丁清单文件重命名
|
||||
string manifestFileName = YooAssetSettingsData.GetPatchManifestFileName(buildParameters.BuildPackage, buildParametersContext.OutputPackageCRC);
|
||||
string manifestFileName = YooAssetSettingsData.GetPatchManifestFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string manifestFilePath = $"{pipelineOutputDirectory}/{manifestFileName}";
|
||||
EditorTools.FileMoveTo(manifestFileTempPath, manifestFilePath);
|
||||
PatchManifest.Serialize(manifestFilePath, patchManifest);
|
||||
BuildRunner.Log($"创建补丁清单文件:{manifestFilePath}");
|
||||
|
||||
// 创建静态版本文件
|
||||
string staticVersionFileName = YooAssetSettingsData.GetStaticVersionFileName(buildParameters.BuildPackage);
|
||||
string staticVersionFileName = YooAssetSettingsData.GetStaticVersionFileName(buildParameters.PackageName);
|
||||
string staticVersionFilePath = $"{pipelineOutputDirectory}/{staticVersionFileName}";
|
||||
StaticVersion staticVersion = new StaticVersion();
|
||||
staticVersion.PackageVersion = buildParameters.PackageVersion;
|
||||
staticVersion.ManifestCRC = HashUtility.FileCRC32(manifestFilePath);
|
||||
StaticVersion.Serialize(staticVersionFilePath, staticVersion);
|
||||
BuildRunner.Log($"创建静态版本文件:{staticVersionFilePath}");
|
||||
FileUtility.CreateFile(staticVersionFilePath, buildParametersContext.OutputPackageCRC);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace YooAsset.Editor
|
|||
|
||||
// 拷贝Report文件
|
||||
{
|
||||
string reportFileName = YooAssetSettingsData.GetReportFileName(buildParameters.BuildPackage, buildParametersContext.OutputPackageCRC);
|
||||
string reportFileName = YooAssetSettingsData.GetReportFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{reportFileName}";
|
||||
string destPath = $"{packageOutputDirectory}/{reportFileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
|
@ -36,7 +36,7 @@ namespace YooAsset.Editor
|
|||
|
||||
// 拷贝补丁清单文件
|
||||
{
|
||||
string manifestFileName = YooAssetSettingsData.GetPatchManifestFileName(buildParameters.BuildPackage, buildParametersContext.OutputPackageCRC);
|
||||
string manifestFileName = YooAssetSettingsData.GetPatchManifestFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{manifestFileName}";
|
||||
string destPath = $"{packageOutputDirectory}/{manifestFileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
|
@ -44,7 +44,7 @@ namespace YooAsset.Editor
|
|||
|
||||
// 拷贝静态版本文件
|
||||
{
|
||||
string versionFileName = YooAssetSettingsData.GetStaticVersionFileName(buildParameters.BuildPackage);
|
||||
string versionFileName = YooAssetSettingsData.GetStaticVersionFileName(buildParameters.PackageName);
|
||||
string sourcePath = $"{pipelineOutputDirectory}/{versionFileName}";
|
||||
string destPath = $"{packageOutputDirectory}/{versionFileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
|
@ -86,7 +86,7 @@ namespace YooAsset.Editor
|
|||
|
||||
// 拷贝所有补丁文件
|
||||
int progressValue = 0;
|
||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(pipelineOutputDirectory, buildParameters.BuildPackage, buildParametersContext.OutputPackageCRC);
|
||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(pipelineOutputDirectory, buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
int patchFileTotalCount = patchManifest.BundleList.Count;
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
{
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace YooAsset.Editor
|
|||
var buildParameters = buildParametersContext.Parameters;
|
||||
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(pipelineOutputDirectory, buildParameters.BuildPackage, buildParametersContext.OutputPackageCRC);
|
||||
PatchManifest patchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(pipelineOutputDirectory, buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
BuildReport buildReport = new BuildReport();
|
||||
|
||||
// 概述信息
|
||||
|
@ -45,7 +45,8 @@ namespace YooAsset.Editor
|
|||
buildReport.Summary.BuildTarget = buildParameters.BuildTarget;
|
||||
buildReport.Summary.BuildPipeline = buildParameters.BuildPipeline;
|
||||
buildReport.Summary.BuildMode = buildParameters.BuildMode;
|
||||
buildReport.Summary.BuildPackage = buildParameters.BuildPackage;
|
||||
buildReport.Summary.BuildPackageName = buildParameters.PackageName;
|
||||
buildReport.Summary.BuildPackageVersion = buildParameters.PackageVersion;
|
||||
buildReport.Summary.EnableAddressable = buildMapContext.EnableAddressable;
|
||||
buildReport.Summary.UniqueBundleName = buildMapContext.UniqueBundleName;
|
||||
|
||||
|
@ -101,13 +102,9 @@ namespace YooAsset.Editor
|
|||
buildReport.BundleInfos.Add(reportBundleInfo);
|
||||
}
|
||||
|
||||
// 删除旧文件
|
||||
string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.BuildPackage, buildParametersContext.OutputPackageCRC);
|
||||
string filePath = $"{pipelineOutputDirectory}/{fileName}";
|
||||
if (File.Exists(filePath))
|
||||
File.Delete(filePath);
|
||||
|
||||
// 序列化文件
|
||||
string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{pipelineOutputDirectory}/{fileName}";
|
||||
BuildReport.Serialize(filePath, buildReport);
|
||||
BuildRunner.Log($"资源构建报告文件创建完成:{filePath}");
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace YooAsset.Editor
|
|||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildMapContext = BuildMapCreater.CreateBuildMap(buildParametersContext.Parameters.BuildMode, buildParametersContext.Parameters.BuildPackage);
|
||||
var buildMapContext = BuildMapCreater.CreateBuildMap(buildParametersContext.Parameters.BuildMode, buildParametersContext.Parameters.PackageName);
|
||||
context.SetContextObject(buildMapContext);
|
||||
BuildRunner.Log("构建内容准备完毕!");
|
||||
|
||||
|
|
|
@ -19,8 +19,10 @@ namespace YooAsset.Editor
|
|||
// 检测构建参数合法性
|
||||
if (buildParameters.BuildTarget == BuildTarget.NoTarget)
|
||||
throw new Exception("请选择目标平台");
|
||||
if (string.IsNullOrEmpty(buildParameters.BuildPackage))
|
||||
if (string.IsNullOrEmpty(buildParameters.PackageName))
|
||||
throw new Exception("包裹名称不能为空");
|
||||
if(string.IsNullOrEmpty(buildParameters.PackageVersion))
|
||||
throw new Exception("包裹版本不能为空");
|
||||
|
||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
||||
{
|
||||
|
@ -40,6 +42,11 @@ namespace YooAsset.Editor
|
|||
throw new Exception("首包资源标签不能为空!");
|
||||
}
|
||||
|
||||
// 检测包裹输出目录是否存在
|
||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||
if (Directory.Exists(packageOutputDirectory))
|
||||
throw new Exception($"本次构建的补丁目录已经存在:{packageOutputDirectory}");
|
||||
|
||||
// 保存改动的资源
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
@ -47,7 +54,7 @@ namespace YooAsset.Editor
|
|||
if (buildParameters.BuildMode == EBuildMode.ForceRebuild)
|
||||
{
|
||||
// 删除平台总目录
|
||||
string platformDirectory = $"{buildParameters.OutputRoot}/{buildParameters.BuildPackage}/{buildParameters.BuildTarget}";
|
||||
string platformDirectory = $"{buildParameters.OutputRoot}/{buildParameters.PackageName}/{buildParameters.BuildTarget}";
|
||||
if (EditorTools.DeleteDirectory(platformDirectory))
|
||||
{
|
||||
BuildRunner.Log($"删除平台总目录:{platformDirectory}");
|
||||
|
|
|
@ -66,7 +66,8 @@ namespace YooAsset.Editor
|
|||
_items.Add(new ItemWrapper("构建平台", $"{buildReport.Summary.BuildTarget}"));
|
||||
_items.Add(new ItemWrapper("构建管线", $"{buildReport.Summary.BuildPipeline}"));
|
||||
_items.Add(new ItemWrapper("构建模式", $"{buildReport.Summary.BuildMode}"));
|
||||
_items.Add(new ItemWrapper("构建包裹", $"{buildReport.Summary.BuildPackage}"));
|
||||
_items.Add(new ItemWrapper("包裹名称", buildReport.Summary.BuildPackageName));
|
||||
_items.Add(new ItemWrapper("包裹版本", buildReport.Summary.BuildPackageVersion));
|
||||
|
||||
_items.Add(new ItemWrapper("启用可寻址资源定位", $"{buildReport.Summary.EnableAddressable}"));
|
||||
_items.Add(new ItemWrapper("资源包名唯一化", $"{buildReport.Summary.UniqueBundleName}"));
|
||||
|
|
Loading…
Reference in New Issue