Skip to content

Commit

Permalink
Report build summary
Browse files Browse the repository at this point in the history
  • Loading branch information
BLaZeKiLL committed Oct 6, 2023
1 parent 02e1a8e commit d1964a7
Showing 1 changed file with 35 additions and 4 deletions.
39 changes: 35 additions & 4 deletions Assets/Editor/Build/Builder.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using UnityEditor;
using System;
using UnityEditor;
using UnityEditor.Build.Reporting;

namespace CodeBlaze.Editor.Build {

public static class Builder {

private static readonly string Eol = Environment.NewLine;

[MenuItem("Build/Package")]
private static void Package() {
AssetDatabase.ExportPackage("Packages/io.codeblaze.vloxyengine", "vloxyengine.unitypackage", ExportPackageOptions.Recurse);
Expand All @@ -28,14 +31,16 @@ private static void BuildWindowsDebug() {
};

var report = BuildPipeline.BuildPlayer(options);

ReportSummary(report.summary);
}

[MenuItem("Build/Windows/Release")]
private static void BuildWindowsRelease() {
PlayerSettings.SetScriptingBackend(BuildTargetGroup.Standalone, ScriptingImplementation.Mono2x);
PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone,new [] {
"UNITY_POST_PROCESSING_STACK_V2",
// "VLOXY_LOGGING",
"VLOXY_LOGGING",
});

var options = new BuildPlayerOptions {
Expand All @@ -47,6 +52,8 @@ private static void BuildWindowsRelease() {
};

var report = BuildPipeline.BuildPlayer(options);

ReportSummary(report.summary);
}

#endregion
Expand All @@ -69,14 +76,16 @@ private static void BuildMacDebug() {
};

var report = BuildPipeline.BuildPlayer(options);

ReportSummary(report.summary);
}

[MenuItem("Build/Mac/Release")]
private static void BuildMacRelease() {
PlayerSettings.SetScriptingBackend(BuildTargetGroup.Standalone, ScriptingImplementation.Mono2x);
PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone,new [] {
"UNITY_POST_PROCESSING_STACK_V2",
// "VLOXY_LOGGING",
"VLOXY_LOGGING",
});

var options = new BuildPlayerOptions {
Expand All @@ -88,6 +97,8 @@ private static void BuildMacRelease() {
};

var report = BuildPipeline.BuildPlayer(options);

ReportSummary(report.summary);
}

#endregion
Expand All @@ -110,14 +121,16 @@ private static void BuildAndroidDebug() {
};

var report = BuildPipeline.BuildPlayer(options);

ReportSummary(report.summary);
}

[MenuItem("Build/Android/Release")]
private static void BuildAndroidRelease() {
PlayerSettings.SetScriptingBackend(BuildTargetGroup.Standalone, ScriptingImplementation.Mono2x);
PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone,new [] {
"UNITY_POST_PROCESSING_STACK_V2",
// "VLOXY_LOGGING",
"VLOXY_LOGGING",
});

var options = new BuildPlayerOptions {
Expand All @@ -129,9 +142,27 @@ private static void BuildAndroidRelease() {
};

var report = BuildPipeline.BuildPlayer(options);

ReportSummary(report.summary);
}

#endregion

private static void ReportSummary(BuildSummary summary)
{
Console.WriteLine(
$"{Eol}" +
$"###########################{Eol}" +
$"# Build results #{Eol}" +
$"###########################{Eol}" +
$"{Eol}" +
$"Duration: {summary.totalTime.ToString()}{Eol}" +
$"Warnings: {summary.totalWarnings.ToString()}{Eol}" +
$"Errors: {summary.totalErrors.ToString()}{Eol}" +
$"Size: {summary.totalSize.ToString()} bytes{Eol}" +
$"{Eol}"
);
}
}

}

0 comments on commit d1964a7

Please sign in to comment.