// Copyright (c) 2012-2019 Wojciech Figat. All rights reserved.
#pragma once
#include "CookingData.h"
#include "Engine/Core/Collections/Dictionary.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.
///
/// The name.
virtual const Char* GetDisplayName() const = 0;
///
/// Gets the name of the platform for filesystem cache directories, deps folder.
///
/// The name.
virtual const Char* GetName() const = 0;
///
/// Gets the type of the platform.
///
/// The platform type.
virtual PlatformType GetPlatform() const = 0;
///
/// Gets the architecture of the platform.
///
/// The architecture type.
virtual ArchitectureType GetArchitecture() const = 0;
///
/// Gets the value indicating whenever platform requires AOT.
///
/// True if platform uses AOT and needs C# assemblies to be be precompiled, otherwise false.
virtual bool UseAOT() 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;
}
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;
}
///
/// The C# scripts AOT configuration options.
///
struct AotConfig
{
String AotCompilerPath;
String AotCompilerArgs;
String AssemblerPath;
String AssemblerArgs;
String ArchiverPath;
String ArchiverArgs;
String AotCachePath;
Dictionary EnvVars;
Array AssembliesSearchDirs;
Array Assemblies;
AotConfig(CookingData& data)
{
Platform::GetEnvironmentVariables(EnvVars);
EnvVars[TEXT("MONO_PATH")] = data.OutputPath / TEXT("Mono/lib/mono/4.5");
AssembliesSearchDirs.Add(data.OutputPath / TEXT("Mono/lib/mono/4.5"));
}
};
///
/// Called to configure AOT options.
///
/// The cooking data.
/// The configuration.
virtual void OnConfigureAOT(CookingData& data, AotConfig& config)
{
}
///
/// Called to execute AOT for the given assembly.
///
/// The cooking data.
/// The configuration.
/// The input managed library file path.
/// True if failed, otherwise false.
virtual bool OnPerformAOT(CookingData& data, AotConfig& config, const String& assemblyPath)
{
return false;
}
///
/// Called after AOT execution for the assemblies.
///
/// The cooking data.
/// The configuration.
/// True if failed, otherwise false.
virtual bool OnPostProcessAOT(CookingData& data, AotConfig& config)
{
return false;
}
///
/// Called during staged build post-processing.
///
/// The cooking data.
/// True if failed, otherwise false.
virtual bool OnPostProcess(CookingData& data)
{
return false;
}
};