Browse Source

Add a new option to set a prefix for generated files in CLI.

pull/1516/head
Joao Matos 5 years ago committed by João Matos
parent
commit
02049cf690
  1. 1
      src/CLI/CLI.cs
  2. 4
      src/CLI/Generator.cs
  3. 2
      src/CLI/Options.cs

1
src/CLI/CLI.cs

@ -32,6 +32,7 @@ namespace CppSharp @@ -32,6 +32,7 @@ namespace CppSharp
optionSet.Add("g=|gen=|generator=", "the {TYPE} of generated code: 'csharp' or 'cli' ('cli' supported only for Windows)", g => { GetGeneratorKind(g, errorMessages); } );
optionSet.Add("p=|platform=", "the {PLATFORM} that the generated code will target: 'win', 'osx' or 'linux'", p => { GetDestinationPlatform(p, errorMessages); } );
optionSet.Add("a=|arch=", "the {ARCHITECTURE} that the generated code will target: 'x86' or 'x64'", a => { GetDestinationArchitecture(a, errorMessages); } );
optionSet.Add("prefix=", "sets a string prefix to the names of generated files", a => { options.Prefix = a; });
optionSet.Add("exceptions", "enables support for C++ exceptions in the parser", v => { options.EnableExceptions = true; });
optionSet.Add("rtti", "enables support for C++ RTTI in the parser", v => { options.EnableRTTI = true; });

4
src/CLI/Generator.cs

@ -187,6 +187,10 @@ namespace CppSharp @@ -187,6 +187,10 @@ namespace CppSharp
driverOptions.OutputDir = options.OutputDir;
driverOptions.CheckSymbols = options.CheckSymbols;
driverOptions.Verbose = options.Verbose;
if (!string.IsNullOrEmpty(options.Prefix))
driverOptions.GenerateName = name =>
options.Prefix + name.FileNameWithoutExtension;
}
private void SetupLinuxOptions(ParserOptions parserOptions)

2
src/CLI/Options.cs

@ -30,6 +30,8 @@ namespace CppSharp @@ -30,6 +30,8 @@ namespace CppSharp
public string OutputFileName { get; set; }
public string InputLibraryName { get; set; }
public string Prefix { get; set; }
public TargetPlatform? Platform { get; set; }

Loading…
Cancel
Save