Add CookingData for C# editor to extend the cooking process
This commit is contained in:
@@ -7,7 +7,8 @@
|
||||
|
||||
void RegisterGameCookingStart(GameCooker::EventType type)
|
||||
{
|
||||
auto platform = ToString(GameCooker::GetCurrentData().Platform);
|
||||
auto& data = *GameCooker::GetCurrentData();
|
||||
auto platform = ToString(data.Platform);
|
||||
if (type == GameCooker::EventType::BuildStarted)
|
||||
{
|
||||
EditorAnalytics::SendEvent("Actions", "GameCooker.Start", platform);
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Core/Enums.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/Core/Types/Guid.h"
|
||||
#include "Engine/Scripting/ScriptingObject.h"
|
||||
|
||||
class GameCooker;
|
||||
class PlatformTools;
|
||||
@@ -125,47 +125,50 @@ extern FLAXENGINE_API const Char* ToString(const BuildConfiguration configuratio
|
||||
/// <summary>
|
||||
/// Game cooking temporary data.
|
||||
/// </summary>
|
||||
struct FLAXENGINE_API CookingData
|
||||
API_CLASS(Sealed, Namespace="FlaxEditor") class FLAXENGINE_API CookingData : public PersistentScriptingObject
|
||||
{
|
||||
DECLARE_SCRIPTING_TYPE(CookingData);
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
/// The platform.
|
||||
/// </summary>
|
||||
BuildPlatform Platform;
|
||||
API_FIELD(ReadOnly) BuildPlatform Platform;
|
||||
|
||||
/// <summary>
|
||||
/// The configuration.
|
||||
/// </summary>
|
||||
BuildConfiguration Configuration;
|
||||
API_FIELD(ReadOnly) BuildConfiguration Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// The options.
|
||||
/// </summary>
|
||||
BuildOptions Options;
|
||||
API_FIELD(ReadOnly) BuildOptions Options;
|
||||
|
||||
/// <summary>
|
||||
/// The list of custom defines passed to the build tool when compiling project scripts. Can be used in build scripts for configuration (Configuration.CustomDefines).
|
||||
/// </summary>
|
||||
Array<String> CustomDefines;
|
||||
API_FIELD(ReadOnly) Array<String> CustomDefines;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
String OriginalOutputPath;
|
||||
API_FIELD(ReadOnly) String OriginalOutputPath;
|
||||
|
||||
/// <summary>
|
||||
/// The output path for data files (Content, Mono, etc.).
|
||||
/// </summary>
|
||||
String DataOutputPath;
|
||||
API_FIELD(ReadOnly) String DataOutputPath;
|
||||
|
||||
/// <summary>
|
||||
/// The output path for binaries (native executable and native code libraries).
|
||||
/// </summary>
|
||||
String NativeCodeOutputPath;
|
||||
API_FIELD(ReadOnly) String NativeCodeOutputPath;
|
||||
|
||||
/// <summary>
|
||||
/// The output path for binaries (C# code libraries).
|
||||
/// </summary>
|
||||
String ManagedCodeOutputPath;
|
||||
API_FIELD(ReadOnly) String ManagedCodeOutputPath;
|
||||
|
||||
/// <summary>
|
||||
/// The platform tools.
|
||||
@@ -248,7 +251,7 @@ public:
|
||||
/// </summary>
|
||||
HashSet<Guid> Assets;
|
||||
|
||||
struct BinaryModule
|
||||
struct BinaryModuleInfo
|
||||
{
|
||||
String Name;
|
||||
String NativePath;
|
||||
@@ -258,17 +261,10 @@ public:
|
||||
/// <summary>
|
||||
/// The binary modules used in the build. Valid after scripts compilation step. This list includes game, all plugins modules and engine module.
|
||||
/// </summary>
|
||||
Array<BinaryModule, InlinedAllocation<64>> BinaryModules;
|
||||
Array<BinaryModuleInfo, InlinedAllocation<64>> BinaryModules;
|
||||
|
||||
public:
|
||||
|
||||
void Init()
|
||||
{
|
||||
RootAssets.Clear();
|
||||
Assets.Clear();
|
||||
Stats = Statistics();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the absolute path to the Platform Data folder that contains the binary files used by the current build configuration.
|
||||
/// </summary>
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace GameCookerImpl
|
||||
String ProgressMsg;
|
||||
float ProgressValue;
|
||||
|
||||
CookingData Data;
|
||||
CookingData* Data = nullptr;
|
||||
Array<GameCooker::BuildStep*> Steps;
|
||||
Dictionary<BuildPlatform, PlatformTools*> Tools;
|
||||
|
||||
@@ -154,6 +154,11 @@ CookingData::Statistics::Statistics()
|
||||
ContentSizeMB = 0;
|
||||
}
|
||||
|
||||
CookingData::CookingData(const SpawnParams& params)
|
||||
: PersistentScriptingObject(params)
|
||||
{
|
||||
}
|
||||
|
||||
String CookingData::GetGameBinariesPath() const
|
||||
{
|
||||
const Char* archDir;
|
||||
@@ -179,7 +184,7 @@ String CookingData::GetGameBinariesPath() const
|
||||
return String::Empty;
|
||||
}
|
||||
|
||||
return GetPlatformBinariesRoot() / TEXT("Game") / archDir / ToString(Configuration);
|
||||
return GetPlatformBinariesRoot() / TEXT("Game") / archDir / ::ToString(Configuration);
|
||||
}
|
||||
|
||||
String CookingData::GetPlatformBinariesRoot() const
|
||||
@@ -239,7 +244,7 @@ public:
|
||||
|
||||
GameCookerService GameCookerServiceInstance;
|
||||
|
||||
const CookingData& GameCooker::GetCurrentData()
|
||||
CookingData* GameCooker::GetCurrentData()
|
||||
{
|
||||
return Data;
|
||||
}
|
||||
@@ -331,8 +336,8 @@ void GameCooker::Build(BuildPlatform platform, BuildConfiguration configuration,
|
||||
CancelFlag = 0;
|
||||
ProgressMsg.Clear();
|
||||
ProgressValue = 1.0f;
|
||||
CookingData& data = Data;
|
||||
data.Init();
|
||||
Data = New<CookingData>();
|
||||
CookingData& data = *Data;
|
||||
data.Tools = tools;
|
||||
data.Platform = platform;
|
||||
data.Configuration = configuration;
|
||||
@@ -448,7 +453,7 @@ void GameCookerImpl::OnCollectAssets(HashSet<Guid>& assets)
|
||||
|
||||
bool GameCookerImpl::Build()
|
||||
{
|
||||
CookingData& data = Data;
|
||||
CookingData& data = *Data;
|
||||
LOG(Info, "Starting Game Cooker...");
|
||||
LOG(Info, "Platform: {0}, Configuration: {2}, Options: {1}", ::ToString(data.Platform), (int32)data.Options, ::ToString(data.Configuration));
|
||||
LOG(Info, "Output Path: {0}", data.OriginalOutputPath);
|
||||
@@ -472,7 +477,7 @@ bool GameCookerImpl::Build()
|
||||
CallEvent(GameCooker::EventType::BuildStarted);
|
||||
for (int32 stepIndex = 0; stepIndex < Steps.Count(); stepIndex++)
|
||||
Steps[stepIndex]->OnBuildStarted(data);
|
||||
Data.Tools->OnBuildStarted(data);
|
||||
data.Tools->OnBuildStarted(data);
|
||||
data.InitProgress(Steps.Count());
|
||||
|
||||
// Execute all steps in a sequence
|
||||
@@ -511,10 +516,12 @@ bool GameCookerImpl::Build()
|
||||
}
|
||||
IsRunning = false;
|
||||
CancelFlag = 0;
|
||||
Data.Tools->OnBuildEnded(data, failed);
|
||||
data.Tools->OnBuildEnded(data, failed);
|
||||
for (int32 stepIndex = 0; stepIndex < Steps.Count(); stepIndex++)
|
||||
Steps[stepIndex]->OnBuildEnded(data, failed);
|
||||
CallEvent(failed ? GameCooker::EventType::BuildFailed : GameCooker::EventType::BuildDone);
|
||||
Delete(Data);
|
||||
Data = nullptr;
|
||||
|
||||
return failed;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the current build data. Valid only during active build process.
|
||||
/// </summary>
|
||||
static const CookingData& GetCurrentData();
|
||||
API_PROPERTY() static CookingData* GetCurrentData();
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether game building is running.
|
||||
|
||||
Reference in New Issue
Block a user