mirror of
https://github.com/ZuneDev/ZuneUIXTools.git
synced 2026-07-27 13:11:59 -07:00
Support multiple compilands and shared binary data tables
This commit is contained in:
@@ -14,21 +14,29 @@ public class CompileCommand : Command<CompileCommand.Settings>
|
||||
{
|
||||
public override int Execute(CommandContext context, Settings settings)
|
||||
{
|
||||
if (settings.Compilands.Length <= 0)
|
||||
if (settings.Compilands is null || settings.Compilands.Length <= 0)
|
||||
{
|
||||
Diagnostic.Error("Missing arguments: must specify a file to compile. Accepts XML and Asm source.");
|
||||
//AnsiConsole.MarkupLine("[red][/]");
|
||||
AnsiConsole.MarkupLine("[red]Missing arguments: must specify a file to compile. Accepts XML and Asm source.[/]");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// TODO: Support multiple compilands
|
||||
CompilerInput[] compilands = new CompilerInput[settings.Compilands.Length];
|
||||
for (int c = 0; c < settings.Compilands.Length; c++)
|
||||
{
|
||||
string sourcePath = settings.Compilands[0];
|
||||
CompilerInput compiland = new()
|
||||
compilands[c] = new()
|
||||
{
|
||||
SourceFileName = sourcePath,
|
||||
OutputFileName = Path.Combine(Environment.CurrentDirectory, Path.ChangeExtension(sourcePath, ".uib"))
|
||||
OutputFileName = SourceToCompiledPath(settings, sourcePath),
|
||||
};
|
||||
CompilerInput[] compilands = [compiland];
|
||||
}
|
||||
|
||||
CompilerInput dataTableInput = new();
|
||||
if (settings.DataTable is not null)
|
||||
{
|
||||
dataTableInput.SourceFileName = settings.DataTable;
|
||||
dataTableInput.OutputFileName = SourceToCompiledPath(settings, settings.DataTable);
|
||||
}
|
||||
|
||||
// Configure error and warning messages
|
||||
var report = new Report(new IrisSourceRepository(compilands, default));
|
||||
@@ -60,8 +68,7 @@ public class CompileCommand : Command<CompileCommand.Settings>
|
||||
MarkupSystem.Startup(true);
|
||||
Assembler.RegisterLoader();
|
||||
|
||||
// TODO: Support shared binary data tables
|
||||
var success = MarkupCompiler.Compile(compilands, default);
|
||||
var success = MarkupCompiler.Compile(compilands, dataTableInput);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
@@ -75,6 +82,12 @@ public class CompileCommand : Command<CompileCommand.Settings>
|
||||
}
|
||||
}
|
||||
|
||||
private static string SourceToCompiledPath(Settings settings, string sourceFilePath)
|
||||
{
|
||||
var outputDir = settings.OutputDir ?? Environment.CurrentDirectory;
|
||||
return Path.Combine(outputDir, Path.ChangeExtension(sourceFilePath, ".uib"));
|
||||
}
|
||||
|
||||
public sealed class Settings : CommandSettings
|
||||
{
|
||||
[Description("The source files to compile.")]
|
||||
@@ -89,6 +102,10 @@ public class CompileCommand : Command<CompileCommand.Settings>
|
||||
[CommandOption("-t|--dataTable")]
|
||||
public string? DataTable { get; init; }
|
||||
|
||||
[Description("The directory to output to.")]
|
||||
[CommandOption("-o|--output <outputDir>")]
|
||||
public string? OutputDir { get; init; }
|
||||
|
||||
[CommandOption("--verbose")]
|
||||
[DefaultValue(false)]
|
||||
public bool Verbose { get; init; }
|
||||
|
||||
@@ -11,6 +11,10 @@ internal class Program
|
||||
|
||||
app.Configure(config =>
|
||||
{
|
||||
config.AddCommand<CompileCommand>("compile")
|
||||
.WithAlias("c")
|
||||
.WithDescription("Compiles the given source to UIB.");
|
||||
|
||||
#if DEBUG
|
||||
config.PropagateExceptions();
|
||||
config.ValidateExamples();
|
||||
|
||||
Reference in New Issue
Block a user