Build.cs

From UE4: Community Wiki
Jump to: navigation, search

The Build.cs C# code is attached to each module and defines how the code for each module is built. There are many variables in this class that users can take advantage of to compile code conditionally per different build situation or set up a special types of modules.

UnrealBuildTool specification[edit]

ModuleRules[edit]

PCHUsage[edit]

Example:

PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

Options: (from Engine/Source/Programs/UnrealBuildTool/Configuration/ModuleRules.cs)

public enum PCHUsageMode
{
  /// Default: Engine modules use shared PCHs, game modules do not
  Default,

  /// Never use shared PCHs. Always generate a unique PCH for this module if appropriate
  NoSharedPCHs,

  /// Shared PCHs are OK!
  UseSharedPCHs,

  /// Shared PCHs may be used if an explicit private PCH is not set through PrivatePCHHeaderFile. In either case, none of the source files manually include a module PCH, and should include a matching header instead.
  UseExplicitOrSharedPCHs
}

Target[edit]

You can use Target to get to a lot of the properties of the build's target settings, such as platform or type of build being compiled.

Configuration[edit]

Example:

if(Target.Configuration == UnrealTargetConfiguration.Shipping)
{
      ...
}

Options: (from Engine/Source/Programs/UnrealBuildTool/Configuration/UEBuildTarget.cs)

public enum UnrealTargetConfiguration
{
	Unknown,
	Debug,
	DebugGame,
	Development,
	Shipping,
	Test
}

Platform[edit]

Example:

if(Target.Platform == UnrealTargetPlatform.Win64)
{
      ...
}


Options: (from Engine/Source/Programs/UnrealBuildTool/Configuration/UEBuildTarget.cs)

public static UnrealTargetPlatform Win32 = FindOrAddByName("Win32");
public static UnrealTargetPlatform Win64 = FindOrAddByName("Win64");
public static UnrealTargetPlatform HoloLens = FindOrAddByName("HoloLens");
public static UnrealTargetPlatform Mac = FindOrAddByName("Mac");
public static UnrealTargetPlatform XboxOne = FindOrAddByName("XboxOne");
public static UnrealTargetPlatform PS4 = FindOrAddByName("PS4");
public static UnrealTargetPlatform IOS = FindOrAddByName("IOS");
public static UnrealTargetPlatform Android = FindOrAddByName("Android");
public static UnrealTargetPlatform Linux = FindOrAddByName("Linux");
public static UnrealTargetPlatform LinuxAArch64 = FindOrAddByName("LinuxAArch64");
public static UnrealTargetPlatform AllDesktop = FindOrAddByName("AllDesktop");
public static UnrealTargetPlatform TVOS = FindOrAddByName("TVOS");
public static UnrealTargetPlatform Switch = FindOrAddByName("Switch");
public static UnrealTargetPlatform Quail = FindOrAddByName("Quail");
public static UnrealTargetPlatform Lumin = FindOrAddByName("Lumin");

Type[edit]

Example:

if(Target.Type == TargetType.Editor)
{
      ...
}


Options: (from Engine/Source/Programs/UnrealBuildTool/Configuration/TargetRules.cs)

public enum TargetType
{
	Game,
	Editor,
	Client,
	Server,
	Program,
}