diff --git a/src/Generator.Tests/ASTTestFixture.cs b/src/Generator.Tests/ASTTestFixture.cs index 91077f17..64df6bb9 100644 --- a/src/Generator.Tests/ASTTestFixture.cs +++ b/src/Generator.Tests/ASTTestFixture.cs @@ -20,6 +20,7 @@ namespace CppSharp.Generator.Tests Options.Headers.AddRange(files); Driver = new Driver(Options, new TextDiagnosticPrinter()); + Driver.BuildParseOptions(); if (!Driver.ParseCode()) throw new Exception("Error parsing the code"); diff --git a/src/Generator/Driver.cs b/src/Generator/Driver.cs index 7d544b62..584a4018 100644 --- a/src/Generator/Driver.cs +++ b/src/Generator/Driver.cs @@ -167,12 +167,6 @@ namespace CppSharp public bool ParseCode() { - foreach (var header in Options.Headers) - { - var source = Project.AddFile(header); - source.Options = BuildParseOptions(source); - } - var parser = new ClangParser(new Parser.AST.ASTContext()); parser.SourceParsed += OnSourceFileParsed; @@ -185,6 +179,15 @@ namespace CppSharp return true; } + public void BuildParseOptions() + { + foreach (var header in Options.Headers) + { + var source = Project.AddFile(header); + source.Options = BuildParseOptions(source); + } + } + public ParserTargetInfo TargetInfo { get; set; } public bool ParseLibraries() @@ -389,6 +392,8 @@ namespace CppSharp if (!options.Quiet) Log.EmitMessage("Parsing code..."); + driver.BuildParseOptions(); + if (!driver.ParseCode()) return;