Add build preset and target names to access for Game Cooker extending
This commit is contained in:
@@ -145,6 +145,16 @@ public:
|
||||
/// </summary>
|
||||
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>
|
||||
/// 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>
|
||||
|
||||
@@ -318,7 +318,7 @@ PlatformTools* GameCooker::GetTools(BuildPlatform platform)
|
||||
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())
|
||||
{
|
||||
@@ -342,6 +342,8 @@ void GameCooker::Build(BuildPlatform platform, BuildConfiguration configuration,
|
||||
data.Platform = platform;
|
||||
data.Configuration = configuration;
|
||||
data.Options = options;
|
||||
data.Preset = preset;
|
||||
data.PresetTarget = presetTarget;
|
||||
data.CustomDefines = customDefines;
|
||||
data.OriginalOutputPath = outputPath;
|
||||
FileSystem::NormalizePath(data.OriginalOutputPath);
|
||||
|
||||
@@ -83,7 +83,9 @@ public:
|
||||
/// <param name="outputPath">The output path (output directory).</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>
|
||||
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>
|
||||
/// Sends a cancel event to the game building service.
|
||||
|
||||
@@ -1189,7 +1189,7 @@ namespace FlaxEditor
|
||||
return true;
|
||||
}
|
||||
|
||||
Windows.GameCookerWin.Build(target);
|
||||
Windows.GameCookerWin.Build(preset, target);
|
||||
}
|
||||
|
||||
Windows.GameCookerWin.ExitOnBuildQueueEnd();
|
||||
|
||||
@@ -446,12 +446,18 @@ namespace FlaxEditor.Windows
|
||||
}
|
||||
}
|
||||
|
||||
private struct QueueItem
|
||||
{
|
||||
public string PresetName;
|
||||
public BuildTarget Target;
|
||||
}
|
||||
|
||||
private PresetsColumn _presets;
|
||||
private TargetsColumn _targets;
|
||||
private int _selectedPresetIndex = -1;
|
||||
private int _selectedTargetIndex = -1;
|
||||
private CustomEditorPresenter _targetSettings;
|
||||
private readonly Queue<BuildTarget> _buildingQueue = new Queue<BuildTarget>();
|
||||
private readonly Queue<QueueItem> _buildingQueue = new Queue<QueueItem>();
|
||||
private string _preBuildAction;
|
||||
private string _postBuildAction;
|
||||
private BuildPreset[] _data;
|
||||
@@ -487,16 +493,19 @@ namespace FlaxEditor.Windows
|
||||
{
|
||||
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
|
||||
if (!string.IsNullOrEmpty(_preBuildAction))
|
||||
ExecueAction(_preBuildAction);
|
||||
ExecuteAction(_preBuildAction);
|
||||
_preBuildAction = null;
|
||||
}
|
||||
else if (type == GameCooker.EventType.BuildDone)
|
||||
{
|
||||
// Execute post-build action
|
||||
if (!string.IsNullOrEmpty(_postBuildAction))
|
||||
ExecueAction(_postBuildAction);
|
||||
ExecuteAction(_postBuildAction);
|
||||
_postBuildAction = null;
|
||||
}
|
||||
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;
|
||||
command = command.Replace("\n", "\r\n");
|
||||
@@ -545,21 +554,30 @@ namespace FlaxEditor.Windows
|
||||
Editor.Log("Building all targets");
|
||||
foreach (var e in preset.Targets)
|
||||
{
|
||||
_buildingQueue.Enqueue(e.DeepClone());
|
||||
_buildingQueue.Enqueue(new QueueItem
|
||||
{
|
||||
PresetName = preset.Name,
|
||||
Target = e.DeepClone(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds the target.
|
||||
/// </summary>
|
||||
/// <param name="preset">The preset.</param>
|
||||
/// <param name="target">The target.</param>
|
||||
public void Build(BuildTarget target)
|
||||
public void Build(BuildPreset preset, BuildTarget target)
|
||||
{
|
||||
if (target == null)
|
||||
throw new ArgumentNullException(nameof(target));
|
||||
|
||||
Editor.Log("Building target");
|
||||
_buildingQueue.Enqueue(target.DeepClone());
|
||||
_buildingQueue.Enqueue(new QueueItem
|
||||
{
|
||||
PresetName = preset.Name,
|
||||
Target = target.DeepClone(),
|
||||
});
|
||||
}
|
||||
|
||||
private void BuildTarget()
|
||||
@@ -569,7 +587,8 @@ namespace FlaxEditor.Windows
|
||||
if (_data[_selectedPresetIndex].Targets == null || _data[_selectedPresetIndex].Targets.Length <= _selectedTargetIndex)
|
||||
return;
|
||||
|
||||
Build(_data[_selectedPresetIndex].Targets[_selectedTargetIndex]);
|
||||
var preset = _data[_selectedPresetIndex];
|
||||
Build(preset, preset.Targets[_selectedTargetIndex]);
|
||||
}
|
||||
|
||||
private void BuildAllTargets()
|
||||
@@ -825,12 +844,13 @@ namespace FlaxEditor.Windows
|
||||
{
|
||||
if (_buildingQueue.Count > 0)
|
||||
{
|
||||
var target = _buildingQueue.Dequeue();
|
||||
var item = _buildingQueue.Dequeue();
|
||||
var target = item.Target;
|
||||
|
||||
_preBuildAction = target.PreBuildAction;
|
||||
_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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user