// Copyright Epic Games, Inc. All Rights Reserved. using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using EpicGames.Core; namespace UnrealBuildTool { /// /// Controls how a particular warning is treated /// public enum WarningLevel { /// /// Do not display diagnostics /// Off, /// /// Output warnings normally /// Warning, /// /// Output warnings as errors /// Error, } /// /// ModuleRules is a data structure that contains the rules for defining a module /// public class ModuleRules { /// /// Type of module /// public enum ModuleType { /// /// C++ /// CPlusPlus, /// /// External (third-party) /// External, } /// /// Override the settings of the UHTModuleType to have a different set of /// PKG_ flags. Cannot set on a plugin because that value already set in /// the '.uplugin' file /// public enum PackageOverrideType { /// /// Do not override the package type on this module /// None, /// /// Set the PKG_EditorOnly flag on this module /// EditorOnly, /// /// Set the PKG_Developer on this module /// EngineDeveloper, /// /// Set the PKG_Developer on this module /// GameDeveloper, /// /// Set the PKG_UncookedOnly flag on this module /// EngineUncookedOnly, /// /// Set the PKG_UncookedOnly flag on this module as a game /// GameUncookedOnly } /// /// Code optimization settings /// public enum CodeOptimization { /// /// Code should never be optimized if possible. /// Never, /// /// Code should only be optimized in non-debug builds (not in Debug). /// InNonDebugBuilds, /// /// Code should only be optimized in shipping builds (not in Debug, DebugGame, Development) /// InShippingBuildsOnly, /// /// Code should always be optimized if possible. /// Always, /// /// Default: 'InNonDebugBuilds' for game modules, 'Always' otherwise. /// Default, } /// /// What type of PCH to use for this module. /// public enum PCHUsageMode { /// /// Default: Engine modules use shared PCHs, game modules do not /// Default, /// /// Never use any PCHs. /// NoPCHs, /// /// 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, } /// /// Which type of targets this module should be precompiled for /// public enum PrecompileTargetsType { /// /// Never precompile this module. /// None, /// /// Inferred from the module's directory. Engine modules under Engine/Source/Runtime will be compiled for games, those under Engine/Source/Editor will be compiled for the editor, etc... /// Default, /// /// Any game targets. /// Game, /// /// Any editor targets. /// Editor, /// /// Any targets. /// Any, } /// /// Control visibility of symbols in this module for special cases /// public enum SymbolVisibility { /// /// Standard visibility rules /// Default, /// /// Make sure symbols in this module are visible in Dll builds /// VisibileForDll, } /// /// Information about a file which is required by the target at runtime, and must be moved around with it. /// [Serializable] public class RuntimeDependency { /// /// The file that should be staged. Should use $(EngineDir) and $(ProjectDir) variables as a root, so that the target can be relocated to different machines. /// public string Path; /// /// The initial location for this file. It will be copied to Path at build time, ready for staging. /// public string? SourcePath; /// /// How to stage this file. /// public StagedFileType Type; /// /// Constructor /// /// Path to the runtime dependency /// How to stage the given path public RuntimeDependency(string InPath, StagedFileType InType = StagedFileType.NonUFS) { Path = InPath; Type = InType; } /// /// Constructor /// /// Path to the runtime dependency /// Source path for the file in the working tree /// How to stage the given path public RuntimeDependency(string InPath, string InSourcePath, StagedFileType InType = StagedFileType.NonUFS) { Path = InPath; SourcePath = InSourcePath; Type = InType; } } /// /// List of runtime dependencies, with convenience methods for adding new items /// [Serializable] public class RuntimeDependencyList { /// /// Inner list of runtime dependencies /// internal List Inner = new List(); /// /// Default constructor /// public RuntimeDependencyList() { } /// /// Add a runtime dependency to the list /// /// Path to the runtime dependency. May include wildcards. public void Add(string InPath) { Inner.Add(new RuntimeDependency(InPath)); } /// /// Add a runtime dependency to the list /// /// Path to the runtime dependency. May include wildcards. /// How to stage this file public void Add(string InPath, StagedFileType InType) { Inner.Add(new RuntimeDependency(InPath, InType)); } /// /// Add a runtime dependency to the list /// /// Path to the runtime dependency. May include wildcards. /// Source path for the file to be added as a dependency. May include wildcards. /// How to stage this file public void Add(string InPath, string InSourcePath, StagedFileType InType = StagedFileType.NonUFS) { Inner.Add(new RuntimeDependency(InPath, InSourcePath, InType)); } /// /// Add a runtime dependency to the list /// /// RuntimeDependency instance [Obsolete("Constructing a RuntimeDependency object is deprecated. Call RuntimeDependencies.Add() with the path to the file to stage.")] public void Add(RuntimeDependency InRuntimeDependency) { Inner.Add(InRuntimeDependency); } } /// /// List of runtime dependencies, with convenience methods for adding new items /// [Serializable] public class ReceiptPropertyList { /// /// Inner list of runtime dependencies /// internal List Inner = new List(); /// /// Default constructor /// public ReceiptPropertyList() { } /// /// Add a receipt property to the list /// /// Name of the property /// Value for the property public void Add(string Name, string Value) { Inner.Add(new ReceiptProperty(Name, Value)); } /// /// Add a receipt property to the list /// /// ReceiptProperty instance [Obsolete("Constructing a ReceiptProperty object is deprecated. Call ReceiptProperties.Add() with the path to the file to stage.")] public void Add(ReceiptProperty InReceiptProperty) { Inner.Add(InReceiptProperty); } } /// /// Stores information about a framework on IOS or MacOS /// public class Framework { /// /// Name of the framework /// internal string Name; /// /// Specifies the path to a zip file that contains it or where the framework is located on disk /// internal string Path; /// /// /// internal string? CopyBundledAssets = null; /// /// Copy the framework to the target's Framework directory /// internal bool bCopyFramework = false; /// /// Constructor /// /// Name of the framework /// Path to a zip file containing the framework or a framework on disk /// /// Copy the framework to the target's Framework directory public Framework(string Name, string Path, string? CopyBundledAssets = null, bool bCopyFramework = false) { this.Name = Name; this.Path = Path; this.CopyBundledAssets = CopyBundledAssets; this.bCopyFramework = bCopyFramework; } /// /// Specifies if the file is a zip file /// public bool IsZipFile() { return Path.EndsWith(".zip"); } } /// /// Deprecated; wrapper for Framework. /// [Obsolete("The UEBuildFramework class has been deprecated in UE 4.22. Please use the Framework class instead.")] public class UEBuildFramework : Framework { /// /// Constructor /// /// Name of the framework /// Path to a zip file containing the framework /// public UEBuildFramework(string Name, string ZipPath, string? CopyBundledAssets = null) : base(Name, ZipPath, CopyBundledAssets) { } } /// /// /// public class BundleResource { /// /// /// public string? ResourcePath = null; /// /// /// public string? BundleContentsSubdir = null; /// /// /// public bool bShouldLog = true; /// /// Constructor /// /// /// /// public BundleResource(string ResourcePath, string BundleContentsSubdir = "Resources", bool bShouldLog = true) { this.ResourcePath = ResourcePath; this.BundleContentsSubdir = BundleContentsSubdir; this.bShouldLog = bShouldLog; } } /// /// Deprecated; wrapper for BundleResource. /// [Obsolete("The UEBuildBundleResource class has been deprecated in UE 4.22. Please use the BundleResource class instead.")] public class UEBuildBundleResource : BundleResource { /// /// Constructor /// /// /// /// public UEBuildBundleResource(string InResourcePath, string InBundleContentsSubdir = "Resources", bool bInShouldLog = true) : base(InResourcePath, InBundleContentsSubdir, bInShouldLog) { } } /// /// Information about a Windows type library (TLB/OLB file) which requires a generated header. /// public class TypeLibrary { /// /// Name of the type library /// public string FileName; /// /// Additional attributes for the #import directive /// public string Attributes; /// /// Name of the output header /// public string Header; /// /// Constructor /// /// Name of the type library. Follows the same conventions as the filename parameter in the MSVC #import directive. /// Additional attributes for the import directive /// Name of the output header public TypeLibrary(string FileName, string Attributes, string Header) { this.FileName = FileName; this.Attributes = Attributes; this.Header = Header; } } /// /// Name of this module /// public string Name { get; internal set; } /// /// File containing this module /// internal FileReference File { get; set; } /// /// Directory containing this module /// internal DirectoryReference Directory { get; set; } /// /// Additional directories that contribute to this module (likely in UnrealBuildTool.EnginePlatformExtensionsDirectory). /// The dictionary tracks module subclasses /// internal Dictionary? DirectoriesForModuleSubClasses; /// /// Additional directories that contribute to this module but are not based on a subclass (NotForLicensees, etc) /// private List AdditionalModuleDirectories = new List(); /// /// Plugin containing this module /// internal PluginInfo? Plugin; /// /// True if a Plugin contains this module /// public bool IsPlugin { get { return Plugin != null; } } /// /// The rules context for this instance /// internal ModuleRulesContext Context { get; set; } /// /// Rules for the target that this module belongs to /// public readonly ReadOnlyTargetRules Target; /// /// Type of module /// public ModuleType Type = ModuleType.CPlusPlus; /// /// Overridden type of module that will set different package flags. /// Cannot be used for modules that are a part of a plugin because that is /// set in the `.uplugin` file already. /// public PackageOverrideType OverridePackageType { get { return overridePackageType ?? PackageOverrideType.None; } set { if (!IsPlugin) { overridePackageType = value; } else { throw new BuildException("Module '{0}' cannot override package type because it is part of a plugin!", Name); } } } private PackageOverrideType? overridePackageType; /// /// Returns true if there has been an override type specified on this module /// public bool HasPackageOverride { get { return OverridePackageType != PackageOverrideType.None; } } /// /// Subfolder of Binaries/PLATFORM folder to put this module in when building DLLs. This should only be used by modules that are found via searching like the /// TargetPlatform or ShaderFormat modules. If FindModules is not used to track them down, the modules will not be found. /// public string BinariesSubFolder = ""; private CodeOptimization? OptimizeCodeOverride; /// /// When this module's code should be optimized. /// public CodeOptimization OptimizeCode { get { if (OptimizeCodeOverride.HasValue) return OptimizeCodeOverride.Value; bool? ShouldOptimizeCode = null; if (Target.EnableOptimizeCodeForModules?.Contains(Name) ?? false) ShouldOptimizeCode = true; if (Target.DisableOptimizeCodeForModules?.Contains(Name) ?? false) ShouldOptimizeCode = false; if (!ShouldOptimizeCode.HasValue) return CodeOptimization.Default; return ShouldOptimizeCode.Value ? CodeOptimization.Always : CodeOptimization.Never; } set { OptimizeCodeOverride = value; } } /// /// Explicit private PCH for this module. Implies that this module will not use a shared PCH. /// public string? PrivatePCHHeaderFile; /// /// Header file name for a shared PCH provided by this module. Must be a valid relative path to a public C++ header file. /// This should only be set for header files that are included by a significant number of other C++ modules. /// public string? SharedPCHHeaderFile; /// /// Specifies an alternate name for intermediate directories and files for intermediates of this module. Useful when hitting path length limitations. /// public string? ShortName = null; /// /// Precompiled header usage for this module /// public PCHUsageMode PCHUsage { get { if (PCHUsagePrivate.HasValue) { // Use the override return PCHUsagePrivate.Value; } else if (Target.bEnableCppModules) { return PCHUsageMode.NoPCHs; } else if (Target.bIWYU || DefaultBuildSettings >= BuildSettingsVersion.V2) { // Use shared or explicit PCHs, and enable IWYU return PCHUsageMode.UseExplicitOrSharedPCHs; } else if (Plugin != null) { // Older plugins use shared PCHs by default, since they aren't typically large enough to warrant their own PCH. return PCHUsageMode.UseSharedPCHs; } else { // Older game modules do not enable shared PCHs by default, because games usually have a large precompiled header of their own. return PCHUsageMode.NoSharedPCHs; } } set { PCHUsagePrivate = value; } } private PCHUsageMode? PCHUsagePrivate; /// /// Whether this module should be treated as an engine module (eg. using engine definitions, PCHs, compiled with optimizations enabled in DebugGame configurations, etc...). /// Initialized to a default based on the rules assembly it was created from. /// public bool bTreatAsEngineModule; /// /// Which engine version's build settings to use by default. /// public BuildSettingsVersion DefaultBuildSettings { get { return DefaultBuildSettingsPrivate ?? Target.DefaultBuildSettings; } set { DefaultBuildSettingsPrivate = value; } } private BuildSettingsVersion? DefaultBuildSettingsPrivate; /// /// Whether to use backwards compatible defaults for this module. By default, engine modules always use the latest default settings, while project modules do not (to support /// an easier migration path). /// [Obsolete("Set DefaultBuildSettings to the appropriate engine version instead")] public bool bUseBackwardsCompatibleDefaults { get { return DefaultBuildSettings != BuildSettingsVersion.Latest; } set { DefaultBuildSettings = bUseBackwardsCompatibleDefaults ? BuildSettingsVersion.V1 : BuildSettingsVersion.Latest; } } /// /// Use run time type information /// public bool bUseRTTI = false; /// /// Direct the compiler to generate AVX instructions wherever SSE or AVX intrinsics are used, on the platforms that support it. /// Note that by enabling this you are changing the minspec for the PC platform, and the resultant executable will crash on machines without AVX support. /// public bool bUseAVX = false; /// /// Enable buffer security checks. This should usually be enabled as it prevents severe security risks. /// public bool bEnableBufferSecurityChecks = true; /// /// Enable exception handling /// public bool bEnableExceptions = false; /// /// Enable objective C exception handling /// public bool bEnableObjCExceptions = false; /// /// How to treat shadow variable warnings /// public WarningLevel ShadowVariableWarningLevel { get { return ShadowVariableWarningLevelPrivate ?? ((DefaultBuildSettings >= BuildSettingsVersion.V2) ? WarningLevel.Error : Target.ShadowVariableWarningLevel); } set { ShadowVariableWarningLevelPrivate = value; } } private WarningLevel? ShadowVariableWarningLevelPrivate; /// /// Enable warnings for shadowed variables /// [Obsolete("The bEnableShadowVariableWarnings setting is deprecated in UE 4.24. Please use ShadowVariableWarningLevel = WarningLevel.Warning/Off; instead.")] public bool bEnableShadowVariableWarnings { get { return ShadowVariableWarningLevel >= WarningLevel.Warning; } set { ShadowVariableWarningLevel = (value ? WarningLevel.Warning : WarningLevel.Off); } } /// /// How to treat unsafe implicit type cast warnings (e.g., double->float or int64->int32) /// public WarningLevel UnsafeTypeCastWarningLevel { get { return UnsafeTypeCastWarningLevelPrivate ?? Target.UnsafeTypeCastWarningLevel; } set { UnsafeTypeCastWarningLevelPrivate = value; } } private WarningLevel? UnsafeTypeCastWarningLevelPrivate; /// /// Enable warnings for using undefined identifiers in #if expressions /// public bool bEnableUndefinedIdentifierWarnings = true; /// /// If true and unity builds are enabled, this module will build without unity. /// [Obsolete("bFasterWithoutUnity has been deprecated in favor of setting 'bUseUnity' on a per module basis in BuildConfiguration")] public bool bFasterWithoutUnity { set { bUseUnity = !value; } } private bool? bUseUnityOverride; /// /// If unity builds are enabled this can be used to override if this specific module will build using Unity. /// This is set using the per module configurations in BuildConfiguration. /// public bool bUseUnity { set { bUseUnityOverride = value; } get { bool UseUnity = true; if (Target.DisableUnityBuildForModules?.Contains(Name) ?? false) UseUnity = false; return bUseUnityOverride ?? UseUnity; } } /// /// The number of source files in this module before unity build will be activated for that module. If set to /// anything besides -1, will override the default setting which is controlled by MinGameModuleSourceFilesForUnityBuild /// public int MinSourceFilesForUnityBuildOverride = 0; /// /// Overrides BuildConfiguration.MinFilesUsingPrecompiledHeader if non-zero. /// public int MinFilesUsingPrecompiledHeaderOverride = 0; /// /// Module uses a #import so must be built locally when compiling with SN-DBS /// public bool bBuildLocallyWithSNDBS = false; /// /// Redistribution override flag for this module. /// public bool? IsRedistributableOverride = null; /// /// Whether the output from this module can be publicly distributed, even if it has code/ /// dependencies on modules that are not (i.e. CarefullyRedist, NotForLicensees, NoRedist). /// This should be used when you plan to release binaries but not source. /// public bool bLegalToDistributeObjectCode = false; /// /// Obsolete. Use bLegalToDistributeObjectCode instead. /// [Obsolete("bOutputPubliclyDistributable has been deprecated in 4.24. Use bLegalToDistributeObjectCode instead.")] public bool bOutputPubliclyDistributable { get { return bLegalToDistributeObjectCode; } set { bLegalToDistributeObjectCode = value; } } /// /// List of folders which are whitelisted to be referenced when compiling this binary, without propagating restricted folder names /// public List WhitelistRestrictedFolders = new List(); /// /// Set of aliased restricted folder references /// public Dictionary AliasRestrictedFolders = new Dictionary(); /// /// Enforce "include what you use" rules when PCHUsage is set to ExplicitOrSharedPCH; warns when monolithic headers (Engine.h, UnrealEd.h, etc...) /// are used, and checks that source files include their matching header first. /// public bool bEnforceIWYU = true; /// /// Whether to add all the default include paths to the module (eg. the Source/Classes folder, subfolders under Source/Public). /// public bool bAddDefaultIncludePaths = true; /// /// Whether to ignore dangling (i.e. unresolved external) symbols in modules /// public bool bIgnoreUnresolvedSymbols = false; /// /// Whether this module should be precompiled. Defaults to the bPrecompile flag from the target. Clear this flag to prevent a module being precompiled. /// public bool bPrecompile; /// /// Whether this module should use precompiled data. Always true for modules created from installed assemblies. /// public bool bUsePrecompiled; /// /// Whether this module can use PLATFORM_XXXX style defines, where XXXX is a confidential platform name. This is used to ensure engine or other /// shared code does not reveal confidential information inside an #if PLATFORM_XXXX block. Licensee game code may want to allow for them, however. /// Note: this is future looking, and previous confidential platforms (like PS4) are unlikely to be restricted /// public bool bAllowConfidentialPlatformDefines = false; /// /// List of modules names (no path needed) with header files that our module's public headers needs access to, but we don't need to "import" or link against. /// public List PublicIncludePathModuleNames = new List(); /// /// List of public dependency module names (no path needed) (automatically does the private/public include). These are modules that are required by our public source files. /// public List PublicDependencyModuleNames = new List(); /// /// List of modules name (no path needed) with header files that our module's private code files needs access to, but we don't need to "import" or link against. /// public List PrivateIncludePathModuleNames = new List(); /// /// List of private dependency module names. These are modules that our private code depends on but nothing in our public /// include files depend on. /// public List PrivateDependencyModuleNames = new List(); /// /// Only for legacy reason, should not be used in new code. List of module dependencies that should be treated as circular references. This modules must have already been added to /// either the public or private dependent module list. /// public List CircularlyReferencedDependentModules = new List(); /// /// List of system/library include paths - typically used for External (third party) modules. These are public stable header file directories that are not checked when resolving header dependencies. /// public List PublicSystemIncludePaths = new List(); /// /// (This setting is currently not need as we discover all files from the 'Public' folder) List of all paths to include files that are exposed to other modules /// public List PublicIncludePaths = new List(); /// /// List of all paths to this module's internal include files, not exposed to other modules (at least one include to the 'Private' path, more if we want to avoid relative paths) /// public List PrivateIncludePaths = new List(); /// /// List of system/library paths (directory of .lib files) - typically used for External (third party) modules /// [Obsolete( "For external libraries use the full path in PublicAdditionalLibraries, if its a system library then use PublicSystemLibraries/PublicSystemLibraryPaths")] public List PublicLibraryPaths => PublicSystemLibraryPaths; /// /// List of system library paths (directory of .lib files) - for External (third party) modules please use the PublicAdditionalLibaries instead /// public List PublicSystemLibraryPaths = new List(); /// /// List of search paths for libraries at runtime (eg. .so files) /// public List PrivateRuntimeLibraryPaths = new List(); /// /// List of search paths for libraries at runtime (eg. .so files) /// public List PublicRuntimeLibraryPaths = new List(); /// /// List of additional libraries (names of the .lib files including extension) - typically used for External (third party) modules /// public List PublicAdditionalLibraries = new List(); /// /// List of additional pre-build libraries (names of the .lib files including extension) - typically used for additional targets which are still built, but using either TargetRules.PreBuildSteps or TargetRules.PreBuildTargets. /// public List PublicPreBuildLibraries = new List(); /// /// List of system libraries to use - these are typically referenced via name and then found via the system paths. If you need to reference a .lib file use the PublicAdditionalLibraries instead /// public List PublicSystemLibraries = new List(); /// /// List of XCode frameworks (iOS and MacOS) /// public List PublicFrameworks = new List(); /// /// List of weak frameworks (for OS version transitions) /// public List PublicWeakFrameworks = new List(); /// /// List of addition frameworks - typically used for External (third party) modules on Mac and iOS /// public List PublicAdditionalFrameworks = new List(); /// /// List of addition resources that should be copied to the app bundle for Mac or iOS /// public List AdditionalBundleResources = new List(); /// /// List of type libraries that we need to generate headers for (Windows only) /// public List TypeLibraries = new List(); /// /// For builds that execute on a remote machine (e.g. iOS), this list contains additional files that /// need to be copied over in order for the app to link successfully. Source/header files and PCHs are /// automatically copied. Usually this is simply a list of precompiled third party library dependencies. /// [Obsolete("To specify files to be transferred to a remote Mac for compilation, create a [Project]/Build/Rsync/RsyncProject.txt file. See https://linux.die.net/man/1/rsync for more information about Rsync filter rules.")] public List PublicAdditionalShadowFiles = new List(); /// /// List of delay load DLLs - typically used for External (third party) modules /// public List PublicDelayLoadDLLs = new List(); /// /// Accessor for the PublicDefinitions list /// [Obsolete("The 'Definitions' property has been deprecated. Please use 'PublicDefinitions' instead.")] public List Definitions { get { return PublicDefinitions; } } /// /// Private compiler definitions for this module /// public List PrivateDefinitions = new List(); /// /// Public compiler definitions for this module /// public List PublicDefinitions = new List(); /// /// Append (or create) /// /// /// public void AppendStringToPublicDefinition(string Definition, string Text) { string WithEquals = Definition + "="; for (int Index = 0; Index < PublicDefinitions.Count; Index++) { if (PublicDefinitions[Index].StartsWith(WithEquals)) { PublicDefinitions[Index] = PublicDefinitions[Index] + Text; return; } } // if we get here, we need to make a new entry PublicDefinitions.Add(Definition + "=" + Text); } /// /// Addition modules this module may require at run-time /// public List DynamicallyLoadedModuleNames = new List(); /// /// Extra modules this module may require at run time, that are on behalf of another platform (i.e. shader formats and the like) /// [Obsolete("PlatformSpecificDynamicallyLoadedModuleNames is deprecated; use DynamicallyLoadedModuleNames instead")] public List PlatformSpecificDynamicallyLoadedModuleNames { get { return DynamicallyLoadedModuleNames; } } /// /// List of files which this module depends on at runtime. These files will be staged along with the target. /// public RuntimeDependencyList RuntimeDependencies = new RuntimeDependencyList(); /// /// List of additional properties to be added to the build receipt /// public ReceiptPropertyList AdditionalPropertiesForReceipt = new ReceiptPropertyList(); /// /// Which targets this module should be precompiled for /// public PrecompileTargetsType PrecompileForTargets = PrecompileTargetsType.Default; /// /// External files which invalidate the makefile if modified. Relative paths are resolved relative to the .build.cs file. /// public List ExternalDependencies = new List(); /// /// External directories containing generated interop files. /// public List AdditionalCodeGenDirectories = new List(); /// /// Subclass rules files which invalidate the makefile if modified. /// public List? SubclassRules; /// /// Whether this module requires the IMPLEMENT_MODULE macro to be implemented. Most UE4 modules require this, since we use the IMPLEMENT_MODULE macro /// to do other global overloads (eg. operator new/delete forwarding to GMalloc). /// public bool? bRequiresImplementModule; /// /// Whether this module qualifies included headers from other modules relative to the root of their 'Public' folder. This reduces the number /// of search paths that have to be passed to the compiler, improving performance and reducing the length of the compiler command line. /// public bool bLegacyPublicIncludePaths { set { bLegacyPublicIncludePathsPrivate = value; } get { return bLegacyPublicIncludePathsPrivate ?? ((DefaultBuildSettings < BuildSettingsVersion.V2) ? Target.bLegacyPublicIncludePaths : false); } } private bool? bLegacyPublicIncludePathsPrivate; /// /// Which stanard to use for compiling this module /// public CppStandardVersion CppStandard = CppStandardVersion.Default; /// /// Control visibility of symbols /// public SymbolVisibility ModuleSymbolVisibility = ModuleRules.SymbolVisibility.Default; /// /// The AutoSDK directory for the active host platform /// public string? AutoSdkDirectory { get { DirectoryReference? AutoSdkDir; return UEBuildPlatformSDK.TryGetHostPlatformAutoSDKDir(out AutoSdkDir) ? AutoSdkDir.FullName : null; } } /// /// The current engine directory /// public string EngineDirectory { get { return UnrealBuildTool.EngineDirectory.FullName; } } /// /// Property for the directory containing this plugin. Useful for adding paths to third party dependencies. /// public string PluginDirectory { get { if (Plugin == null) { throw new BuildException("Module '{0}' does not belong to a plugin; PluginDirectory property is invalid.", Name); } else { return Plugin.Directory.FullName; } } } /// /// Property for the directory containing this module. Useful for adding paths to third party dependencies. /// public string ModuleDirectory { get { return Directory.FullName; } } #nullable disable /// /// Constructor. For backwards compatibility while the parameterless constructor is being phased out, initialization which would happen here is done by /// RulesAssembly.CreateModulRules instead. /// /// Rules for building this target public ModuleRules(ReadOnlyTargetRules Target) { this.Target = Target; } #nullable restore /// /// Add the given Engine ThirdParty modules as static private dependencies /// Statically linked to this module, meaning they utilize exports from the other module /// Private, meaning the include paths for the included modules will not be exposed when giving this modules include paths /// NOTE: There is no AddThirdPartyPublicStaticDependencies function. /// /// The target this module belongs to /// The names of the modules to add public void AddEngineThirdPartyPrivateStaticDependencies(ReadOnlyTargetRules Target, params string[] ModuleNames) { if (!bUsePrecompiled || Target.LinkType == TargetLinkType.Monolithic) { PrivateDependencyModuleNames.AddRange(ModuleNames); } } /// /// Add the given Engine ThirdParty modules as dynamic private dependencies /// Dynamically linked to this module, meaning they do not utilize exports from the other module /// Private, meaning the include paths for the included modules will not be exposed when giving this modules include paths /// NOTE: There is no AddThirdPartyPublicDynamicDependencies function. /// /// Rules for the target being built /// The names of the modules to add public void AddEngineThirdPartyPrivateDynamicDependencies(ReadOnlyTargetRules Target, params string[] ModuleNames) { if (!bUsePrecompiled || Target.LinkType == TargetLinkType.Monolithic) { PrivateIncludePathModuleNames.AddRange(ModuleNames); DynamicallyLoadedModuleNames.AddRange(ModuleNames); } } /// /// Setup this module for physics support (based on the settings in UEBuildConfiguration) /// public void EnableMeshEditorSupport(ReadOnlyTargetRules Target) { if (Target.bEnableMeshEditor == true) { PublicDefinitions.Add("ENABLE_MESH_EDITOR=1"); } else { PublicDefinitions.Add("ENABLE_MESH_EDITOR=0"); } } /// /// Setup this module for physics support (based on the settings in UEBuildConfiguration) /// public void SetupModulePhysicsSupport(ReadOnlyTargetRules Target) { PublicDependencyModuleNames.Add("PhysicsCore"); bool bUseNonPhysXInterface = Target.bUseChaos == true; PublicDependencyModuleNames.AddRange( new string[] { "Chaos", } ); // if (Target.bCompileChaos == true || Target.bUseChaos == true) { PublicDefinitions.Add("INCLUDE_CHAOS=1"); } else { PublicDefinitions.Add("INCLUDE_CHAOS=0"); } // 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 && Target.bCompileChaos == false && Target.bUseChaos == false) { PrivateDependencyModuleNames.Add("PhysX"); } if(Target.bCompileChaos || Target.bUseChaos || Target.bCompilePhysX) { PublicDefinitions.Add("WITH_PHYSX=1"); } else { PublicDefinitions.Add("WITH_PHYSX=0"); } if(!bUseNonPhysXInterface) { // Disable non-physx interfaces PublicDefinitions.Add("WITH_CHAOS=0"); PublicDefinitions.Add("WITH_CHAOS_CLOTHING=0"); // // WITH_CHAOS_NEEDS_TO_BE_FIXED // // Anything wrapped in this define needs to be fixed // in one of the build targets. This define was added // to help identify complier failures between the // the three build targets( UseChaos, PhysX, WithChaos ) // This defaults to off , and will be enabled for bUseChaos. // This define should be removed when all the references // have been fixed across the different builds. // PublicDefinitions.Add("WITH_CHAOS_NEEDS_TO_BE_FIXED=0"); if (Target.bCompilePhysX) { PublicDefinitions.Add("PHYSICS_INTERFACE_PHYSX=1"); } else { PublicDefinitions.Add("PHYSICS_INTERFACE_PHYSX=0"); } if (Target.bCompileAPEX == true) { if (!Target.bCompilePhysX) { throw new BuildException("APEX is enabled, without PhysX. This is not supported!"); } PrivateDependencyModuleNames.Add("APEX"); PublicDefinitions.Add("WITH_APEX=1"); // @MIXEDREALITY_CHANGE : BEGIN - Do not use Apex Cloth for HoloLens. TODO: can we enable this in the future? if (Target.Platform == UnrealTargetPlatform.HoloLens) { PublicDefinitions.Add("WITH_APEX_CLOTHING=0"); PublicDefinitions.Add("WITH_CLOTH_COLLISION_DETECTION=0"); } else { PublicDefinitions.Add("WITH_APEX_CLOTHING=1"); PublicDefinitions.Add("WITH_CLOTH_COLLISION_DETECTION=1"); } // @MIXEDREALITY_CHANGE : END 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 } if (Target.bCompileNvCloth == true) { if (!Target.bCompilePhysX) { throw new BuildException("NvCloth is enabled, without PhysX. This is not supported!"); } PrivateDependencyModuleNames.Add("NvCloth"); PublicDefinitions.Add("WITH_NVCLOTH=1"); } else { PublicDefinitions.Add("WITH_NVCLOTH=0"); } } else { // Disable apex/cloth/physx interface PublicDefinitions.Add("PHYSICS_INTERFACE_PHYSX=0"); PublicDefinitions.Add("WITH_APEX=0"); PublicDefinitions.Add("WITH_APEX_CLOTHING=0"); PublicDefinitions.Add(string.Format("WITH_PHYSX_COOKING={0}", Target.bBuildEditor && Target.bCompilePhysX ? 1 : 0)); // without APEX, we only need cooking in editor builds PublicDefinitions.Add("WITH_NVCLOTH=0"); if(Target.bUseChaos) { PublicDefinitions.Add("WITH_CHAOS=1"); PublicDefinitions.Add("WITH_CHAOS_NEEDS_TO_BE_FIXED=1"); PublicDefinitions.Add("WITH_CHAOS_CLOTHING=1"); PublicDefinitions.Add("WITH_CLOTH_COLLISION_DETECTION=1"); PublicIncludePathModuleNames.AddRange( new string[] { "Chaos", } ); PublicDependencyModuleNames.AddRange( new string[] { "Chaos", } ); } else { PublicDefinitions.Add("WITH_CHAOS=0"); PublicDefinitions.Add("WITH_CHAOS_NEEDS_TO_BE_FIXED=0"); PublicDefinitions.Add("WITH_CHAOS_CLOTHING=0"); PublicDefinitions.Add("WITH_CLOTH_COLLISION_DETECTION=0"); } } if(Target.bCustomSceneQueryStructure) { PublicDefinitions.Add("WITH_CUSTOM_SQ_STRUCTURE=1"); } else { PublicDefinitions.Add("WITH_CUSTOM_SQ_STRUCTURE=0"); } // Unused interface PublicDefinitions.Add("WITH_IMMEDIATE_PHYSX=0"); } /// /// Determines if this module can be precompiled for the current target. /// /// Path to the module rules file /// True if the module can be precompiled, false otherwise internal bool IsValidForTarget(FileReference RulesFile) { if(Type == ModuleRules.ModuleType.CPlusPlus) { switch (PrecompileForTargets) { case ModuleRules.PrecompileTargetsType.None: return false; case ModuleRules.PrecompileTargetsType.Default: return (Target.Type == TargetType.Editor || !UnrealBuildTool.GetExtensionDirs(UnrealBuildTool.EngineDirectory, "Source/Developer").Any(Dir => RulesFile.IsUnderDirectory(Dir)) || Plugin != null); case ModuleRules.PrecompileTargetsType.Game: return (Target.Type == TargetType.Client || Target.Type == TargetType.Server || Target.Type == TargetType.Game); case ModuleRules.PrecompileTargetsType.Editor: return (Target.Type == TargetType.Editor); case ModuleRules.PrecompileTargetsType.Any: return true; } } return false; } /// /// Returns the module directory for a given subclass of the module (platform extensions add subclasses of ModuleRules to add in platform-specific settings) /// /// typeof the subclass /// Directory where the subclass's .Build.cs lives, or null if not found public DirectoryReference? GetModuleDirectoryForSubClass(Type Type) { if (DirectoriesForModuleSubClasses == null) { return null; } DirectoryReference? Directory; if (DirectoriesForModuleSubClasses.TryGetValue(Type, out Directory)) { return Directory; } return null; } /// /// Returns the directories for all subclasses of this module, as well as any additional directories specified by the rules /// /// List of directories, or null if none were added public DirectoryReference[] GetAllModuleDirectories() { List AllDirectories = new List { Directory }; AllDirectories.AddRange(AdditionalModuleDirectories); if (DirectoriesForModuleSubClasses != null) { AllDirectories.AddRange(DirectoriesForModuleSubClasses.Values); } return AllDirectories.ToArray(); } /// /// Adds an additional module directory, if it exists (useful for NotForLicensees/NoRedist) /// /// /// true if the directory exists protected bool ConditionalAddModuleDirectory(DirectoryReference Directory) { if (DirectoryReference.Exists(Directory)) { AdditionalModuleDirectories.Add(Directory); return true; } return false; } } }