// Copyright Epic Games, Inc. All Rights Reserved.
using System;
namespace UnrealBuildTool
{
///
/// Attribute which can be applied to a TargetRules-dervied class to indicate which platforms it supports
///
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1813:Avoid unsealed attributes")]
public class SupportedPlatformsAttribute : Attribute
{
///
/// Array of supported platforms
///
public UnrealTargetPlatform[] Platforms { get; }
///
/// Initialize the attribute with a list of platforms
///
/// Variable-length array of platform arguments
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1019:Define accessors for attribute arguments", Justification = "Unneeded")]
public SupportedPlatformsAttribute(params string[] platforms)
{
try
{
Platforms = Array.ConvertAll(platforms, x => UnrealTargetPlatform.Parse(x));
}
catch (BuildException ex)
{
EpicGames.Core.ExceptionUtils.AddContext(ex, "while parsing a SupportedPlatforms attribute");
throw;
}
}
///
/// Initialize the attribute with all the platforms in a given category
///
/// Category of platforms to add
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1019:Define accessors for attribute arguments", Justification = "Unneeded")]
public SupportedPlatformsAttribute(UnrealPlatformClass category)
{
Platforms = Utils.GetPlatformsInClass(category);
}
}
}