Content-side changes for packaging. (#9382)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
committed by
GitHub
parent
1e30848cf7
commit
7cd0677708
14
Content.Packaging/Content.Packaging.csproj
Normal file
14
Content.Packaging/Content.Packaging.csproj
Normal 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>
|
||||
32
Content.Packaging/ContentPackaging.cs
Normal file
32
Content.Packaging/ContentPackaging.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
68
Content.Packaging/Program.cs
Normal file
68
Content.Packaging/Program.cs
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user