|
|
@ -14,6 +14,7 @@ using CppSharp.Passes; |
|
|
|
using CppSharp.Types; |
|
|
|
using CppSharp.Types; |
|
|
|
using Microsoft.CSharp; |
|
|
|
using Microsoft.CSharp; |
|
|
|
using CppSharp.Parser; |
|
|
|
using CppSharp.Parser; |
|
|
|
|
|
|
|
using System.CodeDom; |
|
|
|
|
|
|
|
|
|
|
|
namespace CppSharp |
|
|
|
namespace CppSharp |
|
|
|
{ |
|
|
|
{ |
|
|
@ -337,14 +338,24 @@ namespace CppSharp |
|
|
|
if (Options.GenerateName != null) |
|
|
|
if (Options.GenerateName != null) |
|
|
|
fileBase = Options.GenerateName(output.TranslationUnit); |
|
|
|
fileBase = Options.GenerateName(output.TranslationUnit); |
|
|
|
|
|
|
|
|
|
|
|
foreach (var template in output.Templates) |
|
|
|
if (Options.IsCSharpGenerator && Options.CompileCode) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var fileRelativePath = string.Format("{0}.{1}", fileBase, template.FileExtension); |
|
|
|
compileUnits.AddRange( |
|
|
|
Diagnostics.Message("Generated '{0}'", fileRelativePath); |
|
|
|
output.Templates.Select(t => new CodeSnippetCompileUnit(t.Generate()))); |
|
|
|
|
|
|
|
compileUnits.AddRange( |
|
|
|
var file = Path.Combine(outputPath, fileRelativePath); |
|
|
|
Options.CodeFiles.Select(c => new CodeSnippetCompileUnit(File.ReadAllText(c)))); |
|
|
|
File.WriteAllText(file, template.Generate()); |
|
|
|
} |
|
|
|
Options.CodeFiles.Add(file); |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
foreach (var template in output.Templates) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var fileRelativePath = string.Format("{0}.{1}", fileBase, template.FileExtension); |
|
|
|
|
|
|
|
Diagnostics.Message("Generated '{0}'", fileRelativePath); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var file = Path.Combine(outputPath, fileRelativePath); |
|
|
|
|
|
|
|
File.WriteAllText(file, template.Generate()); |
|
|
|
|
|
|
|
Options.CodeFiles.Add(file); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -387,10 +398,13 @@ namespace CppSharp |
|
|
|
!compilerParameters.ReferencedAssemblies.Contains(libraryMappings[d])) |
|
|
|
!compilerParameters.ReferencedAssemblies.Contains(libraryMappings[d])) |
|
|
|
.Select(l => libraryMappings[l])).ToArray()); |
|
|
|
.Select(l => libraryMappings[l])).ToArray()); |
|
|
|
|
|
|
|
|
|
|
|
var codeProvider = new CSharpCodeProvider( |
|
|
|
CompilerResults compilerResults; |
|
|
|
new Dictionary<string, string> {{"CompilerVersion", "v4.0"}}); |
|
|
|
using (var codeProvider = new CSharpCodeProvider( |
|
|
|
var compilerResults = codeProvider.CompileAssemblyFromFile( |
|
|
|
new Dictionary<string, string> { { "CompilerVersion", "v4.0" } })) |
|
|
|
compilerParameters, Options.CodeFiles.ToArray()); |
|
|
|
{ |
|
|
|
|
|
|
|
compilerResults = codeProvider.CompileAssemblyFromDom( |
|
|
|
|
|
|
|
compilerParameters, compileUnits.ToArray()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var errors = compilerResults.Errors.Cast<CompilerError>(); |
|
|
|
var errors = compilerResults.Errors.Cast<CompilerError>(); |
|
|
|
foreach (var error in errors.Where(error => !error.IsWarning)) |
|
|
|
foreach (var error in errors.Where(error => !error.IsWarning)) |
|
|
@ -413,6 +427,8 @@ namespace CppSharp |
|
|
|
{ |
|
|
|
{ |
|
|
|
GeneratorOutputPasses.AddPass(pass); |
|
|
|
GeneratorOutputPasses.AddPass(pass); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<CodeSnippetCompileUnit> compileUnits = new List<CodeSnippetCompileUnit>(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static class ConsoleDriver |
|
|
|
public static class ConsoleDriver |
|
|
|