Fix AOT libs cooking to avoid file dirtying for more accurate iterative cooking
This commit is contained in:
@@ -10,9 +10,10 @@
|
||||
#include "Engine/Serialization/JsonTools.h"
|
||||
#include "Engine/Serialization/JsonWriters.h"
|
||||
#include "Editor/Cooker/PlatformTools.h"
|
||||
#include "Engine/Engine/Globals.h"
|
||||
#include "Editor/Editor.h"
|
||||
#include "Editor/ProjectInfo.h"
|
||||
#include "Engine/Engine/Globals.h"
|
||||
#include "Editor/Utilities/EditorUtilities.h"
|
||||
#if PLATFORM_MAC
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
@@ -127,7 +128,7 @@ bool CompileScriptsStep::DeployBinaries(CookingData& data, const String& path, c
|
||||
const String dst = dstPath / StringUtils::GetFileName(file);
|
||||
if (dst == file)
|
||||
continue;
|
||||
if (FileSystem::CopyFile(dst, file))
|
||||
if (EditorUtilities::CopyFileIfNewer(dst, file))
|
||||
{
|
||||
data.Error(String::Format(TEXT("Failed to copy file from {0} to {1}."), file, dst));
|
||||
return true;
|
||||
|
||||
@@ -59,6 +59,7 @@ bool PrecompileAssembliesStep::Perform(CookingData& data)
|
||||
data.StepProgress(infoMsg, 0);
|
||||
|
||||
// Override Newtonsoft.Json with AOT-version (one that doesn't use System.Reflection.Emit)
|
||||
// TODO: remove it since EngineModule does properly reference AOT lib now
|
||||
EditorUtilities::CopyFileIfNewer(data.ManagedCodeOutputPath / TEXT("Newtonsoft.Json.dll"), Globals::StartupFolder / TEXT("Source/Platforms/DotNet/AOT/Newtonsoft.Json.dll"));
|
||||
FileSystem::DeleteFile(data.ManagedCodeOutputPath / TEXT("Newtonsoft.Json.xml"));
|
||||
FileSystem::DeleteFile(data.ManagedCodeOutputPath / TEXT("Newtonsoft.Json.pdb"));
|
||||
|
||||
@@ -462,7 +462,7 @@ namespace Flax.Build
|
||||
else
|
||||
{
|
||||
// Copy to the destination folder
|
||||
Utilities.FileCopy(assemblyPath, Path.Combine(dotnetOutputPath, assemblyFileName));
|
||||
Utilities.FileCopy(assemblyPath, Path.Combine(dotnetOutputPath, assemblyFileName), Utilities.CopyMode.OverrideIfNewer);
|
||||
}
|
||||
};
|
||||
if (Configuration.MaxConcurrency > 1 && Configuration.ConcurrencyProcessorScale > 0.0f && !dotnetAotDebug)
|
||||
|
||||
@@ -42,7 +42,8 @@ namespace Flax.Build
|
||||
BinaryModuleName = "FlaxEngine";
|
||||
options.ScriptingAPI.Defines.Add("FLAX");
|
||||
options.ScriptingAPI.Defines.Add("FLAX_ASSERTIONS");
|
||||
options.ScriptingAPI.FileReferences.Add(Utilities.RemovePathRelativeParts(Path.Combine(Globals.EngineRoot, "Source", "Platforms", "DotNet", "Newtonsoft.Json.dll")));
|
||||
var newtonsoftJsonPath = options.Platform?.HasDynamicCodeExecutionSupport ?? true ? "Newtonsoft.Json.dll" : "AOT/Newtonsoft.Json.dll";
|
||||
options.ScriptingAPI.FileReferences.Add(Utilities.RemovePathRelativeParts(Path.Combine(Globals.EngineRoot, "Source", "Platforms", "DotNet", newtonsoftJsonPath)));
|
||||
options.ScriptingAPI.SystemReferences.Add("System.ComponentModel.TypeConverter");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,24 +144,51 @@ namespace Flax.Build
|
||||
return new TwoWayEnumerator<T>(source.GetEnumerator());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// File copy modes.
|
||||
/// </summary>
|
||||
public enum CopyMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Copies the file to the destination, fails if it already exists.
|
||||
/// </summary>
|
||||
New,
|
||||
|
||||
/// <summary>
|
||||
/// If destination file exists, it will be overriden.
|
||||
/// </summary>
|
||||
OverrideIfExists,
|
||||
|
||||
/// <summary>
|
||||
/// If destination file exists, has the same size and is newer than source file, it won't be overriden (avoids unnecessary copies).
|
||||
/// </summary>
|
||||
OverrideIfNewer,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the file.
|
||||
/// </summary>
|
||||
/// <param name="srcFilePath">The source file path.</param>
|
||||
/// <param name="dstFilePath">The destination file path.</param>
|
||||
/// <param name="overwrite"><see langword="true" /> if the destination file can be overwritten; otherwise, <see langword="false" />.</param>
|
||||
public static void FileCopy(string srcFilePath, string dstFilePath, bool overwrite = true)
|
||||
/// <param name="mode">Copy operation modes.</param>
|
||||
public static void FileCopy(string srcFilePath, string dstFilePath, CopyMode mode = CopyMode.OverrideIfExists)
|
||||
{
|
||||
if (string.IsNullOrEmpty(srcFilePath))
|
||||
throw new ArgumentNullException(nameof(srcFilePath));
|
||||
if (string.IsNullOrEmpty(dstFilePath))
|
||||
throw new ArgumentNullException(nameof(dstFilePath));
|
||||
|
||||
if (mode == CopyMode.OverrideIfNewer &&
|
||||
File.Exists(dstFilePath) &&
|
||||
File.GetLastWriteTime(srcFilePath) <= File.GetLastWriteTime(dstFilePath) &&
|
||||
new FileInfo(dstFilePath).Length == new FileInfo(srcFilePath).Length)
|
||||
return;
|
||||
|
||||
Log.Verbose(srcFilePath + " -> " + dstFilePath);
|
||||
|
||||
try
|
||||
{
|
||||
File.Copy(srcFilePath, dstFilePath, overwrite);
|
||||
File.Copy(srcFilePath, dstFilePath, mode != CopyMode.New);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -173,6 +200,17 @@ namespace Flax.Build
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the file.
|
||||
/// </summary>
|
||||
/// <param name="srcFilePath">The source file path.</param>
|
||||
/// <param name="dstFilePath">The destination file path.</param>
|
||||
/// <param name="overwrite"><see langword="true" /> if the destination file can be overwritten; otherwise, <see langword="false" />.</param>
|
||||
public static void FileCopy(string srcFilePath, string dstFilePath, bool overwrite)
|
||||
{
|
||||
FileCopy(srcFilePath, dstFilePath, overwrite ? CopyMode.OverrideIfExists : CopyMode.New);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the directories.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user