Add support for separate native and managed code in packaged build
This commit is contained in:
@@ -158,9 +158,14 @@ struct FLAXENGINE_API CookingData
|
||||
String DataOutputPath;
|
||||
|
||||
/// <summary>
|
||||
/// The output path for binaries (executable and code libraries).
|
||||
/// The output path for binaries (native executable and native code libraries).
|
||||
/// </summary>
|
||||
String CodeOutputPath;
|
||||
String NativeCodeOutputPath;
|
||||
|
||||
/// <summary>
|
||||
/// The output path for binaries (C# code libraries).
|
||||
/// </summary>
|
||||
String ManagedCodeOutputPath;
|
||||
|
||||
/// <summary>
|
||||
/// The platform tools.
|
||||
|
||||
@@ -337,7 +337,7 @@ void GameCooker::Build(BuildPlatform platform, BuildConfiguration configuration,
|
||||
data.OriginalOutputPath = outputPath;
|
||||
FileSystem::NormalizePath(data.OriginalOutputPath);
|
||||
data.OriginalOutputPath = FileSystem::ConvertRelativePathToAbsolute(Globals::ProjectFolder, data.OriginalOutputPath);
|
||||
data.CodeOutputPath = data.DataOutputPath = data.OriginalOutputPath;
|
||||
data.NativeCodeOutputPath = data.ManagedCodeOutputPath = data.DataOutputPath = data.OriginalOutputPath;
|
||||
data.CacheDirectory = Globals::ProjectCacheFolder / TEXT("Cooker") / tools->GetName();
|
||||
if (!FileSystem::DirectoryExists(data.CacheDirectory))
|
||||
{
|
||||
|
||||
@@ -105,7 +105,8 @@ void AndroidPlatformTools::OnBuildStarted(CookingData& data)
|
||||
{
|
||||
// Adjust the cooking output folder to be located inside the Gradle assets directory
|
||||
data.DataOutputPath /= TEXT("app/assets");
|
||||
data.CodeOutputPath /= TEXT("app/assets");
|
||||
data.NativeCodeOutputPath /= TEXT("app/assets");
|
||||
data.ManagedCodeOutputPath /= TEXT("app/assets");
|
||||
|
||||
PlatformTools::OnBuildStarted(data);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ bool UWPPlatformTools::OnScriptsStepDone(CookingData& data)
|
||||
{
|
||||
// Override Newtonsoft.Json.dll for some platforms (that don't support runtime code generation)
|
||||
const String customBinPath = data.GetPlatformBinariesRoot() / TEXT("Newtonsoft.Json.dll");
|
||||
const String assembliesPath = data.CodeOutputPath;
|
||||
const String assembliesPath = data.ManagedCodeOutputPath;
|
||||
if (FileSystem::CopyFile(assembliesPath / TEXT("Newtonsoft.Json.dll"), customBinPath))
|
||||
{
|
||||
data.Error(TEXT("Failed to copy deploy custom assembly."));
|
||||
|
||||
@@ -36,7 +36,7 @@ ArchitectureType WindowsPlatformTools::GetArchitecture() const
|
||||
bool WindowsPlatformTools::OnDeployBinaries(CookingData& data)
|
||||
{
|
||||
const auto platformSettings = WindowsPlatformSettings::Get();
|
||||
const auto& outputPath = data.CodeOutputPath;
|
||||
const auto& outputPath = data.NativeCodeOutputPath;
|
||||
|
||||
// Apply executable icon
|
||||
Array<String> files;
|
||||
|
||||
@@ -66,6 +66,17 @@ public:
|
||||
return format;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the given file is a native code.
|
||||
/// </summary>
|
||||
/// <param name="data">The cooking data.</param>
|
||||
/// <param name="file">The file path.</param>
|
||||
/// <returns>True if it's a native file, otherwise false.<returns>
|
||||
virtual bool IsNativeCodeFile(CookingData& data, const String& file)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -119,7 +119,8 @@ bool CompileScriptsStep::DeployBinaries(CookingData& data, const String& path, c
|
||||
}
|
||||
for (auto& file : files)
|
||||
{
|
||||
const String dst = data.CodeOutputPath / StringUtils::GetFileName(file);
|
||||
const String& dstPath = data.Tools->IsNativeCodeFile(data, file) ? data.NativeCodeOutputPath : data.ManagedCodeOutputPath;
|
||||
const String dst = dstPath / StringUtils::GetFileName(file);
|
||||
if (dst != file && FileSystem::CopyFile(dst, file))
|
||||
{
|
||||
data.Error(TEXT("Failed to copy file from {0} to {1}."), file, dst);
|
||||
@@ -294,7 +295,7 @@ bool CompileScriptsStep::Perform(CookingData& data)
|
||||
}
|
||||
writer.EndObject();
|
||||
|
||||
const String outputBuildInfo = data.CodeOutputPath / TEXT("Game.Build.json");
|
||||
const String outputBuildInfo = data.DataOutputPath / TEXT("Game.Build.json");
|
||||
if (File::WriteAllBytes(outputBuildInfo, (byte*)buffer.GetString(), (int32)buffer.GetSize()))
|
||||
{
|
||||
LOG(Error, "Failed to save binary modules info file {0}.", outputBuildInfo);
|
||||
|
||||
@@ -52,9 +52,9 @@ bool PrecompileAssembliesStep::Perform(CookingData& data)
|
||||
FileSystem::DirectoryGetFiles(config.Assemblies, dir, TEXT("*.dll"), DirectorySearchOption::TopDirectoryOnly);
|
||||
for (auto& binaryModule : data.BinaryModules)
|
||||
if (binaryModule.ManagedPath.HasChars())
|
||||
config.Assemblies.Add(data.CodeOutputPath / binaryModule.ManagedPath);
|
||||
config.Assemblies.Add(data.ManagedCodeOutputPath / binaryModule.ManagedPath);
|
||||
// TODO: move AOT to Flax.Build and perform it on all C# assemblies used in target build
|
||||
config.Assemblies.Add(data.CodeOutputPath / TEXT("Newtonsoft.Json.dll"));
|
||||
config.Assemblies.Add(data.ManagedCodeOutputPath / TEXT("Newtonsoft.Json.dll"));
|
||||
|
||||
// Perform AOT for the assemblies
|
||||
for (int32 i = 0; i < config.Assemblies.Count(); i++)
|
||||
|
||||
@@ -11,29 +11,25 @@ bool ValidateStep::Perform(CookingData& data)
|
||||
data.StepProgress(TEXT("Performing validation"), 0);
|
||||
|
||||
// Ensure output and cache directories exist
|
||||
if (!FileSystem::DirectoryExists(data.CodeOutputPath))
|
||||
if (!FileSystem::DirectoryExists(data.NativeCodeOutputPath) && FileSystem::CreateDirectory(data.NativeCodeOutputPath))
|
||||
{
|
||||
if (FileSystem::CreateDirectory(data.CodeOutputPath))
|
||||
{
|
||||
data.Error(TEXT("Failed to create build output directory."));
|
||||
return true;
|
||||
}
|
||||
data.Error(TEXT("Failed to create build output directory."));
|
||||
return true;
|
||||
}
|
||||
if (!FileSystem::DirectoryExists(data.DataOutputPath))
|
||||
if (!FileSystem::DirectoryExists(data.ManagedCodeOutputPath) && FileSystem::CreateDirectory(data.ManagedCodeOutputPath))
|
||||
{
|
||||
if (FileSystem::CreateDirectory(data.DataOutputPath))
|
||||
{
|
||||
data.Error(TEXT("Failed to create build output directory."));
|
||||
return true;
|
||||
}
|
||||
data.Error(TEXT("Failed to create build output directory."));
|
||||
return true;
|
||||
}
|
||||
if (!FileSystem::DirectoryExists(data.CacheDirectory))
|
||||
if (!FileSystem::DirectoryExists(data.DataOutputPath) && FileSystem::CreateDirectory(data.DataOutputPath))
|
||||
{
|
||||
if (FileSystem::CreateDirectory(data.CacheDirectory))
|
||||
{
|
||||
data.Error(TEXT("Failed to create build cache directory."));
|
||||
return true;
|
||||
}
|
||||
data.Error(TEXT("Failed to create build output directory."));
|
||||
return true;
|
||||
}
|
||||
if (!FileSystem::DirectoryExists(data.CacheDirectory) && FileSystem::CreateDirectory(data.CacheDirectory))
|
||||
{
|
||||
data.Error(TEXT("Failed to create build cache directory."));
|
||||
return true;
|
||||
}
|
||||
|
||||
#if OFFICIAL_BUILD
|
||||
|
||||
Reference in New Issue
Block a user