From a8911da2f339fd1bd1d34237e69b8e77a364c3c0 Mon Sep 17 00:00:00 2001
From: SimpleStation14 <130339894+SimpleStation14@users.noreply.github.com>
Date: Tue, 9 Jul 2024 16:52:39 -0700
Subject: [PATCH] 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
[space-wizards](https://github.com/space-wizards)/[space-station-14](https://github.com/space-wizards/space-station-14)
###### `9e7b196ffbaa8c0a772d5d7544e51deaa2fe5a26`
PR opened by
VasilisThePikachu at 2024-02-25 21:40:05 UTC
---
PR changed 4 files with 34 additions and 15 deletions.
The PR had the following labels:
---
Original Body
>
>
>
> Requires https://github.com/space-wizards/RobustToolbox/pull/4992
>
> ## About the 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
Co-authored-by: SimpleStation14
Co-authored-by: VMSolidus
---
Content.Packaging/ClientPackaging.cs | 4 ++--
Content.Packaging/CommandLineArgs.cs | 23 +++++++++++++++++++++--
Content.Packaging/Program.cs | 4 ++--
Content.Packaging/ServerPackaging.cs | 18 +++++++++---------
4 files changed, 34 insertions(+), 15 deletions(-)
diff --git a/Content.Packaging/ClientPackaging.cs b/Content.Packaging/ClientPackaging.cs
index a989ebd968..a66d4ec5b9 100644
--- a/Content.Packaging/ClientPackaging.cs
+++ b/Content.Packaging/ClientPackaging.cs
@@ -13,7 +13,7 @@ public static class ClientPackaging
///
/// Be advised this can be called from server packaging during a HybridACZ build.
///
- public static async Task PackageClient(bool skipBuild, IPackageLogger logger)
+ public static async Task PackageClient(bool skipBuild, string configuration, IPackageLogger logger)
{
logger.Info("Building client...");
@@ -26,7 +26,7 @@ await ProcessHelpers.RunCheck(new ProcessStartInfo
{
"build",
Path.Combine("Content.Client", "Content.Client.csproj"),
- "-c", "Release",
+ "-c", configuration,
"--nologo",
"/v:m",
"/t:Rebuild",
diff --git a/Content.Packaging/CommandLineArgs.cs b/Content.Packaging/CommandLineArgs.cs
index 9f2b075535..23f661921e 100644
--- a/Content.Packaging/CommandLineArgs.cs
+++ b/Content.Packaging/CommandLineArgs.cs
@@ -31,6 +31,11 @@ public sealed class CommandLineArgs
///
public bool HybridAcz { get; set; }
+ ///
+ /// Configuration used for when packaging the server. (Release, Debug, Tools)
+ ///
+ public string Configuration { get; set; }
+
// CommandLineArgs, 3rd of her name.
public static bool TryParse(IReadOnlyList args, [NotNullWhen(true)] out CommandLineArgs? parsed)
{
@@ -39,6 +44,7 @@ public static bool TryParse(IReadOnlyList args, [NotNullWhen(true)] out
var skipBuild = false;
var wipeRelease = true;
var hybridAcz = false;
+ var configuration = "Release";
List? platforms = null;
using var enumerator = args.GetEnumerator();
@@ -89,6 +95,16 @@ public static bool TryParse(IReadOnlyList args, [NotNullWhen(true)] out
platforms ??= new List();
platforms.Add(enumerator.Current);
}
+ else if (arg == "--configuration")
+ {
+ if (!enumerator.MoveNext())
+ {
+ Console.WriteLine("No configuration provided");
+ return false;
+ }
+
+ configuration = enumerator.Current;
+ }
else if (arg == "--help")
{
PrintHelp();
@@ -106,7 +122,7 @@ public static bool TryParse(IReadOnlyList args, [NotNullWhen(true)] out
return false;
}
- parsed = new CommandLineArgs(client.Value, skipBuild, wipeRelease, hybridAcz, platforms);
+ parsed = new CommandLineArgs(client.Value, skipBuild, wipeRelease, hybridAcz, platforms, configuration);
return true;
}
@@ -120,6 +136,7 @@ private static void PrintHelp()
--no-wipe-release Don't wipe the release folder before creating files.
--hybrid-acz Use HybridACZ for server builds.
--platform Platform for server builds. Default will output several x64 targets.
+ --configuration Configuration to use for building the server (Release, Debug, Tools). Default is Release.
");
}
@@ -128,12 +145,14 @@ private CommandLineArgs(
bool skipBuild,
bool wipeRelease,
bool hybridAcz,
- List? platforms)
+ List? platforms,
+ string configuration)
{
Client = client;
SkipBuild = skipBuild;
WipeRelease = wipeRelease;
HybridAcz = hybridAcz;
Platforms = platforms;
+ Configuration = configuration;
}
}
diff --git a/Content.Packaging/Program.cs b/Content.Packaging/Program.cs
index ba5924ec3e..65c0e0131a 100644
--- a/Content.Packaging/Program.cs
+++ b/Content.Packaging/Program.cs
@@ -17,11 +17,11 @@
if (parsed.Client)
{
- await ClientPackaging.PackageClient(parsed.SkipBuild, logger);
+ await ClientPackaging.PackageClient(parsed.SkipBuild, parsed.Configuration, logger);
}
else
{
- await ServerPackaging.PackageServer(parsed.SkipBuild, parsed.HybridAcz, logger, parsed.Platforms);
+ await ServerPackaging.PackageServer(parsed.SkipBuild, parsed.HybridAcz, logger, parsed.Configuration, parsed.Platforms);
}
void WipeBin()
diff --git a/Content.Packaging/ServerPackaging.cs b/Content.Packaging/ServerPackaging.cs
index ba489629f7..d9ca57c4d1 100644
--- a/Content.Packaging/ServerPackaging.cs
+++ b/Content.Packaging/ServerPackaging.cs
@@ -69,7 +69,7 @@ public static class ServerPackaging
"zh-Hant"
};
- public static async Task PackageServer(bool skipBuild, bool hybridAcz, IPackageLogger logger, List? platforms = null)
+ public static async Task PackageServer(bool skipBuild, bool hybridAcz, IPackageLogger logger, string configuration, List? platforms = null)
{
if (platforms == null)
{
@@ -82,7 +82,7 @@ public static async Task PackageServer(bool skipBuild, bool hybridAcz, IPackageL
// Rather than hosting the client ZIP on the watchdog or on a separate server,
// Hybrid ACZ uses the ACZ hosting functionality to host it as part of the status host,
// which means that features such as automatic UPnP forwarding still work properly.
- await ClientPackaging.PackageClient(skipBuild, logger);
+ await ClientPackaging.PackageClient(skipBuild, configuration, logger);
}
// Good variable naming right here.
@@ -91,13 +91,13 @@ public static async Task PackageServer(bool skipBuild, bool hybridAcz, IPackageL
if (!platforms.Contains(platform.Rid))
continue;
- await BuildPlatform(platform, skipBuild, hybridAcz, logger);
+ await BuildPlatform(platform, skipBuild, hybridAcz, configuration, logger);
}
}
- private static async Task BuildPlatform(PlatformReg platform, bool skipBuild, bool hybridAcz, IPackageLogger logger)
+ private static async Task BuildPlatform(PlatformReg platform, bool skipBuild, bool hybridAcz, string configuration, IPackageLogger logger)
{
- logger.Info($"Building project for {platform}...");
+ logger.Info($"Building project for {platform.TargetOs}...");
if (!skipBuild)
{
@@ -108,7 +108,7 @@ await ProcessHelpers.RunCheck(new ProcessStartInfo
{
"build",
Path.Combine("Content.Server", "Content.Server.csproj"),
- "-c", "Release",
+ "-c", configuration,
"--nologo",
"/v:m",
$"/p:TargetOs={platform.TargetOs}",
@@ -118,7 +118,7 @@ await ProcessHelpers.RunCheck(new ProcessStartInfo
}
});
- await PublishClientServer(platform.Rid, platform.TargetOs);
+ await PublishClientServer(platform.Rid, platform.TargetOs, configuration);
}
logger.Info($"Packaging {platform.Rid} server...");
@@ -137,7 +137,7 @@ await ProcessHelpers.RunCheck(new ProcessStartInfo
logger.Info($"Finished packaging server in {sw.Elapsed}");
}
- private static async Task PublishClientServer(string runtime, string targetOs)
+ private static async Task PublishClientServer(string runtime, string targetOs, string configuration)
{
await ProcessHelpers.RunCheck(new ProcessStartInfo
{
@@ -147,7 +147,7 @@ await ProcessHelpers.RunCheck(new ProcessStartInfo
"publish",
"--runtime", runtime,
"--no-self-contained",
- "-c", "Release",
+ "-c", configuration,
$"/p:TargetOs={targetOs}",
"/p:FullRelease=True",
"/m",