// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. #pragma once #include "Engine/Core/Log.h" #include "Engine/Core/Types/Guid.h" #include "Engine/Core/Collections/Array.h" #include "Engine/Core/Collections/HashSet.h" #include "Engine/Core/Collections/Dictionary.h" #include "Engine/Scripting/ScriptingObject.h" class GameCooker; class PlatformTools; #if OFFICIAL_BUILD // Use the fixed .NET SDK version in packaged builds for compatibility (FlaxGame is precompiled with it) #define GAME_BUILD_DOTNET_VER TEXT("-dotnet=8") #else #define GAME_BUILD_DOTNET_VER TEXT("") #endif /// /// 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, /// /// Starts the cooked game build on building end. /// AutoRun = 1 << 1, /// /// Skips cooking logic and uses already cooked data (eg. to only use AutoRun or ShowOutput feature). /// NoCook = 1 << 2, }; 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, /// /// Switch. /// Switch = 10, /// /// PlayStation 5 /// API_ENUM(Attributes="EditorDisplay(null, \"PlayStation 5\")") PS5 = 11, /// /// MacOS (x86-64 Intel) /// API_ENUM(Attributes="EditorDisplay(null, \"Mac x64\")") MacOSx64 = 12, /// /// MacOS (ARM64 Apple Silicon) /// API_ENUM(Attributes="EditorDisplay(null, \"Mac ARM64\")") MacOSARM64 = 13, /// /// iOS (ARM64) /// API_ENUM(Attributes="EditorDisplay(null, \"iOS ARM64\")") iOSARM64 = 14, }; /// /// 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, }; /// /// .NET Ahead of Time Compilation (AOT) modes. /// enum class DotNetAOTModes { /// /// AOT is not used. /// None, /// /// Use .NET Native IL Compiler (shorten as ILC) to convert all C# assemblies in native platform executable binary. /// ILC, /// /// Use Mono AOT to cross-compile all used C# assemblies into native platform shared libraries. /// MonoAOTDynamic, /// /// Use Mono AOT to cross-compile all used C# assemblies into native platform static libraries which can be linked into a single shared library. /// MonoAOTStatic, }; extern FLAXENGINE_API const Char* ToString(const BuildPlatform platform); extern FLAXENGINE_API const Char* ToString(const BuildConfiguration configuration); extern FLAXENGINE_API const Char* ToString(const DotNetAOTModes mode); #define BUILD_STEP_CANCEL_CHECK if (GameCooker::IsCancelRequested()) return true /// /// Game cooking temporary data. /// API_CLASS(Sealed, Namespace="FlaxEditor") class FLAXENGINE_API CookingData : public ScriptingObject { DECLARE_SCRIPTING_TYPE(CookingData); public: /// /// The platform. /// API_FIELD(ReadOnly) BuildPlatform Platform; /// /// The configuration. /// API_FIELD(ReadOnly) BuildConfiguration Configuration; /// /// The options. /// API_FIELD(ReadOnly) BuildOptions Options; /// /// The name of build preset used for cooking (can be used by editor and game plugins). /// API_FIELD(ReadOnly) String Preset; /// /// The name of build preset target used for cooking (can be used by editor and game plugins). /// API_FIELD(ReadOnly) String PresetTarget; /// /// The list of custom defines passed to the build tool when compiling project scripts. Can be used in build scripts for configuration (Configuration.CustomDefines). /// API_FIELD(ReadOnly) Array CustomDefines; /// /// 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. /// API_FIELD(ReadOnly) String OriginalOutputPath; /// /// The output path for data files (Content, Dotnet, Mono, etc.). /// API_FIELD(ReadOnly) String DataOutputPath; /// /// The output path for binaries (native executable and native code libraries). /// API_FIELD(ReadOnly) String NativeCodeOutputPath; /// /// The output path for binaries (C# code libraries). /// API_FIELD(ReadOnly) String ManagedCodeOutputPath; /// /// 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 BinaryModuleInfo { 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: /// /// Gets the absolute path to the Platform Data folder that contains the binary files used by the current build configuration. /// String GetGameBinariesPath() const; /// /// Gets the absolute path to the platform folder that contains the dependency files used by the current build configuration. /// String GetPlatformBinariesRoot() const; /// /// Gets the name of the platform and architecture for the current BuildPlatform. /// void GetBuildPlatformName(const Char*& platform, const Char*& architecture) 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 StringView& msg); void Error(const String& msg) { Error(StringView(msg)); } void Error(const Char* msg) { Error(StringView(msg)); } };