Content-side changes for packaging. (#9382)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Pieter-Jan Briers
2022-09-14 11:39:55 +02:00
committed by GitHub
parent 1e30848cf7
commit 7cd0677708
8 changed files with 155 additions and 3 deletions

View File

@@ -5,7 +5,6 @@ using NUnit.Framework;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
namespace Content.IntegrationTests.Tests
{

View File

@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\RobustToolbox\Robust.Packaging\Robust.Packaging.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,32 @@
using Robust.Packaging;
using Robust.Packaging.AssetProcessing;
namespace Content.Packaging;
public static class ContentPackaging
{
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 RobustClientPackaging.WriteContentAssemblies(
inputPass,
contentDir,
"Content.Client",
new[] { "Content.Client", "Content.Shared", "Content.Shared.Database" },
cancel);
await RobustClientPackaging.WriteClientResources(contentDir, inputPass, cancel);
inputPass.InjectFinished();
}
}

View File

@@ -0,0 +1,68 @@
using System.Diagnostics;
using System.IO.Compression;
using Content.Packaging;
using Robust.Packaging;
using Robust.Packaging.AssetProcessing.Passes;
using Robust.Packaging.Utility;
using Robust.Shared.Timing;
IPackageLogger logger = new PackageLoggerConsole();
logger.Info("Clearing release/ directory");
Directory.CreateDirectory("release");
var skipBuild = args.Contains("--skip-build");
if (!skipBuild)
WipeBin();
await Build(skipBuild);
async Task Build(bool skipBuild)
{
logger.Info("Building project...");
if (!skipBuild)
{
await ProcessHelpers.RunCheck(new ProcessStartInfo
{
FileName = "dotnet",
ArgumentList =
{
"build",
Path.Combine("Content.Client", "Content.Client.csproj"),
"-c", "Release",
"--nologo",
"/v:m",
"/t:Rebuild",
"/p:FullRelease=true",
"/m"
}
});
}
logger.Info("Packaging client...");
var sw = RStopwatch.StartNew();
{
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 ContentPackaging.WriteResources("", writer, logger, default);
await writer.FinishedTask;
}
logger.Info($"Finished packaging in {sw.Elapsed}");
}
void WipeBin()
{
logger.Info("Clearing old build artifacts (if any)...");
Directory.Delete("bin", recursive: true);
}

View File

@@ -0,0 +1,25 @@
using System.Threading;
using System.Threading.Tasks;
using Content.Packaging;
using Robust.Packaging;
using Robust.Packaging.AssetProcessing;
using Robust.Server.ServerStatus;
namespace Content.Server.Acz;
public sealed class ContentMagicAczProvider : IMagicAczProvider
{
private readonly IDependencyCollection _deps;
public ContentMagicAczProvider(IDependencyCollection deps)
{
_deps = deps;
}
public async Task Package(AssetPass pass, IPackageLogger logger, CancellationToken cancel)
{
var contentDir = DefaultMagicAczProvider.FindContentRootPath(_deps);
await ContentPackaging.WriteResources(contentDir, pass, logger, cancel);
}
}

View File

@@ -18,6 +18,7 @@
<PackageReference Include="JetBrains.Annotations" Version="2022.1.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Content.Packaging\Content.Packaging.csproj" />
<ProjectReference Include="..\Content.Server.Database\Content.Server.Database.csproj" />
<ProjectReference Include="..\RobustToolbox\Lidgren.Network\Lidgren.Network.csproj" />
<ProjectReference Include="..\RobustToolbox\Robust.Shared.Maths\Robust.Shared.Maths.csproj" />

View File

@@ -1,3 +1,4 @@
using Content.Server.Acz;
using Content.Server.Administration;
using Content.Server.Administration.Logs;
using Content.Server.Administration.Managers;
@@ -45,8 +46,8 @@ namespace Content.Server.Entry
{
base.Init();
IoCManager.Resolve<IStatusHost>().SetAczInfo("Content.Client",
new[] { "Content.Client", "Content.Shared", "Content.Shared.Database" });
var aczProvider = new ContentMagicAczProvider(IoCManager.Resolve<IDependencyCollection>());
IoCManager.Resolve<IStatusHost>().SetMagicAczProvider(aczProvider);
var factory = IoCManager.Resolve<IComponentFactory>();
var prototypes = IoCManager.Resolve<IPrototypeManager>();

View File

@@ -100,6 +100,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Content.Shared.Database", "
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Content.MapRenderer", "Content.MapRenderer\Content.MapRenderer.csproj", "{199BBEA1-7627-434B-B6F6-0F52A7C0E1E0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Robust.Packaging", "RobustToolbox\Robust.Packaging\Robust.Packaging.csproj", "{952AAF2A-DF63-4A7D-8094-3453893EBA80}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Content.Packaging", "Content.Packaging\Content.Packaging.csproj", "{424445D4-F5D9-4CA9-A435-0A36E8AA28F3}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Project Files", "Project Files", "{EC27A16C-9412-4AA6-AE68-CAAB28882802}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
@@ -241,6 +244,14 @@ Global
{199BBEA1-7627-434B-B6F6-0F52A7C0E1E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{199BBEA1-7627-434B-B6F6-0F52A7C0E1E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{199BBEA1-7627-434B-B6F6-0F52A7C0E1E0}.Release|Any CPU.Build.0 = Release|Any CPU
{952AAF2A-DF63-4A7D-8094-3453893EBA80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{952AAF2A-DF63-4A7D-8094-3453893EBA80}.Debug|Any CPU.Build.0 = Debug|Any CPU
{952AAF2A-DF63-4A7D-8094-3453893EBA80}.Release|Any CPU.ActiveCfg = Release|Any CPU
{952AAF2A-DF63-4A7D-8094-3453893EBA80}.Release|Any CPU.Build.0 = Release|Any CPU
{424445D4-F5D9-4CA9-A435-0A36E8AA28F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{424445D4-F5D9-4CA9-A435-0A36E8AA28F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{424445D4-F5D9-4CA9-A435-0A36E8AA28F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{424445D4-F5D9-4CA9-A435-0A36E8AA28F3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -268,6 +279,7 @@ Global
{88B0FC0F-7209-40E2-AF16-EB90AF727C5B} = {83B4CBBA-547A-42F0-A7CD-8A67D93196CE}
{A3C5B00A-D232-4A01-B82E-B0E58BFD5C12} = {83B4CBBA-547A-42F0-A7CD-8A67D93196CE}
{8A21C7CA-2EB8-40E5-8043-33582C06D139} = {83B4CBBA-547A-42F0-A7CD-8A67D93196CE}
{952AAF2A-DF63-4A7D-8094-3453893EBA80} = {83B4CBBA-547A-42F0-A7CD-8A67D93196CE}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AA37ED9F-F8D6-468E-A101-658AD605B09A}