Add build preset and target names to access for Game Cooker extending
This commit is contained in:
@@ -145,6 +145,16 @@ public:
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
API_FIELD(ReadOnly) BuildOptions Options;
|
API_FIELD(ReadOnly) BuildOptions Options;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The name of build preset used for cooking (can be used by editor and game plugins).
|
||||||
|
/// </summary>
|
||||||
|
API_FIELD(ReadOnly) String Preset;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The name of build preset target used for cooking (can be used by editor and game plugins).
|
||||||
|
/// </summary>
|
||||||
|
API_FIELD(ReadOnly) String PresetTarget;
|
||||||
|
|
||||||
/// <summary>
|
/// <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).
|
/// 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>
|
/// </summary>
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ PlatformTools* GameCooker::GetTools(BuildPlatform platform)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameCooker::Build(BuildPlatform platform, BuildConfiguration configuration, const StringView& outputPath, BuildOptions options, const Array<String>& customDefines)
|
void GameCooker::Build(BuildPlatform platform, BuildConfiguration configuration, const StringView& outputPath, BuildOptions options, const Array<String>& customDefines, const StringView& preset, const StringView& presetTarget)
|
||||||
{
|
{
|
||||||
if (IsRunning())
|
if (IsRunning())
|
||||||
{
|
{
|
||||||
@@ -342,6 +342,8 @@ void GameCooker::Build(BuildPlatform platform, BuildConfiguration configuration,
|
|||||||
data.Platform = platform;
|
data.Platform = platform;
|
||||||
data.Configuration = configuration;
|
data.Configuration = configuration;
|
||||||
data.Options = options;
|
data.Options = options;
|
||||||
|
data.Preset = preset;
|
||||||
|
data.PresetTarget = presetTarget;
|
||||||
data.CustomDefines = customDefines;
|
data.CustomDefines = customDefines;
|
||||||
data.OriginalOutputPath = outputPath;
|
data.OriginalOutputPath = outputPath;
|
||||||
FileSystem::NormalizePath(data.OriginalOutputPath);
|
FileSystem::NormalizePath(data.OriginalOutputPath);
|
||||||
|
|||||||
@@ -83,7 +83,9 @@ public:
|
|||||||
/// <param name="outputPath">The output path (output directory).</param>
|
/// <param name="outputPath">The output path (output directory).</param>
|
||||||
/// <param name="options">The build options.</param>
|
/// <param name="options">The build options.</param>
|
||||||
/// <param name="customDefines">The list of custom defines passed to the build tool when compiling project scripts. Can be used in build scripts for configuration (Configuration.CustomDefines).</param>
|
/// <param name="customDefines">The list of custom defines passed to the build tool when compiling project scripts. Can be used in build scripts for configuration (Configuration.CustomDefines).</param>
|
||||||
API_FUNCTION() static void Build(BuildPlatform platform, BuildConfiguration configuration, const StringView& outputPath, BuildOptions options, const Array<String>& customDefines);
|
/// <param name="preset">The name of build preset used for cooking (can be used by editor and game plugins).</param>
|
||||||
|
/// <param name="presetTarget">The name of build preset target used for cooking (can be used by editor and game plugins).</param>
|
||||||
|
API_FUNCTION() static void Build(BuildPlatform platform, BuildConfiguration configuration, const StringView& outputPath, BuildOptions options, const Array<String>& customDefines, const StringView& preset = StringView::Empty, const StringView& presetTarget = StringView::Empty);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a cancel event to the game building service.
|
/// Sends a cancel event to the game building service.
|
||||||
|
|||||||
@@ -1189,7 +1189,7 @@ namespace FlaxEditor
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Windows.GameCookerWin.Build(target);
|
Windows.GameCookerWin.Build(preset, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
Windows.GameCookerWin.ExitOnBuildQueueEnd();
|
Windows.GameCookerWin.ExitOnBuildQueueEnd();
|
||||||
|
|||||||
@@ -446,12 +446,18 @@ namespace FlaxEditor.Windows
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private struct QueueItem
|
||||||
|
{
|
||||||
|
public string PresetName;
|
||||||
|
public BuildTarget Target;
|
||||||
|
}
|
||||||
|
|
||||||
private PresetsColumn _presets;
|
private PresetsColumn _presets;
|
||||||
private TargetsColumn _targets;
|
private TargetsColumn _targets;
|
||||||
private int _selectedPresetIndex = -1;
|
private int _selectedPresetIndex = -1;
|
||||||
private int _selectedTargetIndex = -1;
|
private int _selectedTargetIndex = -1;
|
||||||
private CustomEditorPresenter _targetSettings;
|
private CustomEditorPresenter _targetSettings;
|
||||||
private readonly Queue<BuildTarget> _buildingQueue = new Queue<BuildTarget>();
|
private readonly Queue<QueueItem> _buildingQueue = new Queue<QueueItem>();
|
||||||
private string _preBuildAction;
|
private string _preBuildAction;
|
||||||
private string _postBuildAction;
|
private string _postBuildAction;
|
||||||
private BuildPreset[] _data;
|
private BuildPreset[] _data;
|
||||||
@@ -487,16 +493,19 @@ namespace FlaxEditor.Windows
|
|||||||
{
|
{
|
||||||
if (type == GameCooker.EventType.BuildStarted)
|
if (type == GameCooker.EventType.BuildStarted)
|
||||||
{
|
{
|
||||||
|
Debug.Log("Cooking started: " + (GameCooker.CurrentData.Preset ?? "null"));
|
||||||
|
Debug.Log("Cooking started: " + (GameCooker.CurrentData.PresetTarget ?? "null"));
|
||||||
|
|
||||||
// Execute pre-build action
|
// Execute pre-build action
|
||||||
if (!string.IsNullOrEmpty(_preBuildAction))
|
if (!string.IsNullOrEmpty(_preBuildAction))
|
||||||
ExecueAction(_preBuildAction);
|
ExecuteAction(_preBuildAction);
|
||||||
_preBuildAction = null;
|
_preBuildAction = null;
|
||||||
}
|
}
|
||||||
else if (type == GameCooker.EventType.BuildDone)
|
else if (type == GameCooker.EventType.BuildDone)
|
||||||
{
|
{
|
||||||
// Execute post-build action
|
// Execute post-build action
|
||||||
if (!string.IsNullOrEmpty(_postBuildAction))
|
if (!string.IsNullOrEmpty(_postBuildAction))
|
||||||
ExecueAction(_postBuildAction);
|
ExecuteAction(_postBuildAction);
|
||||||
_postBuildAction = null;
|
_postBuildAction = null;
|
||||||
}
|
}
|
||||||
else if (type == GameCooker.EventType.BuildFailed)
|
else if (type == GameCooker.EventType.BuildFailed)
|
||||||
@@ -506,7 +515,7 @@ namespace FlaxEditor.Windows
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ExecueAction(string action)
|
private void ExecuteAction(string action)
|
||||||
{
|
{
|
||||||
string command = "echo off\ncd \"" + Globals.ProjectFolder.Replace('/', '\\') + "\"\necho on\n" + action;
|
string command = "echo off\ncd \"" + Globals.ProjectFolder.Replace('/', '\\') + "\"\necho on\n" + action;
|
||||||
command = command.Replace("\n", "\r\n");
|
command = command.Replace("\n", "\r\n");
|
||||||
@@ -545,21 +554,30 @@ namespace FlaxEditor.Windows
|
|||||||
Editor.Log("Building all targets");
|
Editor.Log("Building all targets");
|
||||||
foreach (var e in preset.Targets)
|
foreach (var e in preset.Targets)
|
||||||
{
|
{
|
||||||
_buildingQueue.Enqueue(e.DeepClone());
|
_buildingQueue.Enqueue(new QueueItem
|
||||||
|
{
|
||||||
|
PresetName = preset.Name,
|
||||||
|
Target = e.DeepClone(),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Builds the target.
|
/// Builds the target.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="preset">The preset.</param>
|
||||||
/// <param name="target">The target.</param>
|
/// <param name="target">The target.</param>
|
||||||
public void Build(BuildTarget target)
|
public void Build(BuildPreset preset, BuildTarget target)
|
||||||
{
|
{
|
||||||
if (target == null)
|
if (target == null)
|
||||||
throw new ArgumentNullException(nameof(target));
|
throw new ArgumentNullException(nameof(target));
|
||||||
|
|
||||||
Editor.Log("Building target");
|
Editor.Log("Building target");
|
||||||
_buildingQueue.Enqueue(target.DeepClone());
|
_buildingQueue.Enqueue(new QueueItem
|
||||||
|
{
|
||||||
|
PresetName = preset.Name,
|
||||||
|
Target = target.DeepClone(),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BuildTarget()
|
private void BuildTarget()
|
||||||
@@ -569,7 +587,8 @@ namespace FlaxEditor.Windows
|
|||||||
if (_data[_selectedPresetIndex].Targets == null || _data[_selectedPresetIndex].Targets.Length <= _selectedTargetIndex)
|
if (_data[_selectedPresetIndex].Targets == null || _data[_selectedPresetIndex].Targets.Length <= _selectedTargetIndex)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Build(_data[_selectedPresetIndex].Targets[_selectedTargetIndex]);
|
var preset = _data[_selectedPresetIndex];
|
||||||
|
Build(preset, preset.Targets[_selectedTargetIndex]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BuildAllTargets()
|
private void BuildAllTargets()
|
||||||
@@ -825,12 +844,13 @@ namespace FlaxEditor.Windows
|
|||||||
{
|
{
|
||||||
if (_buildingQueue.Count > 0)
|
if (_buildingQueue.Count > 0)
|
||||||
{
|
{
|
||||||
var target = _buildingQueue.Dequeue();
|
var item = _buildingQueue.Dequeue();
|
||||||
|
var target = item.Target;
|
||||||
|
|
||||||
_preBuildAction = target.PreBuildAction;
|
_preBuildAction = target.PreBuildAction;
|
||||||
_postBuildAction = target.PostBuildAction;
|
_postBuildAction = target.PostBuildAction;
|
||||||
|
|
||||||
GameCooker.Build(target.Platform, target.Mode, target.Output, BuildOptions.None, target.CustomDefines);
|
GameCooker.Build(target.Platform, target.Mode, target.Output, BuildOptions.None, target.CustomDefines, item.PresetName, target.Name);
|
||||||
}
|
}
|
||||||
else if (_exitOnBuildEnd)
|
else if (_exitOnBuildEnd)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user