Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional command to add a file header in each generated file #311

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions FFmpeg.AutoGen.CppSharpUnsafeGenerator/CliOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public class CliOptions
HelpText = "Print details during execution.")]
public bool Verbose { get; set; }

[Option("fileHeader",
HelpText = "Optional string to use as header for generated files.")]
public string FileHeader { get; set; }

public static CliOptions ParseArgumentsStrict(string[] args)
{
var result = CommandLine.Parser.Default.ParseArguments<CliOptions>(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ internal sealed record GenerationContext
public Dictionary<string, InlineFunctionDefinition> ExistingInlineFunctionMap { get; init; } = new();
public string SolutionDir { get; init; } = string.Empty;
public string OutputDir { get; init; } = string.Empty;
public string FileHeader { get; init; } = string.Empty;
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ void IDisposable.Dispose()

public virtual void Generate()
{
if (!string.IsNullOrEmpty(Context.FileHeader))
{
WriteLine(Context.FileHeader);
WriteLine();
}

var usings = Usings().ToList();
usings.ForEach(ns => WriteLine($"using {ns};"));
if (usings.Count > 0) WriteLine();
Expand Down
3 changes: 2 additions & 1 deletion FFmpeg.AutoGen.CppSharpUnsafeGenerator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ internal static void Main(string[] args)
.ToDictionary(x => x.LibraryName, x => x.LibraryVersion),
Definitions = processingContext.Definitions.ToArray(),
ExistingInlineFunctionMap = inlineFunctions.ToDictionary(f => f.Name),
SolutionDir = options.SolutionDir
SolutionDir = options.SolutionDir,
FileHeader = options.FileHeader,
};

GenerateLegacyFFmpegAutoGen(generationContext);
Expand Down