Fix handling errors when saving scripting API parsing cache

This commit is contained in:
Wojtek Figat
2021-02-19 12:25:53 +01:00
parent ce9df56a97
commit 2f12e67356
3 changed files with 13 additions and 1 deletions

View File

@@ -164,6 +164,8 @@ namespace Flax.Build.Bindings
private static void SaveCache(ModuleInfo moduleInfo, BuildOptions moduleOptions, List<string> headerFiles) private static void SaveCache(ModuleInfo moduleInfo, BuildOptions moduleOptions, List<string> headerFiles)
{ {
if (!Directory.Exists(moduleOptions.IntermediateFolder))
return;
var path = GetCachePath(moduleInfo.Module, moduleOptions); var path = GetCachePath(moduleInfo.Module, moduleOptions);
using (var stream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read)) using (var stream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read))
using (var writer = new BinaryWriter(stream, Encoding.UTF8)) using (var writer = new BinaryWriter(stream, Encoding.UTF8))

View File

@@ -152,9 +152,17 @@ namespace Flax.Build.Bindings
// Save cache // Save cache
using (new ProfileEventScope("SaveCache")) using (new ProfileEventScope("SaveCache"))
{
try
{ {
SaveCache(moduleInfo, moduleOptions, headerFiles); SaveCache(moduleInfo, moduleOptions, headerFiles);
} }
catch (Exception ex)
{
Log.Error($"Failed to save API cache for module {moduleInfo.Module.Name}");
Log.Exception(ex);
}
}
// Initialize API // Initialize API
using (new ProfileEventScope("Init")) using (new ProfileEventScope("Init"))

View File

@@ -751,8 +751,10 @@ namespace Flax.Build
using (new ProfileEventScope("BuildBindings")) using (new ProfileEventScope("BuildBindings"))
{ {
if (!buildData.Target.IsPreBuilt) if (!buildData.Target.IsPreBuilt)
{
BuildTargetBindings(rules, graph, buildData); BuildTargetBindings(rules, graph, buildData);
} }
}
// Link modules into a target // Link modules into a target
var outputTargetFilePath = target.GetOutputFilePath(targetBuildOptions); var outputTargetFilePath = target.GetOutputFilePath(targetBuildOptions);