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