Posted onInUnrealEngine
,
UBTViews: Symbols count in article: 3.1kReading time ≈8 mins.
UE4 Engine defines many macros and some processing logic within the engine, such as WITH_ENGINE/WITH_EDITOR, etc. Some of these are defined by UBT through reading the configurations in *.target.cs files, and some logic is processed by reading configurations in *.Build.cs.
I have read some of the UBT code and extracted part of the configuration files (Target.cs/Build.cs) parameters and their mutual definitions with MACROs as a quick reference manual. You can view the parameters in *.Target.cs here: UnrealBuildSystem/Targets You can view the parameters in *.Build.cs here: UnrealBuildSystem/ModuleFiles UE’s build system documentation: Build Tools
// Propagate whether we want a lean and mean build to the C++ code. if (Rules.bCompileLeanAndMeanUE) { GlobalCompileEnvironment.Definitions.Add("UE_BUILD_MINIMAL=1"); } else { GlobalCompileEnvironment.Definitions.Add("UE_BUILD_MINIMAL=0"); }
WITH_EDITOR
(bool) bBuildEditor
Whether to compile the editor or not. Only desktop platforms (Windows or Mac) will use this, other platforms force this to false.
// bBuildEditor has now been set appropriately for all platforms, so this is here to make sure the #define if (Rules.bBuildEditor) { GlobalCompileEnvironment.Definitions.Add("WITH_EDITOR=1"); } elseif (!GlobalCompileEnvironment.Definitions.Contains("WITH_EDITOR=0")) { GlobalCompileEnvironment.Definitions.Add("WITH_EDITOR=0"); }
WITH_EDITORONLY_DATA
(bool) bBuildWithEditorOnlyData
Whether to compile WITH_EDITORONLY_DATA disabled. Only Windows will use this, other platforms force this to false.
// Check if server-only code should be compiled out. if (Rules.bWithServerCode == true) { GlobalCompileEnvironment.Definitions.Add("WITH_SERVER_CODE=1"); } else { GlobalCompileEnvironment.Definitions.Add("WITH_SERVER_CODE=0"); }
// Programs/UnrealBuildTool/Configuration/ModuleRules.cs // SetupModulePhysXAPEXSupport(ReadOnlyTargetRules Target) // definitions used outside of PhysX/APEX need to be set here, not in PhysX.Build.cs or APEX.Build.cs, // since we need to make sure we always set it, even to 0 (because these are Private dependencies, the // defines inside their Build.cs files won't leak out) if (Target.bCompilePhysX == true) { PrivateDependencyModuleNames.Add("PhysX"); PublicDefinitions.Add("WITH_PHYSX=1"); } else { PublicDefinitions.Add("WITH_PHYSX=0"); }
// Programs/UnrealBuildTool/Configuration/ModuleRules.cs // SetupModulePhysXAPEXSupport(ReadOnlyTargetRules Target) if (Target.bCompileAPEX == true) { if (!Target.bCompilePhysX) { thrownew BuildException("APEX is enabled, without PhysX. This is not supported!"); }
PrivateDependencyModuleNames.Add("APEX"); PublicDefinitions.Add("WITH_APEX=1"); PublicDefinitions.Add("WITH_APEX_CLOTHING=1"); PublicDefinitions.Add("WITH_CLOTH_COLLISION_DETECTION=1"); PublicDefinitions.Add("WITH_PHYSX_COOKING=1"); // APEX currently relies on cooking even at runtime
} else { PublicDefinitions.Add("WITH_APEX=0"); PublicDefinitions.Add("WITH_APEX_CLOTHING=0"); PublicDefinitions.Add("WITH_CLOTH_COLLISION_DETECTION=0"); PublicDefinitions.Add(string.Format("WITH_PHYSX_COOKING={0}", Target.bBuildEditor && Target.bCompilePhysX ? 1 : 0)); // without APEX, we only need cooking in editor builds }
WITH_NVCLOTH
(bool) bCompileNvCloth
Whether to include NvCloth.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// Programs/UnrealBuildTool/Configuration/ModuleRules.cs // SetupModulePhysXAPEXSupport(ReadOnlyTargetRules Target) if (Target.bCompileNvCloth == true) { if (!Target.bCompilePhysX) { thrownew BuildException("NvCloth is enabled, without PhysX. This is not supported!"); }
// Programs/UnrealBuildTool/Platform/Windows/VCToolChains.cs // void AppendLibArguments(LinkEnvironment LinkEnvironment, List<string> Arguments) voidAppendLibArguments(LinkEnvironment LinkEnvironment, List<string> Arguments) { // Prevents the linker from displaying its logo for each invocation. Arguments.Add("/NOLOGO");
// Prompt the user before reporting internal errors to Microsoft. Arguments.Add("/errorReport:prompt");
// // PC // if (LinkEnvironment.Platform == CppPlatform.Win32 || LinkEnvironment.Platform == CppPlatform.Win64) { // Set machine type/ architecture to be 64 bit. if (LinkEnvironment.Platform == CppPlatform.Win64) { Arguments.Add("/MACHINE:x64"); } // 32 bit executable/ target. else { Arguments.Add("/MACHINE:x86"); }