diff --git a/Source/Editor/Cooker/CookingData.h b/Source/Editor/Cooker/CookingData.h index 77774a9df..848bf199b 100644 --- a/Source/Editor/Cooker/CookingData.h +++ b/Source/Editor/Cooker/CookingData.h @@ -158,9 +158,14 @@ struct FLAXENGINE_API CookingData String DataOutputPath; /// - /// The output path for binaries (executable and code libraries). + /// The output path for binaries (native executable and native code libraries). /// - String CodeOutputPath; + String NativeCodeOutputPath; + + /// + /// The output path for binaries (C# code libraries). + /// + String ManagedCodeOutputPath; /// /// The platform tools. diff --git a/Source/Editor/Cooker/GameCooker.cpp b/Source/Editor/Cooker/GameCooker.cpp index f64045ff5..d9525b28e 100644 --- a/Source/Editor/Cooker/GameCooker.cpp +++ b/Source/Editor/Cooker/GameCooker.cpp @@ -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)) { diff --git a/Source/Editor/Cooker/Platform/Android/AndroidPlatformTools.cpp b/Source/Editor/Cooker/Platform/Android/AndroidPlatformTools.cpp index 3987fcb4a..71f01fa5d 100644 --- a/Source/Editor/Cooker/Platform/Android/AndroidPlatformTools.cpp +++ b/Source/Editor/Cooker/Platform/Android/AndroidPlatformTools.cpp @@ -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); } diff --git a/Source/Editor/Cooker/Platform/UWP/UWPPlatformTools.cpp b/Source/Editor/Cooker/Platform/UWP/UWPPlatformTools.cpp index e6516bf67..e32a8d759 100644 --- a/Source/Editor/Cooker/Platform/UWP/UWPPlatformTools.cpp +++ b/Source/Editor/Cooker/Platform/UWP/UWPPlatformTools.cpp @@ -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.")); diff --git a/Source/Editor/Cooker/Platform/Windows/WindowsPlatformTools.cpp b/Source/Editor/Cooker/Platform/Windows/WindowsPlatformTools.cpp index d5dc1c933..9f7744704 100644 --- a/Source/Editor/Cooker/Platform/Windows/WindowsPlatformTools.cpp +++ b/Source/Editor/Cooker/Platform/Windows/WindowsPlatformTools.cpp @@ -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 files; diff --git a/Source/Editor/Cooker/PlatformTools.h b/Source/Editor/Cooker/PlatformTools.h index 63b018343..ac07c88af 100644 --- a/Source/Editor/Cooker/PlatformTools.h +++ b/Source/Editor/Cooker/PlatformTools.h @@ -66,6 +66,17 @@ public: return format; } + /// + /// Checks if the given file is a native code. + /// + /// The cooking data. + /// The file path. + /// True if it's a native file, otherwise false. + virtual bool IsNativeCodeFile(CookingData& data, const String& file) + { + return false; + } + public: /// diff --git a/Source/Editor/Cooker/Steps/CompileScriptsStep.cpp b/Source/Editor/Cooker/Steps/CompileScriptsStep.cpp index 5d3125960..5969dd32b 100644 --- a/Source/Editor/Cooker/Steps/CompileScriptsStep.cpp +++ b/Source/Editor/Cooker/Steps/CompileScriptsStep.cpp @@ -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); diff --git a/Source/Editor/Cooker/Steps/PrecompileAssembliesStep.cpp b/Source/Editor/Cooker/Steps/PrecompileAssembliesStep.cpp index 6e5fe50a7..7277fcb43 100644 --- a/Source/Editor/Cooker/Steps/PrecompileAssembliesStep.cpp +++ b/Source/Editor/Cooker/Steps/PrecompileAssembliesStep.cpp @@ -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++) diff --git a/Source/Editor/Cooker/Steps/ValidateStep.cpp b/Source/Editor/Cooker/Steps/ValidateStep.cpp index a64317496..416d60820 100644 --- a/Source/Editor/Cooker/Steps/ValidateStep.cpp +++ b/Source/Editor/Cooker/Steps/ValidateStep.cpp @@ -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