Browse Source

Merge branch 'mono:main' into main

pull/1695/head
hxbb00 2 years ago committed by GitHub
parent
commit
2bfa7b75a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      src/CLI/Generator.cs
  2. 7
      src/Generator/Driver.cs
  3. 11
      src/Generator/Passes/CleanUnitPass.cs
  4. 4
      src/Parser/ParserOptions.cs

3
src/CLI/Generator.cs

@ -108,6 +108,9 @@ namespace CppSharp @@ -108,6 +108,9 @@ namespace CppSharp
if (string.IsNullOrEmpty(options.OutputNamespace))
options.OutputNamespace = moduleName;
if (options.IncludeDirs.Count == 0)
options.IncludeDirs.Add(Path.GetDirectoryName(options.HeaderFiles.First()));
SetupTargetTriple();
return true;

7
src/Generator/Driver.cs

@ -439,7 +439,12 @@ namespace CppSharp @@ -439,7 +439,12 @@ namespace CppSharp
}
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...");

11
src/Generator/Passes/CleanUnitPass.cs

@ -31,14 +31,9 @@ namespace CppSharp.Passes @@ -31,14 +31,9 @@ namespace CppSharp.Passes
includeDir = ".";
includeDir = Path.GetFullPath(includeDir);
Module module = Options.Modules.Find(
m => m.IncludeDirs.Any(i => Path.GetFullPath(i) == includeDir));
if (module == null)
{
unit.ExplicitlyIgnore();
module = Options.Modules[1];
}
return module;
return Options.Modules.FirstOrDefault(
m => m.IncludeDirs.Any(i => Path.GetFullPath(i) == includeDir)) ??
Options.Modules[1];
}
public override bool VisitDeclarationContext(DeclarationContext context)

4
src/Parser/ParserOptions.cs

@ -240,9 +240,11 @@ namespace CppSharp.Parser @@ -240,9 +240,11 @@ namespace CppSharp.Parser
GetUnixCompilerInfo(headersPath, out var compiler, out var longVersion, out var shortVersion);
AddSystemIncludeDirs(BuiltinsDir);
AddArguments($"-fgnuc-version={longVersion}");
var majorVersion = shortVersion.Split('.')[0];
// Workaround https://github.com/llvm/llvm-project/issues/53152, remove once bug is fixed.
AddArguments(int.Parse(majorVersion) >= 11 ? $"-fgnuc-version=10.1" : $"-fgnuc-version={longVersion}");
string[] versions = { longVersion, shortVersion, majorVersion };
string[] triples = { "x86_64-linux-gnu", "x86_64-pc-linux-gnu" };
if (compiler == "gcc")

Loading…
Cancel
Save