From 7bb3985e1238d757451cfaff17600053c9de0e89 Mon Sep 17 00:00:00 2001 From: wixoaGit Date: Thu, 19 Oct 2023 22:51:40 -0400 Subject: [PATCH] Move to a new `OpenDreamPackageTool` project Ran into file locking issues with OpenDreamPackaging as a dependency --- OpenDream.sln | 13 ++ .../ClientPackaging.cs | 2 +- .../PlatformReg.cs | 2 +- .../ServerPackaging.cs | 2 +- .../TgsPackaging.cs | 2 +- OpenDreamPackaging/Program.cs | 213 +----------------- 6 files changed, 19 insertions(+), 215 deletions(-) rename {OpenDreamPackaging => OpenDreamPackageTool}/ClientPackaging.cs (98%) rename {OpenDreamPackaging => OpenDreamPackageTool}/PlatformReg.cs (86%) rename {OpenDreamPackaging => OpenDreamPackageTool}/ServerPackaging.cs (99%) rename {OpenDreamPackaging => OpenDreamPackageTool}/TgsPackaging.cs (98%) diff --git a/OpenDream.sln b/OpenDream.sln index bc0d5a7dd3..7c81824472 100644 --- a/OpenDream.sln +++ b/OpenDream.sln @@ -99,6 +99,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenDreamPackaging", "OpenD EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Robust.Serialization.Generator", "RobustToolbox\Robust.Serialization.Generator\Robust.Serialization.Generator.csproj", "{366AA569-0889-491B-AB00-F038EAEC5221}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenDreamPackageTool", "OpenDreamPackageTool\OpenDreamPackageTool.csproj", "{351729DE-F70D-4136-AD48-1E08A715C1B1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -428,6 +430,16 @@ Global {366AA569-0889-491B-AB00-F038EAEC5221}.Release|x64.Build.0 = Release|Any CPU {366AA569-0889-491B-AB00-F038EAEC5221}.Tools|Any CPU.ActiveCfg = Debug|Any CPU {366AA569-0889-491B-AB00-F038EAEC5221}.Tools|Any CPU.Build.0 = Debug|Any CPU + {351729DE-F70D-4136-AD48-1E08A715C1B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {351729DE-F70D-4136-AD48-1E08A715C1B1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {351729DE-F70D-4136-AD48-1E08A715C1B1}.Debug|x64.ActiveCfg = Debug|Any CPU + {351729DE-F70D-4136-AD48-1E08A715C1B1}.Debug|x64.Build.0 = Debug|Any CPU + {351729DE-F70D-4136-AD48-1E08A715C1B1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {351729DE-F70D-4136-AD48-1E08A715C1B1}.Release|Any CPU.Build.0 = Release|Any CPU + {351729DE-F70D-4136-AD48-1E08A715C1B1}.Release|x64.ActiveCfg = Release|Any CPU + {351729DE-F70D-4136-AD48-1E08A715C1B1}.Release|x64.Build.0 = Release|Any CPU + {351729DE-F70D-4136-AD48-1E08A715C1B1}.Tools|Any CPU.ActiveCfg = Debug|Any CPU + {351729DE-F70D-4136-AD48-1E08A715C1B1}.Tools|Any CPU.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -459,6 +471,7 @@ Global {CBF4EBB8-A6A0-446F-82D4-B1D24FF5B3FF} = {534AFACE-24AF-4F54-B7B0-951C5D62DF34} {F3735A7F-44A2-4BEE-ADD6-952577D4DC33} = {DBFD7471-84E2-4AAB-86E9-F8DFF917ED5B} {D080D3FA-CE53-40D2-AC9A-940FD9EB5055} = {DBFD7471-84E2-4AAB-86E9-F8DFF917ED5B} + {366AA569-0889-491B-AB00-F038EAEC5221} = {DBFD7471-84E2-4AAB-86E9-F8DFF917ED5B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {970174FD-D22D-44D9-A410-F82A015E6F74} diff --git a/OpenDreamPackaging/ClientPackaging.cs b/OpenDreamPackageTool/ClientPackaging.cs similarity index 98% rename from OpenDreamPackaging/ClientPackaging.cs rename to OpenDreamPackageTool/ClientPackaging.cs index 532832fe65..55e8fa6537 100644 --- a/OpenDreamPackaging/ClientPackaging.cs +++ b/OpenDreamPackageTool/ClientPackaging.cs @@ -1,6 +1,6 @@ using System.Diagnostics; -namespace OpenDreamPackaging; +namespace OpenDreamPackageTool; public static class ClientPackaging { private static readonly string[] ClientIgnoredResources = { diff --git a/OpenDreamPackaging/PlatformReg.cs b/OpenDreamPackageTool/PlatformReg.cs similarity index 86% rename from OpenDreamPackaging/PlatformReg.cs rename to OpenDreamPackageTool/PlatformReg.cs index e75e7549f8..baf7524b9c 100644 --- a/OpenDreamPackaging/PlatformReg.cs +++ b/OpenDreamPackageTool/PlatformReg.cs @@ -1,4 +1,4 @@ -namespace OpenDreamPackaging; +namespace OpenDreamPackageTool; public record PlatformReg(string RId, string TargetOs, bool BuildByDefault) { public string RId = RId; diff --git a/OpenDreamPackaging/ServerPackaging.cs b/OpenDreamPackageTool/ServerPackaging.cs similarity index 99% rename from OpenDreamPackaging/ServerPackaging.cs rename to OpenDreamPackageTool/ServerPackaging.cs index a9bc099baa..124b8b84b4 100644 --- a/OpenDreamPackaging/ServerPackaging.cs +++ b/OpenDreamPackageTool/ServerPackaging.cs @@ -1,7 +1,7 @@ using System.Diagnostics; using System.IO.Compression; -namespace OpenDreamPackaging; +namespace OpenDreamPackageTool; public static class ServerPackaging { public static readonly PlatformReg[] Platforms = { diff --git a/OpenDreamPackaging/TgsPackaging.cs b/OpenDreamPackageTool/TgsPackaging.cs similarity index 98% rename from OpenDreamPackaging/TgsPackaging.cs rename to OpenDreamPackageTool/TgsPackaging.cs index 702b8533ca..4e4ac96024 100644 --- a/OpenDreamPackaging/TgsPackaging.cs +++ b/OpenDreamPackageTool/TgsPackaging.cs @@ -1,6 +1,6 @@ using System.Diagnostics; -namespace OpenDreamPackaging; +namespace OpenDreamPackageTool; public static class TgsPackaging { public static void Package(Program.TgsOptions options) { diff --git a/OpenDreamPackaging/Program.cs b/OpenDreamPackaging/Program.cs index 9bba242173..4c63beb151 100644 --- a/OpenDreamPackaging/Program.cs +++ b/OpenDreamPackaging/Program.cs @@ -1,216 +1,7 @@ -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; - namespace OpenDreamPackaging; public static class Program { - public class Options { - public string OutputDir = "release/"; - public bool SkipBuild; - } - - public class ServerOptions : Options { - public PlatformReg? Platform; - public bool HybridAcz; - public bool InPlatformSubDir = true; - public bool TgsEngineBuild; - } - - public class ClientOptions : Options { - public PlatformReg? Platform; - } - - public class TgsOptions : Options { - public PlatformReg? Platform; - } - - public static readonly string[] SharedIgnoredResources = { - ".gitignore", - ".directory", - ".DS_Store" - }; - - public static int Main(string[] args) { - if (!TryParseArgs(args, out var options)) - return 1; - - switch (options) { - case ServerOptions serverOptions: - ServerPackaging.Package(serverOptions); - break; - case ClientOptions clientOptions: - ClientPackaging.Package(clientOptions); - break; - case TgsOptions tgsOptions: - TgsPackaging.Package(tgsOptions); - break; - } - - return 0; - } - - public static void RunSubProcess(ProcessStartInfo startInfo) { - using Process process = new(); - - process.StartInfo = startInfo; - process.OutputDataReceived += ProcessOutputDataReceived; - process.Start(); - process.WaitForExit(); - if (process.ExitCode != 0) { - Environment.Exit(process.ExitCode); - } - } - - public static void CopyDirectory(string src, string dest, string[]? skip = null) { - skip ??= Array.Empty(); - - var srcDir = new DirectoryInfo(src); - if (!srcDir.Exists) - throw new Exception($"Source directory not found: {src}"); - - Directory.CreateDirectory(dest); - - foreach (var file in srcDir.EnumerateFiles()) { - if (skip.Contains(file.Name)) - continue; - - file.CopyTo(Path.Combine(dest, file.Name)); - } - - foreach (var subDir in srcDir.EnumerateDirectories()) { - if (skip.Contains(subDir.Name)) - continue; - - CopyDirectory(subDir.FullName, Path.Combine(dest, subDir.Name)); - } - } - - private static void ProcessOutputDataReceived(object sender, DataReceivedEventArgs args) { - if (args.Data == null) - return; - - Console.Write(args.Data); - } - - private static bool TryParseArgs(string[] args, [NotNullWhen(true)] out Options? options) { - if (args.Contains("--server")) { - var serverOptions = new ServerOptions(); - - options = serverOptions; - for (int i = 0; i < args.Length; i++) { - var arg = args[i]; - - switch (arg) { - case "--server": - break; - case "--output": - case "-o": - serverOptions.OutputDir = args[++i]; - break; - case "--skip-build": - serverOptions.SkipBuild = true; - break; - case "--platform": - case "-p": - if (i + 1 >= args.Length) { - Console.Error.WriteLine("No platform given"); - return false; - } - - var platformRId = args[++i]; - - serverOptions.Platform = - ServerPackaging.Platforms.First(p => p.RId == platformRId); - if (serverOptions.Platform == null) { - Console.Error.WriteLine($"Invalid platform '{platformRId}'"); - return false; - } - - break; - case "--hybrid-acz": - serverOptions.HybridAcz = true; - break; - default: - Console.Error.WriteLine($"Unknown argument '{arg}'"); - return false; - } - } - - return true; - } else if (args.Contains("--client")) { - var clientOptions = new ClientOptions(); - - options = clientOptions; - for (int i = 0; i < args.Length; i++) { - var arg = args[i]; - - switch (arg) { - case "--client": - break; - case "--output": - case "-o": - clientOptions.OutputDir = args[++i]; - break; - case "--skip-build": - clientOptions.SkipBuild = true; - break; - default: - Console.Error.WriteLine($"Unknown argument '{arg}'"); - return false; - } - } - - return true; - } else if (args.Contains("--tgs")) { - var tgsOptions = new TgsOptions(); - - options = tgsOptions; - for (int i = 0; i < args.Length; i++) { - var arg = args[i]; - - switch (arg) { - case "--tgs": - break; - case "--output": - case "-o": - tgsOptions.OutputDir = args[++i]; - break; - case "--skip-build": - tgsOptions.SkipBuild = true; - break; - case "--platform": - case "-p": - if (i + 1 >= args.Length) { - Console.Error.WriteLine("No platform given"); - return false; - } - - var platformRId = args[++i]; - - tgsOptions.Platform = - ServerPackaging.Platforms.First(p => p.RId == platformRId); - if (tgsOptions.Platform == null) { - Console.Error.WriteLine($"Invalid platform '{platformRId}'"); - return false; - } - - break; - default: - Console.Error.WriteLine($"Unknown argument '{arg}'"); - return false; - } - } - - if (tgsOptions.Platform == null) { - Console.Error.WriteLine("A '--platform' argument is required for a tgs package"); - return false; - } - - return true; - } - - options = null; - Console.Error.WriteLine("One of '--server' or '--client' must be given"); - return false; + public static void Main() { + throw new NotImplementedException(); } }