diff --git a/src/Generator/Driver.cs b/src/Generator/Driver.cs index 6e6e4144..6261f569 100644 --- a/src/Generator/Driver.cs +++ b/src/Generator/Driver.cs @@ -1,5 +1,4 @@ -using System; -using System.CodeDom.Compiler; +using System.CodeDom.Compiler; using System.Collections.Generic; using System.Globalization; using System.IO; @@ -33,6 +32,8 @@ namespace CppSharp public ASTContext ASTContext { get; private set; } public SymbolContext Symbols { get; private set; } + public bool HasCompilationErrors { get; set; } + private static readonly Dictionary libraryMappings = new Dictionary(); public Driver(DriverOptions options, IDiagnosticConsumer diagnostics) @@ -398,6 +399,7 @@ namespace CppSharp !compilerParameters.ReferencedAssemblies.Contains(libraryMappings[d])) .Select(l => libraryMappings[l])).ToArray()); + Diagnostics.Message("Compiling generated code..."); CompilerResults compilerResults; using (var codeProvider = new CSharpCodeProvider( new Dictionary { { "CompilerVersion", "v4.0" } })) @@ -405,17 +407,22 @@ namespace CppSharp compilerResults = codeProvider.CompileAssemblyFromDom( compilerParameters, compileUnits.ToArray()); } - - var errors = compilerResults.Errors.Cast(); - foreach (var error in errors.Where(error => !error.IsWarning)) + + var errors = compilerResults.Errors.Cast().Where(e => !e.IsWarning).ToList(); + foreach (var error in errors) Diagnostics.Error(error.ToString()); - if (compilerResults.Errors.Count == 0) + if (errors.Count == 0) { + Diagnostics.Message("Compilation succeeded."); var wrapper = Path.Combine(outputDir, assemblyFile); foreach (var library in Options.Libraries) libraryMappings[library] = wrapper; } + else + { + HasCompilationErrors = true; + } } public void AddTranslationUnitPass(TranslationUnitPass pass)