generate glenum, link glenum, add source gen for text regex
This commit is contained in:
@@ -42,18 +42,20 @@ namespace StgSharp.GenerateGL
|
||||
return SuccessExitCode;
|
||||
}
|
||||
|
||||
if (arguments.Count > 1)
|
||||
if (arguments.Count == 0 || arguments.Count > 2 ||
|
||||
!TryReadTarget(arguments[0], out GlGenerationTarget target))
|
||||
{
|
||||
Console.Error.WriteLine("error: generate accepts at most one output directory.");
|
||||
Console.Error.WriteLine(
|
||||
"error: generate requires api, enum, or all and accepts one optional output directory.");
|
||||
Console.Error.WriteLine("Run 'generate --help' for command information.");
|
||||
return UsageErrorExitCode;
|
||||
}
|
||||
|
||||
string? outputDirectory = arguments.Count == 1 ? arguments[0] : null;
|
||||
string? outputDirectory = arguments.Count == 2 ? arguments[1] : null;
|
||||
string? resolvedOutputDirectory = null;
|
||||
try
|
||||
{
|
||||
generatedFiles = OpenGlGenerator.Generate(projection);
|
||||
generatedFiles = OpenGlGenerator.Generate(projection, target);
|
||||
if (outputDirectory is not null)
|
||||
{
|
||||
resolvedOutputDirectory = WriteGeneratedFiles(
|
||||
@@ -103,6 +105,21 @@ namespace StgSharp.GenerateGL
|
||||
return SuccessExitCode;
|
||||
}
|
||||
|
||||
private static bool TryReadTarget(
|
||||
string value,
|
||||
out GlGenerationTarget target
|
||||
)
|
||||
{
|
||||
target = value.ToUpperInvariant() switch
|
||||
{
|
||||
"API" => GlGenerationTarget.Api,
|
||||
"ENUM" or "ENUMS" => GlGenerationTarget.Enum,
|
||||
"ALL" => GlGenerationTarget.All,
|
||||
_ => GlGenerationTarget.None,
|
||||
};
|
||||
return target != GlGenerationTarget.None;
|
||||
}
|
||||
|
||||
private static string WriteGeneratedFiles(
|
||||
GeneratedFileSet files,
|
||||
string outputDirectory
|
||||
@@ -217,7 +234,7 @@ namespace StgSharp.GenerateGL
|
||||
if (files.Files.Count == 0)
|
||||
{
|
||||
Console.Error.WriteLine("No generated files are held in this session.");
|
||||
Console.Error.WriteLine("Run 'generate' first.");
|
||||
Console.Error.WriteLine("Run 'generate api', 'generate enum', or 'generate all' first.");
|
||||
return QueryErrorExitCode;
|
||||
}
|
||||
|
||||
@@ -251,7 +268,8 @@ namespace StgSharp.GenerateGL
|
||||
$"No generated file named '{arguments[0]}' is held in this session.");
|
||||
if (files.Files.Count == 0)
|
||||
{
|
||||
Console.Error.WriteLine("Run 'generate' first.");
|
||||
Console.Error.WriteLine(
|
||||
"Run 'generate api', 'generate enum', or 'generate all' first.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -271,12 +289,19 @@ namespace StgSharp.GenerateGL
|
||||
Console.WriteLine("Generate C# bindings from the loaded OpenGL registry.");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Usage:");
|
||||
Console.WriteLine(" generate");
|
||||
Console.WriteLine(" generate <output-directory>");
|
||||
Console.WriteLine(" generate api [output-directory]");
|
||||
Console.WriteLine(" generate enum [output-directory]");
|
||||
Console.WriteLine(" generate all [output-directory]");
|
||||
Console.WriteLine(" generate --help");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Targets:");
|
||||
Console.WriteLine(" api Generate function tables and managed forwarding APIs.");
|
||||
Console.WriteLine(" enum Generate glConst and strongly typed enum groups.");
|
||||
Console.WriteLine(" all Generate both API and enum files.");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Output:");
|
||||
Console.WriteLine(" Without a directory, output is retained in memory only.");
|
||||
Console.WriteLine(" API output references enum output; use all for a clean directory.");
|
||||
Console.WriteLine(" The output directory must already exist and be writable.");
|
||||
Console.WriteLine(" Existing files are replaced only when marked as generated.");
|
||||
Console.WriteLine();
|
||||
|
||||
Reference in New Issue
Block a user