// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. #pragma once #include "Engine/Core/Log.h" #include "Engine/Core/Enums.h" #include "Engine/Core/Collections/Array.h" #include "Engine/Core/Collections/HashSet.h" #include "Engine/Core/Collections/Dictionary.h" class GameCooker; class PlatformTools; /// /// Game building options. Used as flags. /// API_ENUM(Attributes="Flags") enum class BuildOptions { /// /// No special options declared. /// None = 0, /// /// Shows the output directory folder on building end. /// ShowOutput = 1 << 0, }; DECLARE_ENUM_OPERATORS(BuildOptions); /// /// Game build target platform. /// API_ENUM() enum class BuildPlatform { /// /// Windows (32-bit architecture) /// API_ENUM(Attributes="EditorDisplay(null, \"Windows 32bit\")") Windows32 = 1, /// /// Windows (64-bit architecture) /// API_ENUM(Attributes="EditorDisplay(null, \"Windows 64bit\")") Windows64 = 2, /// /// Universal Windows Platform (UWP) (x86 architecture) /// API_ENUM(Attributes="EditorDisplay(null, \"Windows Store x86\")") UWPx86 = 3, /// /// Universal Windows Platform (UWP) (x64 architecture) /// API_ENUM(Attributes="EditorDisplay(null, \"Windows Store x64\")") UWPx64 = 4, /// /// Xbox One /// API_ENUM(Attributes="EditorDisplay(null, \"Xbox One\")") XboxOne = 5, /// /// Linux (64-bit architecture) /// API_ENUM(Attributes="EditorDisplay(null, \"Linux x64\")") LinuxX64 = 6, /// /// PlayStation 4 /// API_ENUM(Attributes="EditorDisplay(null, \"PlayStation 4\")") PS4 = 7, /// /// Xbox Series X. /// API_ENUM(Attributes="EditorDisplay(null, \"Xbox Scarlett\")") XboxScarlett = 8, /// /// Android ARM64 (arm64-v8a). /// API_ENUM(Attributes="EditorDisplay(null, \"Android ARM64 (arm64-v8a)\")") AndroidARM64 = 9, }; inline const Char* ToString(const BuildPlatform platform) { switch (platform) { case BuildPlatform::Windows32: return TEXT("Windows x86"); case BuildPlatform::Windows64: return TEXT("Windows x64"); case BuildPlatform::UWPx86: return TEXT("Windows Store x86"); case BuildPlatform::UWPx64: return TEXT("Windows Store x64"); case BuildPlatform::XboxOne: return TEXT("Xbox One"); case BuildPlatform::LinuxX64: return TEXT("Linux x64"); case BuildPlatform::PS4: return TEXT("PlayStation 4"); case BuildPlatform::XboxScarlett: return TEXT("Xbox Scarlett"); case BuildPlatform::AndroidARM64: return TEXT("Android ARM64"); default: return TEXT("?"); } } /// /// Game build configuration modes. /// API_ENUM() enum class BuildConfiguration { /// /// Debug configuration. Without optimizations but with full debugging information. /// Debug = 0, /// /// Development configuration. With basic optimizations and partial debugging data. /// Development = 1, /// /// Shipping configuration. With full optimization and no debugging data. /// Release = 2, }; inline const Char* ToString(const BuildConfiguration configuration) { switch (configuration) { case BuildConfiguration::Debug: return TEXT("Debug"); case BuildConfiguration::Development: return TEXT("Development"); case BuildConfiguration::Release: return TEXT("Release"); default: return TEXT("?"); } } #define BUILD_STEP_CANCEL_CHECK if (GameCooker::IsCancelRequested()) return true /// /// Game cooking temporary data. /// struct FLAXENGINE_API CookingData { /// /// The platform. /// BuildPlatform Platform; /// /// The configuration. /// BuildConfiguration Configuration; /// /// The options. /// BuildOptions Options; /// /// The original output path (actual OutputPath could be modified by the Platform Tools or a plugin for additional layout customizations or packaging). This path is preserved. /// String OriginalOutputPath; /// /// The output path. /// String OutputPath; /// /// The platform tools. /// PlatformTools* Tools; public: /// /// The asset type build stats storage. /// struct AssetTypeStatistics { /// /// The asset type name. /// String TypeName; /// /// The amount of assets of that type in a build. /// int32 Count = 0; /// /// The final output size of the assets of that type in a build. /// uint64 ContentSize = 0; bool operator<(const AssetTypeStatistics& other) const; }; /// /// The build stats storage. /// struct Statistics { /// /// The total assets amount in the build. /// int32 TotalAssets; /// /// The cooked assets (TotalAssets - CookedAssets is amount of reused cached assets). /// int32 CookedAssets; /// /// The final output content size in MB. /// int32 ContentSizeMB; /// /// The asset type stats. Key is the asset typename, value is the stats container. /// Dictionary AssetStats; Statistics(); }; /// /// The build stats. /// Statistics Stats; public: /// /// The temporary directory used for the building cache. Can be used for the incremental building. /// String CacheDirectory; /// /// The root assets collection to include in build in the first place (can be used only before CollectAssetsStep). /// Game cooker will find dependant assets and deploy them as well. /// HashSet RootAssets; /// /// The final assets collection to include in build (valid only after CollectAssetsStep). /// HashSet Assets; struct BinaryModule { String Name; String NativePath; String ManagedPath; }; /// /// The binary modules used in the build. Valid after scripts compilation step. This list includes game, all plugins modules and engine module. /// Array> BinaryModules; public: void Init() { RootAssets.Clear(); Assets.Clear(); Stats = Statistics(); } /// /// Gets the absolute path to the Platform Data folder that contains the binary files used by the current build configuration. /// /// The platform data folder path. String GetGameBinariesPath() const; /// /// Gets the absolute path to the platform folder that contains the dependency files used by the current build configuration. /// /// The platform deps folder path. String GetPlatformBinariesRoot() const; public: /// /// The total amount of baking steps to perform. /// int32 StepsCount; /// /// The current step index. /// int32 CurrentStepIndex; /// /// Initializes the progress. /// /// The total steps count. void InitProgress(const int32 stepsCount) { StepsCount = stepsCount; CurrentStepIndex = 0; } /// /// Moves the progress reporting to the next step /// void NextStep() { CurrentStepIndex++; } /// /// Reports the current step progress (normalized 0-1 value) /// /// The step info message. /// The step progress. void StepProgress(const String& info, const float stepProgress) const; public: /// /// Adds the asset to the build. /// /// The asset id. void AddRootAsset(const Guid& id); /// /// Adds the asset to the build. /// /// The absolute asset path. void AddRootAsset(const String& path); /// /// Adds the internal engine asset to the build. /// /// The internal path (relative to the engine content path). void AddRootEngineAsset(const String& internalPath); public: void Error(const String& msg); void Error(const Char* msg) { Error(String(msg)); } template void Error(const Char* format, const Args& ... args) { const String msg = String::Format(format, args...); Error(msg); } };