Files
UnrealEngineUWP/Engine/Source/Programs/UnrealBuildTool/Configuration/UEBuildConfiguration.cs
Wes Hunt 012e45b913 UBT Utils.cs (New logging system)
* Allows us to use built-in Trace providers (console, file, etc) directly and still use our custom formatting.
* Fat comments explaining why Trace.WriteXXX functions should not be used directly in our system.
* Fixes thread safety by using Trace.WriteXXX under the hood after formatting, which uses a global lock (except on Mono, where a bug appears to be preventing this. Simulating the call on that platform).
* No need for TraceEvent overloads, which saves us the extra parameter cruft.
* Removed non-varargs overloads of Log functions (technically a bit slower, but these are already small messages).
* No longer needed VerbosityFilter and ConsoleListener classes.
* Avoid calling GetSource() if we aren't outputting the source.
* Avoid formatting the string if it won't pass the verbosity level.
* Consolidated all of UAT and UBT options into this class, so they could fully share the implementation.

UBT BuildConfiguration.cs
* Added LogFilename (and --log=<file> arg) that enables logging to a file.
* Added static ctor guard that asserts if someone tries to read a config before we have loaded config files and parsed config-override commandlines. It's a poor man's hack, but better than nothing!

UBT UEBuildConfiguration.cs
* Same static ctor guard as above.

UBT UnrealBuildTools.cs (initialization refactoring)
* In general I tried to de-mystify some of the rationale behind our startup code via fat comments.
* Broke main into 3 stages:
1. "early code" that should not try to read a config value.
  * Very little code here. Mostly setting the current directory.
  * Does an early init of logging to ensure logging is around, but config values won't be ready.
2. "Init Configuration code" that loads config files and parses command lines that may override them.
  * I isolated two locations in startup that parsed long sets of switches and moved ones that trivially affected BuildConfiguration and UEBuildConfiguration in here. Those two locations seemed to have mostly copies of the same switches, indicating serious param parsing issues at some point in time.
  * This allows switches to override config files more easily than the patchwork of re-parsing that was currently used (particularly for -verbose).
  * I did a cursory examination of later code that indicated this double (actually, triple) parsing was no longer necessary with the refactors above. Any insight into why things may have ended up this way would be helpful.
3. "Post Init code" that is actually the meat of UBT.
  * I left this code largely untouched.
  * Removed 2 of 3 different command line logging statements.
  * Removed two redundant parses of config overrides (ParseBuildConfigurationFlags).
* Guarded all of main in a try/catch block to ensure no exceptions can leak from UBT without returning a valid error code. It ALMOST already did this, but only covered the part surrounded by the Mutex.
* There was a perplexing bit that redundantly called XmlConfigLoader.Reset<> (line 683) that I struggled to understand. It turns out UEBuildConfiguration was sensitive to the current directory being set before files were loaded, and the old code called XmlConfigLoader.Init() super early, which required it to be called again after the current directory was set (see UEBuldConfiguration.UEThirdPartySourceDirectory for the cause). After my changes, I verified as best I could that these calls are no longer needed and removed them.

XmlConfigLoader.cs
* Add support for Properties in XmlConfigLoader.

AutomationTool Program.cs
* Guard logging shutdown code in try/finally so it can't be missed.

AutomationTool Log.cs
* Uses new logging system from UBT
* Removed unnecessary classes (VerbosityFilter, AutomationConsoleTraceListener, and AutomationFileTraceListener)
* Console trace logic is handled by UBT code now, moved UTF8Output handling to InitLogging.
* A custom TraceListener for file logging was unnecessary.
  * Logic to handle creating the log file and retry loops was move into InitLogging, and the result passed to a regular TextFileTraceListener.
  * Logic to handle copying the log on shutdown was moved to a ShutdownLogging function.
#codereview:robert.manuszewski,michael.trepka,kellan.carr

[CL 2526245 by Wes Hunt in Main branch]
2015-04-26 18:19:28 -04:00

291 lines
9.5 KiB
C#

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
using System;
using System.IO;
namespace UnrealBuildTool
{
public class UEBuildConfiguration
{
static UEBuildConfiguration()
{
if (!UnrealBuildTool.bIsSafeToReferenceConfigurationValues)
{
throw new BuildException("UEBuildConfiguration was referenced before the XmlConfig files could be loaded.");
}
}
/** Whether to include PhysX support */
[XmlConfig]
public static bool bCompilePhysX;
/** Whether to include PhysX APEX support */
[XmlConfig]
public static bool bCompileAPEX;
/** Whether to allow runtime cooking of physics */
[XmlConfig]
public static bool bRuntimePhysicsCooking;
/** Whether to include Box2D support */
[XmlConfig]
public static bool bCompileBox2D;
/** Whether to include ICU unicode/i18n support in core */
[XmlConfig]
public static bool bCompileICU;
/** Whether to build a stripped down version of the game specifically for dedicated server. */
[Obsolete("bBuildDedicatedServer has been deprecated and will be removed in future release. Update your code to use TargetInfo.Type instead or your code will not compile.")]
public static bool bBuildDedicatedServer;
/** Whether to compile the editor or not. Only desktop platforms (Windows or Mac) will use this, other platforms force this to false */
[XmlConfig]
public static bool bBuildEditor;
/** Whether to compile code related to building assets. Consoles generally cannot build assets. Desktop platforms generally can. */
[XmlConfig]
public static bool bBuildRequiresCookedData;
/** Whether to compile WITH_EDITORONLY_DATA disabled. Only Windows will use this, other platforms force this to false */
[XmlConfig]
public static bool bBuildWithEditorOnlyData;
/** Whether to compile the developer tools. */
[XmlConfig]
public static bool bBuildDeveloperTools;
/** Whether to force compiling the target platform modules, even if they wouldn't normally be built */
[XmlConfig]
public static bool bForceBuildTargetPlatforms;
/** Whether to force compiling shader format modules, even if they wouldn't normally be built. */
[XmlConfig]
public static bool bForceBuildShaderFormats;
/** Whether we should compile in support for Simplygon or not. */
[XmlConfig]
public static bool bCompileSimplygon;
/** Whether we should compile in support for Steam OnlineSubsystem or not. [RCL] FIXME 2014-Apr-17: bCompileSteamOSS means "bHasSteamworksInstalled" for some code, these meanings need to be untangled */
[XmlConfig]
public static bool bCompileSteamOSS;
/** Whether we should compile in support for Mcp OnlineSubsystem or not. */
[XmlConfig]
public static bool bCompileMcpOSS;
/** Whether to compile lean and mean version of UE. */
[XmlConfig]
public static bool bCompileLeanAndMeanUE;
/** Whether to generate a list of external files that are required to build a target */
[XmlConfig]
public static bool bGenerateExternalFileList;
/** Whether to merge to the existing list of external files */
[XmlConfig]
public static bool bMergeExternalFileList;
/** Whether to generate a manifest file that contains the files to add to Perforce */
[XmlConfig]
public static bool bGenerateManifest;
/** Whether to add to the existing manifest (if it exists), or start afresh */
[XmlConfig]
public static bool bMergeManifests;
/** Whether to 'clean' the given project */
[XmlConfig]
public static bool bCleanProject;
/** Whether we are just running the PrepTargetForDeployment step */
[XmlConfig]
public static bool bPrepForDeployment;
/** Enabled for all builds that include the engine project. Disabled only when building standalone apps that only link with Core. */
[XmlConfig]
public static bool bCompileAgainstEngine;
/** Enabled for all builds that include the CoreUObject project. Disabled only when building standalone apps that only link with Core. */
[XmlConfig]
public static bool bCompileAgainstCoreUObject;
/** If true, include ADO database support in core */
[XmlConfig]
public static bool bIncludeADO;
/** Directory for the third party files/libs */
[Obsolete("Use UEThirdPartySourceDirectory instead of UEThirdPartyDirectory.", true)]
[XmlConfig]
public static string UEThirdPartyDirectory;
/** Directory for the third party source */
[XmlConfig]
public static string UEThirdPartySourceDirectory;
/** Directory for the third party binaries */
[XmlConfig]
public static string UEThirdPartyBinariesDirectory;
/** If true, force header regeneration. Intended for the build machine */
[XmlConfig]
public static bool bForceHeaderGeneration;
/** If true, do not build UHT, assume it is already built */
[XmlConfig]
public static bool bDoNotBuildUHT;
/** If true, fail if any of the generated header files is out of date. */
[XmlConfig]
public static bool bFailIfGeneratedCodeChanges;
/** Whether to compile Recast navmesh generation */
[XmlConfig]
public static bool bCompileRecast;
/** Whether to compile SpeedTree support. */
[XmlConfig]
public static bool bCompileSpeedTree;
/** Enable exceptions for all modules */
[XmlConfig]
public static bool bForceEnableExceptions;
/** Compile server-only code. */
[XmlConfig]
public static bool bWithServerCode;
/** Whether to include stats support even without the engine */
[XmlConfig]
public static bool bCompileWithStatsWithoutEngine;
/** Whether to include plugin support */
[XmlConfig]
public static bool bCompileWithPluginSupport;
/** Whether to turn on logging for test/shipping builds */
[XmlConfig]
public static bool bUseLoggingInShipping;
/** True if we need PhysX vehicle support */
[XmlConfig]
public static bool bCompilePhysXVehicle;
/** True if we need FreeType support */
[XmlConfig]
public static bool bCompileFreeType;
/** True if we want to favor optimizing size over speed */
[XmlConfig]
public static bool bCompileForSize;
/** True if hot-reload from IDE is allowed */
[XmlConfig]
public static bool bAllowHotReloadFromIDE;
/** True if performing hot-reload from IDE */
public static bool bHotReloadFromIDE;
/** When true, the targets won't execute their link actions if there was nothing to compile */
public static bool bSkipLinkingWhenNothingToCompile;
/** Whether to compile CEF3 support. */
[XmlConfig]
public static bool bCompileCEF3;
/// <summary>
/// Sets the configuration back to defaults.
/// </summary>
public static void LoadDefaults()
{
//@todo. Allow disabling PhysX/APEX via these values...
// Currently, WITH_PHYSX is forced to true in Engine.h (as it isn't defined anywhere by the builder)
bCompilePhysX = true;
bCompileAPEX = true;
bRuntimePhysicsCooking = true;
bCompileBox2D = true;
bCompileICU = true;
bBuildEditor = true;
bBuildRequiresCookedData = false;
bBuildWithEditorOnlyData = true;
bBuildDeveloperTools = true;
bForceBuildTargetPlatforms = false;
bForceBuildShaderFormats = false;
bCompileSimplygon = true;
bCompileLeanAndMeanUE = false;
bCompileAgainstEngine = true;
bCompileAgainstCoreUObject = true;
UEThirdPartySourceDirectory = "ThirdParty/";
UEThirdPartyBinariesDirectory = "../Binaries/ThirdParty/";
bCompileRecast = true;
bForceEnableExceptions = false;
bWithServerCode = true;
bCompileSpeedTree = true;
bCompileWithStatsWithoutEngine = false;
bCompileWithPluginSupport = false;
bUseLoggingInShipping = false;
bCompileSteamOSS = true;
bCompileMcpOSS = true;
bCompilePhysXVehicle = true;
bCompileFreeType = true;
bCompileForSize = false;
bHotReloadFromIDE = false;
bAllowHotReloadFromIDE = true;
bSkipLinkingWhenNothingToCompile = false;
bCompileCEF3 = true;
}
/// <summary>
/// Function to call to after reset default data.
/// </summary>
public static void PostReset()
{
// Configuration overrides.
string SteamVersion = "Steamv132";
bCompileSteamOSS = bCompileSteamOSS
&& Directory.Exists(UEBuildConfiguration.UEThirdPartySourceDirectory + "Steamworks/" + SteamVersion) == true;
bCompileMcpOSS = bCompileMcpOSS
&& Directory.Exists("Runtime/Online/NotForLicensees/OnlineSubsystemMcp") == true;
bCompileSimplygon = bCompileSimplygon
&& Directory.Exists(UEBuildConfiguration.UEThirdPartySourceDirectory + "NotForLicensees") == true
&& Directory.Exists(UEBuildConfiguration.UEThirdPartySourceDirectory + "NotForLicensees/Simplygon") == true
&& Directory.Exists("Developer/SimplygonMeshReduction") == true
&& !(ProjectFileGenerator.bGenerateProjectFiles && ProjectFileGenerator.bGeneratingRocketProjectFiles);
if (UnrealBuildTool.CommandLineContains(@"UnrealCodeAnalyzer") || UnrealBuildTool.CommandLineContains(@"UnrealHeaderTool"))
{
BuildConfiguration.bRunUnrealCodeAnalyzer = false;
}
if (BuildConfiguration.bRunUnrealCodeAnalyzer)
{
BuildConfiguration.bUsePCHFiles = false;
BuildConfiguration.bUseUnityBuild = false;
BuildConfiguration.bUseSharedPCHs = false;
BuildConfiguration.bAllowXGE = false;
}
}
/**
* Validates the configuration.
*
* @warning: the order of validation is important
*/
public static void ValidateConfiguration()
{
// Lean and mean means no Editor and other frills.
if (bCompileLeanAndMeanUE)
{
bBuildEditor = false;
bBuildDeveloperTools = false;
bCompileSimplygon = false;
bCompileSpeedTree = false;
}
}
}
}