Files
wwdpublic/Content.Packaging/ClientPackaging.cs
SimpleStation14 a8911da2f3 Mirror: Configuration argument for content packaging (#316)
## Mirror of PR #25569: [Configuration argument for content
packaging](https://github.com/space-wizards/space-station-14/pull/25569)
from <img src="https://avatars.githubusercontent.com/u/10567778?v=4"
alt="space-wizards" width="22"/>
[space-wizards](https://github.com/space-wizards)/[space-station-14](https://github.com/space-wizards/space-station-14)

###### `9e7b196ffbaa8c0a772d5d7544e51deaa2fe5a26`

PR opened by <img
src="https://avatars.githubusercontent.com/u/34938708?v=4"
width="16"/><a href="https://github.com/VasilisThePikachu">
VasilisThePikachu</a> at 2024-02-25 21:40:05 UTC

---

PR changed 4 files with 34 additions and 15 deletions.

The PR had the following labels:


---

<details open="true"><summary><h1>Original Body</h1></summary>

> <!-- Please read these guidelines before opening your PR:
https://docs.spacestation14.io/en/getting-started/pr-guideline -->
> <!-- The text between the arrows are comments - they will not be
visible on your PR. -->
> 
> Requires https://github.com/space-wizards/RobustToolbox/pull/4992
> 
> ## About the PR
> <!-- What did you change in this PR? -->
> 
> Needed this for something so here we are. I think someone mentioned
they wanted this? Welp its here now
> 
> New argument is ``--configuration`` by default release but you can
pass in anything else. Probably debug or tools


</details>

Co-authored-by: SimpleStation14 <Unknown>
Co-authored-by: VMSolidus <evilexecutive@gmail.com>
2024-07-09 19:52:39 -04:00

80 lines
2.4 KiB
C#

using System.Diagnostics;
using System.IO.Compression;
using Robust.Packaging;
using Robust.Packaging.AssetProcessing;
using Robust.Packaging.AssetProcessing.Passes;
using Robust.Packaging.Utility;
using Robust.Shared.Timing;
namespace Content.Packaging;
public static class ClientPackaging
{
/// <summary>
/// Be advised this can be called from server packaging during a HybridACZ build.
/// </summary>
public static async Task PackageClient(bool skipBuild, string configuration, IPackageLogger logger)
{
logger.Info("Building client...");
if (!skipBuild)
{
await ProcessHelpers.RunCheck(new ProcessStartInfo
{
FileName = "dotnet",
ArgumentList =
{
"build",
Path.Combine("Content.Client", "Content.Client.csproj"),
"-c", configuration,
"--nologo",
"/v:m",
"/t:Rebuild",
"/p:FullRelease=true",
"/m"
}
});
}
logger.Info("Packaging client...");
var sw = RStopwatch.StartNew();
{
await using var zipFile =
File.Open(Path.Combine("release", "SS14.Client.zip"), FileMode.Create, FileAccess.ReadWrite);
using var zip = new ZipArchive(zipFile, ZipArchiveMode.Update);
var writer = new AssetPassZipWriter(zip);
await WriteResources("", writer, logger, default);
await writer.FinishedTask;
}
logger.Info($"Finished packaging client in {sw.Elapsed}");
}
public static async Task WriteResources(
string contentDir,
AssetPass pass,
IPackageLogger logger,
CancellationToken cancel)
{
var graph = new RobustClientAssetGraph();
pass.Dependencies.Add(new AssetPassDependency(graph.Output.Name));
AssetGraph.CalculateGraph(graph.AllPasses.Append(pass).ToArray(), logger);
var inputPass = graph.Input;
await RobustSharedPackaging.WriteContentAssemblies(
inputPass,
contentDir,
"Content.Client",
new[] { "Content.Client", "Content.Shared", "Content.Shared.Database" },
cancel: cancel);
await RobustClientPackaging.WriteClientResources(contentDir, pass, cancel);
inputPass.InjectFinished();
}
}