Skip to content

Commit

Permalink
Added variation of mono#1736
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanL8 committed Aug 29, 2023
1 parent cafa6a0 commit 4125eda
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/CLI/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ public bool ValidateOptions(List<string> messages)
if (string.IsNullOrEmpty(options.OutputNamespace))
options.OutputNamespace = moduleName;

if (options.IncludeDirs.Count == 0)
options.IncludeDirs.Add(Path.GetDirectoryName(options.HeaderFiles.First()));

SetupTargetTriple();

return true;
Expand Down
7 changes: 6 additions & 1 deletion src/Generator/Driver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,12 @@ public static void Run(ILibrary library)
}

new CleanUnitPass { Context = driver.Context }.VisitASTContext(driver.Context.ASTContext);
options.Modules.RemoveAll(m => m != options.SystemModule && !m.Units.GetGenerated().Any());
foreach (var module in options.Modules.Where(
m => m != options.SystemModule && !m.Units.GetGenerated().Any()))
{
Diagnostics.Message($"Removing module {module} because no translation units are generated...");
options.Modules.Remove(module);
}

if (!options.Quiet)
Diagnostics.Message("Processing code...");
Expand Down
5 changes: 5 additions & 0 deletions src/Generator/Passes/CleanUnitPass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ private Module GetModule(TranslationUnit unit)
includeDir = ".";
includeDir = Path.GetFullPath(includeDir);

// Added in https://github.com/mono/CppSharp/pull/1736, but causes us issues.
// return Options.Modules.FirstOrDefault(
// m => m.IncludeDirs.Any(i => Path.GetFullPath(i) == includeDir)) ??
// Options.Modules[1];

Module module = Options.Modules.Find(
m => m.IncludeDirs.Any(i => Path.GetFullPath(i) == includeDir));
if (module == null)
Expand Down

0 comments on commit 4125eda

Please sign in to comment.