Files
UnrealEngineUWP/Engine/Source/Programs/Shared/EpicGames.BuildGraph/BgLabelSpec.cs
Ben Marsh a59ef99c07 BuildGraph: New mechanism for declaring graphs using C# code (WIP).
Nodes can now be implemented by arbitary C# methods. Graph structure is specified through expression trees implemented using Bg* types, which are not substituted with values until execution time. Doing so allows determination of node and option dependencies for a particular target, allowing us to generate dynamic UI for presenting relevant settings to the user.

Includes partial implementation of Installed Build script as an example implementation.

#preflight 61bb85d46c2686e86322eec9

[CL 18477305 by Ben Marsh in ue5-main branch]
2021-12-16 13:55:22 -05:00

88 lines
2.3 KiB
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using EpicGames.BuildGraph.Expressions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace EpicGames.BuildGraph
{
/// <summary>
/// Configuration for a label
/// </summary>
public class BgLabelConfig
{
/// <summary>
/// Name of this badge
/// </summary>
public BgString? DashboardName { get; set; }
/// <summary>
/// Category for this label
/// </summary>
public BgString? DashboardCategory { get; }
/// <summary>
/// Name of the badge in UGS
/// </summary>
public BgString? UgsBadge { get; }
/// <summary>
/// Path to the project folder in UGS
/// </summary>
public BgString? UgsProject { get; }
/// <summary>
/// Which change to show the badge for
/// </summary>
public BgString? Change;
/// <summary>
/// Set of nodes that must be run for this label to be shown.
/// </summary>
public BgList<BgFileSet> RequiredNodes = BgList<BgFileSet>.Empty;
/// <summary>
/// Set of nodes that will be included in this label if present.
/// </summary>
public BgList<BgFileSet> IncludedNodes = BgList<BgFileSet>.Empty;
}
/// <summary>
/// Specification for a label
/// </summary>
public class BgLabelSpec
{
BgLabelConfig Config { get; }
internal BgLabelSpec(BgLabelConfig Config)
{
this.Config = Config;
}
internal void AddToGraph(BgExprContext Context, BgGraph Graph)
{
string? DashboardName = Config.DashboardName?.Compute(Context);
string? DashboardCategory = Config.DashboardCategory?.Compute(Context);
string? UgsBadge = Config.UgsBadge?.Compute(Context);
string? UgsProject = Config.UgsBadge?.Compute(Context);
BgLabelChange LabelChange;
if ((object?)Config.Change == null)
{
LabelChange = BgLabelChange.Current;
}
else
{
LabelChange = Enum.Parse<BgLabelChange>(Config.Change.Compute(Context));
}
BgLabel Label = new BgLabel(DashboardName, DashboardCategory, UgsBadge, UgsProject, LabelChange);
Label.RequiredNodes.UnionWith(Config.RequiredNodes.ComputeTags(Context).Select(x => Graph.TagNameToNodeOutput[x].ProducingNode));
Label.IncludedNodes.UnionWith(Config.IncludedNodes.ComputeTags(Context).Select(x => Graph.TagNameToNodeOutput[x].ProducingNode));
Graph.Labels.Add(Label);
}
}
}