Skip to content

Commit 62c030a

Browse files
committed
Improve module naming heuristics and add an option for setting it explicitly.
1 parent 21b93dd commit 62c030a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/CLI/CLI.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ static bool ParseCommandLineArgs(string[] args, List<string> errorMessages, ref
2424
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) );
2525
optionSet.Add("on=|outputnamespace=", "the {NAMESPACE} that will be used for the generated code", on => options.OutputNamespace = on );
2626

27+
optionSet.Add("m=|module=", "the name for the generated {MODULE}", a => { options.OutputFileName = a; });
28+
2729
optionSet.Add("iln=|inputlibraryname=|inputlib=", "the {NAME} of the shared library that contains the symbols of the generated code", iln => options.InputLibraryName = iln );
2830
optionSet.Add("d|debug", "enables debug mode which generates more verbose code to aid debugging", v => options.Debug = true);
2931
optionSet.Add("c|compile", "enables automatic compilation of the generated code", v => options.Compile = true);

src/CLI/Generator.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,16 @@ public bool ValidateOptions(List<string> messages)
8686
options.OutputDir = Path.Combine(Directory.GetCurrentDirectory(), "gen");
8787
}
8888

89-
var dir = Path.GetDirectoryName(options.HeaderFiles.First());
90-
var moduleName = new DirectoryInfo(dir).Name;
89+
string moduleName;
90+
if (options.HeaderFiles.Count == 1)
91+
{
92+
moduleName = Path.GetFileNameWithoutExtension(options.HeaderFiles.First());
93+
}
94+
else
95+
{
96+
var dir = Path.GetDirectoryName(options.HeaderFiles.First());
97+
moduleName = new DirectoryInfo(dir).Name;
98+
}
9199

92100
if (string.IsNullOrEmpty(options.OutputFileName))
93101
options.OutputFileName = moduleName;

0 commit comments

Comments
 (0)