Browse Source

Option to allow caller to specify it does not want unchanged output files to be modified. This supports incremental build in VS. (#1373)

Check if generated code is different to existing files and only overwrite if so

Co-authored-by: Build Agent <admin@sage.com>
mono-ubuntu-20.04
Ali Alamiri 5 years ago committed by GitHub
parent
commit
fe33488829
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      src/Generator/Driver.cs

11
src/Generator/Driver.cs

@ -316,7 +316,7 @@ namespace CppSharp @@ -316,7 +316,7 @@ namespace CppSharp
var fileRelativePath = $"{fileBase}.{template.FileExtension}";
var file = Path.Combine(outputPath, fileRelativePath);
File.WriteAllText(file, template.Generate());
WriteGeneratedCodeToFile(file, template.Generate());
output.TranslationUnit.Module.CodeFiles.Add(file);
Diagnostics.Message("Generated '{0}'", fileRelativePath);
@ -324,6 +324,15 @@ namespace CppSharp @@ -324,6 +324,15 @@ namespace CppSharp
}
}
private void WriteGeneratedCodeToFile(string file, string generatedCode)
{
var fi = new FileInfo(file);
if (!fi.Exists || fi.Length != generatedCode.Length ||
File.ReadAllText(file) != generatedCode)
File.WriteAllText(file, generatedCode);
}
private static readonly Dictionary<Module, string> libraryMappings = new Dictionary<Module, string>();
public void CompileCode(Module module)

Loading…
Cancel
Save