mirror of
https://github.com/muskit/H3VR-TNH-Quality-of-Life-Improvements.git
synced 2026-06-02 20:24:26 -07:00
update MeatKit (9a1a68ab68cd0650227af944ffa30d1166b9e056)
This commit is contained in:
+3
-3
@@ -1,12 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d18106ea7c52411db45cabd362f21f16
|
||||
timeCreated: 1640061580
|
||||
licenseType: Pro
|
||||
timeCreated: 1649523901
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 151c1f5398ee70041a49c417b23f1846, type: 3}
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
+3
-3
@@ -1,12 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f6d6db4144b34551885c304840edfb62
|
||||
timeCreated: 1640061353
|
||||
licenseType: Pro
|
||||
timeCreated: 1649523904
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 6fae6dfd178cd184180013acef55632c, type: 3}
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
namespace MeatKit
|
||||
{
|
||||
public static class BuildLog
|
||||
{
|
||||
private static StringWriter _temp;
|
||||
private static Stopwatch _sw;
|
||||
private static DateTime _startTime;
|
||||
private static bool _failed;
|
||||
private static string _completionMessage;
|
||||
private static Exception _exception;
|
||||
|
||||
public static void StartNew()
|
||||
{
|
||||
_temp = new StringWriter();
|
||||
_sw = Stopwatch.StartNew();
|
||||
_startTime = DateTime.Now;
|
||||
}
|
||||
|
||||
public static void WriteLine(string text)
|
||||
{
|
||||
if (_temp == null) return;
|
||||
_temp.WriteLine(text);
|
||||
}
|
||||
|
||||
public static void SetCompletionStatus(bool failed, string message, Exception exception)
|
||||
{
|
||||
_failed = failed;
|
||||
_completionMessage = message;
|
||||
_exception = exception;
|
||||
}
|
||||
|
||||
public static void Finish()
|
||||
{
|
||||
_sw.Stop();
|
||||
|
||||
StreamWriter output = new StreamWriter("AssetBundles/buildlog.txt", false);
|
||||
|
||||
WriteProfileInfo(output);
|
||||
output.WriteLine();
|
||||
output.WriteLine("--- MeatKit Build Log ---");
|
||||
output.WriteLine("Start Time: " + _startTime.ToString("dddd, dd MMMM yyyy HH:mm:ssK"));
|
||||
output.WriteLine("Duration : " + _sw.Elapsed.GetReadableTimespan());
|
||||
output.WriteLine("Status : " + (_failed ? "FAILED" : "COMPLETED"));
|
||||
if (!string.IsNullOrEmpty(_completionMessage))
|
||||
output.WriteLine("Message : " + _completionMessage);
|
||||
if (_exception != null)
|
||||
{
|
||||
output.WriteLine("Exception :");
|
||||
output.WriteLine(_exception.ToString());
|
||||
}
|
||||
|
||||
output.WriteLine("\n--- Full build log ---");
|
||||
output.Write(_temp.ToString());
|
||||
|
||||
output.Close();
|
||||
output.Dispose();
|
||||
_temp = null;
|
||||
}
|
||||
|
||||
private static void WriteProfileInfo(StreamWriter output)
|
||||
{
|
||||
var profile = BuildWindow.SelectedProfile;
|
||||
var implicitDependencies = profile.GetRequiredDependencies();
|
||||
|
||||
output.WriteLine("--- Selected Build Profile ---");
|
||||
output.WriteLine("Thunderstore Metadata");
|
||||
output.WriteLine(" Package Name: " + profile.PackageName);
|
||||
output.WriteLine(" Author : " + profile.Author);
|
||||
output.WriteLine(" Version : " + profile.Version);
|
||||
output.WriteLine(" Icon Set : " + (profile.Icon == null ? "No" : "Yes"));
|
||||
output.WriteLine(" Readme Set : " + (profile.ReadMe == null ? "No" : "Yes"));
|
||||
output.WriteLine(" Website URL : " + profile.WebsiteURL);
|
||||
output.WriteLine(" Description : " + profile.Description);
|
||||
output.WriteLine(" Implicit Dependencies : (" + implicitDependencies.Length + ")");
|
||||
foreach (var dependency in implicitDependencies)
|
||||
output.WriteLine(" " + dependency);
|
||||
output.WriteLine(" Additional Dependencies: (" + profile.AdditionalDependencies.Length + ")");
|
||||
foreach (var dependency in profile.AdditionalDependencies)
|
||||
output.WriteLine(" " + dependency);
|
||||
|
||||
output.WriteLine("Script Options");
|
||||
output.WriteLine(" Strip Namespaces : " + profile.StripNamespaces);
|
||||
output.WriteLine(" Additional Namespaces: (" + profile.AdditionalNamespaces.Length + ")");
|
||||
foreach (var @namespace in profile.AdditionalNamespaces)
|
||||
output.WriteLine(" " + @namespace);
|
||||
output.WriteLine(" Apply Harmony Patches: " + profile.ApplyHarmonyPatches);
|
||||
|
||||
output.WriteLine("Export Options");
|
||||
output.WriteLine(" Build Items: (" + profile.BuildItems.Length + ")");
|
||||
foreach (var buildItem in profile.BuildItems)
|
||||
output.WriteLine(" " + buildItem);
|
||||
output.WriteLine(" Build Action: " + profile.BuildAction);
|
||||
output.WriteLine(" Export Path : " + profile.ExportPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f474df2cd776465d8cc9d2f7f52f77c7
|
||||
timeCreated: 1664853706
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using AssetsTools.NET;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
@@ -18,6 +17,8 @@ namespace MeatKit
|
||||
[CreateAssetMenu(menuName = "MeatKit/Build Profile")]
|
||||
public class BuildProfile : ScriptableObject, IValidatable
|
||||
{
|
||||
private const string BaseOutputPath = "AssetBundles/";
|
||||
|
||||
[Header("Thunderstore Metadata")]
|
||||
public string PackageName = "";
|
||||
public string Author = "";
|
||||
@@ -31,10 +32,10 @@ namespace MeatKit
|
||||
[Header("Script Options")]
|
||||
public bool StripNamespaces = true;
|
||||
public string[] AdditionalNamespaces = new string[0];
|
||||
|
||||
public bool ApplyHarmonyPatches = true;
|
||||
|
||||
[Header("Export Options")]
|
||||
public BuildItem[] BuildItems = new BuildItem[0];
|
||||
public AssetBundleCompressionType BundleCompressionType = AssetBundleCompressionType.LZ4;
|
||||
public BuildAction BuildAction = BuildAction.JustBuildFiles;
|
||||
|
||||
[HideInInspector]
|
||||
@@ -49,6 +50,11 @@ namespace MeatKit
|
||||
messages["PackageName"] =
|
||||
BuildMessage.Error("Package name can only contain letters, numbers, and underscores.");
|
||||
|
||||
// Author needs to match regex
|
||||
if (!Regex.IsMatch(Author, @"^[a-zA-Z_0-9]+$"))
|
||||
messages["Author"] =
|
||||
BuildMessage.Error("Author can only contain letters, numbers, and underscores.");
|
||||
|
||||
// Make sure the version number is a valid x.x.x
|
||||
if (!Regex.IsMatch(Version, @"^\d+\.\d+\.\d+$"))
|
||||
messages["Version"] = BuildMessage.Error("Version number must be in format 'x.x.x'.");
|
||||
@@ -65,18 +71,8 @@ namespace MeatKit
|
||||
|
||||
if (!ReadMe)
|
||||
messages["ReadMe"] = BuildMessage.Error("Missing readme.");
|
||||
|
||||
switch (BundleCompressionType)
|
||||
{
|
||||
case AssetBundleCompressionType.NONE:
|
||||
messages["BundleCompressionType"] = BuildMessage.Warning(
|
||||
"Uncompressed bundles are not recommended for publication. They can and will be very large.");
|
||||
break;
|
||||
case AssetBundleCompressionType.LZMA:
|
||||
messages["BundleCompressionType"] = BuildMessage.Info(
|
||||
"LZMA can take longer to compress than LZ4, however it will result in smaller file sizes usually.");
|
||||
break;
|
||||
}
|
||||
else if (!AssetDatabase.GetAssetPath(ReadMe).EndsWith(".md", StringComparison.InvariantCultureIgnoreCase))
|
||||
messages["ReadMe"] = BuildMessage.Warning("Are you sure this is a Markdown file? It doesn't have the .md file extension.");
|
||||
|
||||
switch (BuildAction)
|
||||
{
|
||||
@@ -109,11 +105,32 @@ namespace MeatKit
|
||||
|
||||
public bool EnsureValidForEditor()
|
||||
{
|
||||
// Go over each build item
|
||||
BuildLog.WriteLine("Starting build profile check...");
|
||||
|
||||
// Check ourselves
|
||||
bool hasErrors = false, hasWarnings = false;
|
||||
foreach (var item in BuildItems)
|
||||
// Check if it has any validation messages
|
||||
foreach (var message in Validate().Values)
|
||||
{
|
||||
// Log them
|
||||
switch (message.Type)
|
||||
{
|
||||
case MessageType.Error:
|
||||
Debug.LogError(AssetDatabase.GetAssetPath(this) + ": " + message.Message);
|
||||
hasErrors = true;
|
||||
break;
|
||||
case MessageType.Warning:
|
||||
Debug.LogWarning(AssetDatabase.GetAssetPath(this) + ": " + message.Message);
|
||||
hasWarnings = true;
|
||||
break;
|
||||
}
|
||||
|
||||
BuildLog.WriteLine(" " + message.Type + ": " + this + ": " + message.Message);
|
||||
}
|
||||
|
||||
// Go over each build item and check for any validation messages
|
||||
foreach (var item in BuildItems.Where(x => x != null))
|
||||
foreach (var message in item.Validate().Values)
|
||||
{
|
||||
// Log them
|
||||
switch (message.Type)
|
||||
{
|
||||
@@ -125,45 +142,54 @@ namespace MeatKit
|
||||
Debug.LogWarning(AssetDatabase.GetAssetPath(item) + ": " + message.Message);
|
||||
hasWarnings = true;
|
||||
break;
|
||||
case MessageType.Info:
|
||||
Debug.Log(AssetDatabase.GetAssetPath(item) + ": " + message.Message);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
BuildLog.WriteLine(" " + message.Type + ": " + item + ": " + message.Message);
|
||||
}
|
||||
|
||||
|
||||
// If there's errors don't let anything continue
|
||||
if (hasErrors)
|
||||
{
|
||||
EditorUtility.DisplayDialog("Build errors",
|
||||
"There were errors validating your build items. Please check the console for more info.", "Ok.");
|
||||
BuildLog.SetCompletionStatus(true, "Build profile failed one or more checks", null);
|
||||
return false;
|
||||
}
|
||||
|
||||
// If there's only warnings, let the user decide if they want to continue
|
||||
if (hasWarnings)
|
||||
return EditorUtility.DisplayDialog("Build warnings",
|
||||
{
|
||||
var continueAnyway = EditorUtility.DisplayDialog("Build warnings",
|
||||
"Some build items validated with warnings. Continue with build anyway?", "Yes", "No");
|
||||
|
||||
// Otherwise continue
|
||||
return true;
|
||||
BuildLog.WriteLine("Build profile has one or more warnings.");
|
||||
BuildLog.WriteLine(" Continue anyway? " + continueAnyway);
|
||||
BuildLog.SetCompletionStatus(true, "User canceled build", null);
|
||||
|
||||
return continueAnyway;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise continue
|
||||
BuildLog.WriteLine(" Build profile passed all checks!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public string[] GetRequiredDependencies()
|
||||
{
|
||||
return BuildItems
|
||||
.Where(x => x != null)
|
||||
.SelectMany(x => x.RequiredDependencies).ToArray();
|
||||
.SelectMany(x => x.RequiredDependencies)
|
||||
.Distinct().ToArray();
|
||||
}
|
||||
|
||||
public string MainNamespace
|
||||
{
|
||||
get
|
||||
{
|
||||
return Author + "." + PackageName;
|
||||
}
|
||||
get { return Author + "." + PackageName; }
|
||||
}
|
||||
|
||||
|
||||
public string[] GetRequiredNamespaces()
|
||||
{
|
||||
return new[] {MainNamespace};
|
||||
@@ -173,7 +199,12 @@ namespace MeatKit
|
||||
{
|
||||
return GetRequiredNamespaces().Concat(AdditionalNamespaces).ToArray();
|
||||
}
|
||||
|
||||
|
||||
public string ExportPath
|
||||
{
|
||||
get { return Path.Combine(BaseOutputPath, Path.Combine(PackageName, Version)) + Path.DirectorySeparatorChar; }
|
||||
}
|
||||
|
||||
public void WriteThunderstoreManifest(string location)
|
||||
{
|
||||
#if H3VR_IMPORTED
|
||||
@@ -187,7 +218,7 @@ namespace MeatKit
|
||||
// ReSharper disable once CoVariantArrayConversion
|
||||
obj["dependencies"] = new JArray(GetRequiredDependencies().Concat(AdditionalDependencies).ToArray());
|
||||
|
||||
File.WriteAllText(location, JsonConvert.SerializeObject(obj));
|
||||
File.WriteAllText(location, JsonConvert.SerializeObject(obj,Formatting.Indented));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -198,4 +229,4 @@ namespace MeatKit
|
||||
CopyToProfile,
|
||||
CreateThunderstorePackage
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
-2
@@ -1,3 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
fileFormatVersion: 2
|
||||
guid: afed54a239594b8abd631a8047a54987
|
||||
timeCreated: 1635004125
|
||||
timeCreated: 1649524426
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- Icon: {instanceID: 0}
|
||||
- ReadMe: {instanceID: 0}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
@@ -4,9 +4,12 @@ namespace MeatKit
|
||||
{
|
||||
public class MeatKitBuildException : Exception
|
||||
{
|
||||
public MeatKitBuildException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public MeatKitBuildException(string message, Exception innerException) : base(message, innerException)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user