Browse Source

Improve module naming heuristics and add an option for setting it explicitly.

pull/1516/head
Joao Matos 5 years ago committed by João Matos
parent
commit
62c030a86c
  1. 2
      src/CLI/CLI.cs
  2. 12
      src/CLI/Generator.cs

2
src/CLI/CLI.cs

@ -24,6 +24,8 @@ namespace CppSharp
optionSet.Add("o=|output=", "the {PATH} for the generated bindings file (doesn't need the extension since it will depend on the generator)", v => HandleOutputArg(v, errorMessages) ); optionSet.Add("o=|output=", "the {PATH} for the generated bindings file (doesn't need the extension since it will depend on the generator)", v => HandleOutputArg(v, errorMessages) );
optionSet.Add("on=|outputnamespace=", "the {NAMESPACE} that will be used for the generated code", on => options.OutputNamespace = on ); optionSet.Add("on=|outputnamespace=", "the {NAMESPACE} that will be used for the generated code", on => options.OutputNamespace = on );
optionSet.Add("m=|module=", "the name for the generated {MODULE}", a => { options.OutputFileName = a; });
optionSet.Add("iln=|inputlibraryname=|inputlib=", "the {NAME} of the shared library that contains the symbols of the generated code", iln => options.InputLibraryName = iln ); optionSet.Add("iln=|inputlibraryname=|inputlib=", "the {NAME} of the shared library that contains the symbols of the generated code", iln => options.InputLibraryName = iln );
optionSet.Add("d|debug", "enables debug mode which generates more verbose code to aid debugging", v => options.Debug = true); optionSet.Add("d|debug", "enables debug mode which generates more verbose code to aid debugging", v => options.Debug = true);
optionSet.Add("c|compile", "enables automatic compilation of the generated code", v => options.Compile = true); optionSet.Add("c|compile", "enables automatic compilation of the generated code", v => options.Compile = true);

12
src/CLI/Generator.cs

@ -86,8 +86,16 @@ namespace CppSharp
options.OutputDir = Path.Combine(Directory.GetCurrentDirectory(), "gen"); options.OutputDir = Path.Combine(Directory.GetCurrentDirectory(), "gen");
} }
var dir = Path.GetDirectoryName(options.HeaderFiles.First()); string moduleName;
var moduleName = new DirectoryInfo(dir).Name; if (options.HeaderFiles.Count == 1)
{
moduleName = Path.GetFileNameWithoutExtension(options.HeaderFiles.First());
}
else
{
var dir = Path.GetDirectoryName(options.HeaderFiles.First());
moduleName = new DirectoryInfo(dir).Name;
}
if (string.IsNullOrEmpty(options.OutputFileName)) if (string.IsNullOrEmpty(options.OutputFileName))
options.OutputFileName = moduleName; options.OutputFileName = moduleName;

Loading…
Cancel
Save