Open
Description
The current version of CppSharp generates only one file with Generator.OutputMode.FilePerModule
mode if header files are in the same include directory. ILibrary Setup method:
/// Setup the driver options here.
public void Setup(Driver driver)
{
//Set up the driver options.
driver.Options.GeneratorKind = GeneratorKind.CSharp;
driver.Options.OutputDir = "<Output_folder>/QtShatpNi/QtBase";
driver.Options.GenerationOutputMode = GenerationOutputMode.FilePerModule;
driver.Options.GenerateDeprecatedDeclarations = false;
// Set up parser options.
driver.ParserOptions.LanguageVersion = CppSharp.Parser.LanguageVersion.CPP17;
driver.ParserOptions.IncludeDirs = [@"<QT_path>\Qt\6.7.2\msvc2019_64\include", @"<QT_path>\Qt\6.7.2\msvc2019_64\include\QtCore"];
// Set up modules.
//AddModule(driver, "QTypeInfo", "qtypeinfo.h");
AddModule(driver, "QChar", "qchar.h");
AddModule(driver, "QNamespace", "qnamespace.h");
}
/// <summary>
/// Helper function to generate a module.
/// </summary>
/// <param name="driver"></param>
/// <param name="modulename"></param>
/// <param name="header"></param>
private void AddModule(Driver driver, string modulename, string header) {
var module = driver.Options.AddModule(modulename);
module.OutputNamespace = _namespace;
module.Headers.Add(header);
module.LibraryName = modulename;
module.SharedLibraryName = "Qt6Core.dll";
module.IncludeDirs.Add(driver.ParserOptions.IncludeDirs[1]);
}
I think this is caused by CleanUnitPass
associating unit passes with the first module with the same include path.
In the CleanUnitPass
module is determined by this method:
private Module GetModule(TranslationUnit unit)
{
if (unit.IsSystemHeader)
return Options.SystemModule;
var includeDir = Path.GetDirectoryName(unit.FilePath);
if (string.IsNullOrWhiteSpace(includeDir))
includeDir = ".";
includeDir = Path.GetFullPath(includeDir);
return Options.Modules.FirstOrDefault(
m => m.IncludeDirs.Any(i => Path.GetFullPath(i) == includeDir)) ??
Options.Modules[1];
}
Line return Options.Modules.FirstOrDefault
seem to cause the issue. I would remove CleanUnitPass
class and move the module unit association to be done at the parser rather than later.
Metadata
Metadata
Assignees
Labels
No labels