// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
#pragma once
#include "CookingData.h"
#include "Editor/Scripting/ScriptsBuilder.h"
#include "Engine/Graphics/PixelFormat.h"
class TextureBase;
///
/// The platform support tools base interface.
///
class FLAXENGINE_API PlatformTools
{
public:
///
/// Finalizes an instance of the class.
///
virtual ~PlatformTools() = default;
///
/// Gets the name of the platform for UI and logging.
///
virtual const Char* GetDisplayName() const = 0;
///
/// Gets the name of the platform for filesystem cache directories, deps folder.
///
virtual const Char* GetName() const = 0;
///
/// Gets the type of the platform.
///
virtual PlatformType GetPlatform() const = 0;
///
/// Gets the architecture of the platform.
///
virtual ArchitectureType GetArchitecture() const = 0;
///
/// Gets the value indicating whenever platform requires AOT (needs C# assemblies to be precompiled).
///
virtual DotNetAOTModes UseAOT() const
{
return DotNetAOTModes::None;
}
///
/// Gets the value indicating whenever platform supports using system-installed .Net Runtime.
///
virtual bool UseSystemDotnet() const
{
return false;
}
///
/// Gets the texture format that is supported by the platform for a given texture.
///
/// The cooking data.
/// The texture.
/// The texture format.
/// The target texture format for the platform.
virtual PixelFormat GetTextureFormat(CookingData& data, TextureBase* texture, PixelFormat format)
{
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);
public:
///
/// Called when game building starts.
///
/// The cooking data.
virtual void OnBuildStarted(CookingData& data)
{
}
///
/// Called when game building ends.
///
/// The cooking data.
/// True if build failed, otherwise false.
virtual void OnBuildEnded(CookingData& data, bool failed)
{
}
///
/// Called before scripts compilation. Can be used to inject custom configuration or prepare data.
///
/// The cooking data.
/// True if failed, otherwise false.
virtual bool OnScriptsCompilationStart(CookingData& data)
{
return false;
}
///
/// Called after scripts compilation. Can be used to cleanup or prepare data.
///
/// The cooking data.
/// True if failed, otherwise false.
virtual bool OnScriptsCompilationEnd(CookingData& data)
{
return false;
}
///
/// Called after compiled scripts deploy. Can be used to override or patch the output files.
///
/// The cooking data.
/// True if failed, otherwise false.
virtual bool OnScriptsStepDone(CookingData& data)
{
return false;
}
///
/// Called during binaries deployment.
///
/// The cooking data.
/// True if failed, otherwise false.
virtual bool OnDeployBinaries(CookingData& data)
{
return false;
}
///
/// Called during staged build post-processing.
///
/// The cooking data.
/// True if failed, otherwise false.
virtual bool OnPostProcess(CookingData& data)
{
return false;
}
///
/// Called to run the cooked game build on device.
///
/// The cooking data.
/// The game executable file path to run (or tool path to run if build should run on remote device). Empty if not supported.
/// The command line for executable file. Use `{0}` to insert custom command line for passing to the cooked game.
/// Overriden custom working directory to use. Leave empty if use cooked data output folder.
virtual void OnRun(CookingData& data, String& executableFile, String& commandLineFormat, String& workingDir)
{
}
};