// Copyright Epic Games, Inc. All Rights Reserved. using System; using System.Collections.Generic; using System.Diagnostics; using System.Text; using System.Text.RegularExpressions; using System.IO; using EpicGames.Core; using UnrealBuildBase; namespace UnrealBuildTool { /// /// Compiler configuration. This controls whether to use define debug macros and other compiler settings. Note that optimization level should be based on the bOptimizeCode variable rather than /// this setting, so it can be modified on a per-module basis without introducing an incompatibility between object files or PCHs. /// enum CppConfiguration { Debug, Development, Shipping } /// /// Specifies which language standard to use. This enum should be kept in order, so that toolchains can check whether the requested setting is >= values that they support. /// public enum CppStandardVersion { /// /// Supports C++14 /// Cpp14, /// /// Supports C++17 /// Cpp17, /// /// Supports C++20 /// Cpp20, /// /// Latest standard supported by the compiler /// Latest, /// /// Use the default standard version /// Default = Cpp17, } /// /// The optimization level that may be compilation targets for C# files. /// enum CSharpTargetConfiguration { Debug, Development, } /// /// The possible interactions between a precompiled header and a C++ file being compiled. /// enum PrecompiledHeaderAction { None, Include, Create } /// /// Encapsulates the compilation output of compiling a set of C++ files. /// class CPPOutput { public List ObjectFiles = new List(); public List CompiledModuleInterfaces = new List(); public List GeneratedHeaderFiles = new List(); public FileItem? PrecompiledHeaderFile = null; } /// /// Encapsulates the environment that a C++ file is compiled in. /// class CppCompileEnvironment { /// /// The platform to be compiled/linked for. /// public readonly UnrealTargetPlatform Platform; /// /// The configuration to be compiled/linked for. /// public readonly CppConfiguration Configuration; /// /// The architecture that is being compiled/linked (empty string by default) /// public readonly string Architecture; /// /// Cache of source file metadata /// public readonly SourceFileMetadataCache MetadataCache; /// /// Templates for shared precompiled headers /// public readonly List SharedPCHs; /// /// The name of the header file which is precompiled. /// public FileReference? PrecompiledHeaderIncludeFilename = null; /// /// Whether the compilation should create, use, or do nothing with the precompiled header. /// public PrecompiledHeaderAction PrecompiledHeaderAction = PrecompiledHeaderAction.None; /// /// Whether artifacts from this compile are shared with other targets. If so, we should not apply any target-wide modifications to the compile environment. /// public bool bUseSharedBuildEnvironment; /// /// Use run time type information /// public bool bUseRTTI = false; /// /// Enable inlining. /// public bool bUseInlining = false; /// /// Whether to compile ISPC files. /// public bool bCompileISPC = false; /// /// Direct the compiler to generate AVX instructions wherever SSE or AVX intrinsics are used. /// 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; /// /// 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 = false; /// /// 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; /// /// The minimum number of files that must use a pre-compiled header before it will be created and used. /// public int MinFilesUsingPrecompiledHeaderOverride = 0; /// /// Module uses a #import so must be built locally when compiling with SN-DBS /// public bool bBuildLocallyWithSNDBS = false; /// /// Whether to retain frame pointers /// public bool bRetainFramePointers = true; /// /// Enable exception handling /// public bool bEnableExceptions = false; /// /// Enable objective C exception handling /// public bool bEnableObjCExceptions = false; /// /// How to treat any warnings in the code /// public WarningLevel DefaultWarningLevel = WarningLevel.Warning; /// /// Whether to warn about deprecated variables /// public WarningLevel DeprecationWarningLevel = WarningLevel.Warning; /// /// Whether to warn about the use of shadow variables /// public WarningLevel ShadowVariableWarningLevel = WarningLevel.Warning; /// /// How to treat unsafe implicit type cast warnings (e.g., double->float or int64->int32) /// public WarningLevel UnsafeTypeCastWarningLevel = WarningLevel.Off; /// /// Whether to warn about the use of undefined identifiers in #if expressions /// public bool bEnableUndefinedIdentifierWarnings = true; /// /// Whether to treat undefined identifier warnings as errors. /// public bool bUndefinedIdentifierWarningsAsErrors = false; /// /// Whether to treat all warnings as errors /// public bool bWarningsAsErrors = false; /// /// True if compiler optimizations should be enabled. This setting is distinct from the configuration (see CPPTargetConfiguration). /// public bool bOptimizeCode = false; /// /// Whether to optimize for minimal code size /// public bool bOptimizeForSize = false; /// /// True if debug info should be created. /// public bool bCreateDebugInfo = true; /// /// True if we're compiling .cpp files that will go into a library (.lib file) /// public bool bIsBuildingLibrary = false; /// /// True if we're compiling a DLL /// public bool bIsBuildingDLL = false; /// /// Whether we should compile using the statically-linked CRT. This is not widely supported for the whole engine, but is required for programs that need to run without dependencies. /// public bool bUseStaticCRT = false; /// /// Whether to use the debug CRT in debug configurations /// public bool bUseDebugCRT = false; /// /// Whether to omit frame pointers or not. Disabling is useful for e.g. memory profiling on the PC /// public bool bOmitFramePointers = true; /// /// Whether we should compile with support for OS X 10.9 Mavericks. Used for some tools that we need to be compatible with this version of OS X. /// public bool bEnableOSX109Support = false; /// /// Whether PDB files should be used for Visual C++ builds. /// public bool bUsePDBFiles = false; /// /// Whether to just preprocess source files /// public bool bPreprocessOnly = false; /// /// Whether to support edit and continue. Only works on Microsoft compilers in 32-bit compiles. /// public bool bSupportEditAndContinue; /// /// Whether to use incremental linking or not. /// public bool bUseIncrementalLinking; /// /// Whether to allow the use of LTCG (link time code generation) /// public bool bAllowLTCG; /// /// Whether to enable Profile Guided Optimization (PGO) instrumentation in this build. /// public bool bPGOProfile; /// /// Whether to optimize this build with Profile Guided Optimization (PGO). /// public bool bPGOOptimize; /// /// Platform specific directory where PGO profiling data is stored. /// public string? PGODirectory; /// /// Platform specific filename where PGO profiling data is saved. /// public string? PGOFilenamePrefix; /// /// Whether to log detailed timing info from the compiler /// public bool bPrintTimingInfo; /// /// Whether to output a dependencies file along with the output build products /// public bool bGenerateDependenciesFile = true; /// /// When enabled, allows XGE to compile pre-compiled header files on remote machines. Otherwise, PCHs are always generated locally. /// public bool bAllowRemotelyCompiledPCHs = false; /// /// Ordered list of include paths for the module /// public HashSet UserIncludePaths; /// /// The include paths where changes to contained files won't cause dependent C++ source files to /// be recompiled, unless BuildConfiguration.bCheckSystemHeadersForModification==true. /// public HashSet SystemIncludePaths; /// /// List of paths to search for compiled module interface (*.ifc) files /// public HashSet ModuleInterfacePaths; /// /// Whether headers in system paths should be checked for modification when determining outdated actions. /// public bool bCheckSystemHeadersForModification; /// /// List of header files to force include /// public List ForceIncludeFiles = new List(); /// /// List of files that need to be up to date before compile can proceed /// public List AdditionalPrerequisites = new List(); /// /// The C++ preprocessor definitions to use. /// public List Definitions = new List(); /// /// Additional arguments to pass to the compiler. /// public string AdditionalArguments = ""; /// /// A list of additional frameworks whose include paths are needed. /// public List AdditionalFrameworks = new List(); /// /// The file containing the precompiled header data. /// public FileItem? PrecompiledHeaderFile = null; /// /// Whether or not UHT is being built /// public bool bHackHeaderGenerator; /// /// Whether to hide symbols by default /// public bool bHideSymbolsByDefault = true; /// /// Which C++ standard to support. May not be compatible with all platforms. /// public CppStandardVersion CppStandard = CppStandardVersion.Default; /// /// The amount of the stack usage to report static analysis warnings. /// public int AnalyzeStackSizeWarning = 300000; /// /// Enable C++ coroutine support. /// For MSVC, adds "/await:strict" to the command line. Program should #include <coroutine> /// For Clang, adds "-fcoroutines-ts" to the command line. Program should #include <experimental/coroutine> (not supported in every clang toolchain) /// public bool bEnableCoroutines = false; /// /// What version of include order specified by the module rules. Used to determine shared PCH variants. /// public EngineIncludeOrderVersion IncludeOrderVersion = EngineIncludeOrderVersion.Latest; /// /// Directory where to put crash report files for platforms that support it /// public string? CrashDiagnosticDirectory; /// /// Default constructor. /// public CppCompileEnvironment(UnrealTargetPlatform Platform, CppConfiguration Configuration, string Architecture, SourceFileMetadataCache MetadataCache) { this.Platform = Platform; this.Configuration = Configuration; this.Architecture = Architecture; this.MetadataCache = MetadataCache; this.SharedPCHs = new List(); this.UserIncludePaths = new HashSet(); this.SystemIncludePaths = new HashSet(); this.ModuleInterfacePaths = new HashSet(); } /// /// Copy constructor. /// /// Environment to copy settings from public CppCompileEnvironment(CppCompileEnvironment Other) { Platform = Other.Platform; Configuration = Other.Configuration; Architecture = Other.Architecture; MetadataCache = Other.MetadataCache; SharedPCHs = Other.SharedPCHs; PrecompiledHeaderIncludeFilename = Other.PrecompiledHeaderIncludeFilename; PrecompiledHeaderAction = Other.PrecompiledHeaderAction; bUseSharedBuildEnvironment = Other.bUseSharedBuildEnvironment; bUseRTTI = Other.bUseRTTI; bUseInlining = Other.bUseInlining; bCompileISPC = Other.bCompileISPC; bUseAVX = Other.bUseAVX; bUseUnity = Other.bUseUnity; MinSourceFilesForUnityBuildOverride = Other.MinSourceFilesForUnityBuildOverride; MinFilesUsingPrecompiledHeaderOverride = Other.MinFilesUsingPrecompiledHeaderOverride; bBuildLocallyWithSNDBS = Other.bBuildLocallyWithSNDBS; bRetainFramePointers = Other.bRetainFramePointers; bEnableExceptions = Other.bEnableExceptions; bEnableObjCExceptions = Other.bEnableObjCExceptions; DefaultWarningLevel = Other.DefaultWarningLevel; DeprecationWarningLevel = Other.DeprecationWarningLevel; ShadowVariableWarningLevel = Other.ShadowVariableWarningLevel; UnsafeTypeCastWarningLevel = Other.UnsafeTypeCastWarningLevel; bUndefinedIdentifierWarningsAsErrors = Other.bUndefinedIdentifierWarningsAsErrors; bEnableUndefinedIdentifierWarnings = Other.bEnableUndefinedIdentifierWarnings; bWarningsAsErrors = Other.bWarningsAsErrors; bOptimizeCode = Other.bOptimizeCode; bOptimizeForSize = Other.bOptimizeForSize; bCreateDebugInfo = Other.bCreateDebugInfo; bIsBuildingLibrary = Other.bIsBuildingLibrary; bIsBuildingDLL = Other.bIsBuildingDLL; bUseStaticCRT = Other.bUseStaticCRT; bUseDebugCRT = Other.bUseDebugCRT; bOmitFramePointers = Other.bOmitFramePointers; bEnableOSX109Support = Other.bEnableOSX109Support; bUsePDBFiles = Other.bUsePDBFiles; bPreprocessOnly = Other.bPreprocessOnly; bSupportEditAndContinue = Other.bSupportEditAndContinue; bUseIncrementalLinking = Other.bUseIncrementalLinking; bAllowLTCG = Other.bAllowLTCG; bPGOOptimize = Other.bPGOOptimize; bPGOProfile = Other.bPGOProfile; PGOFilenamePrefix = Other.PGOFilenamePrefix; PGODirectory = Other.PGODirectory; bPrintTimingInfo = Other.bPrintTimingInfo; bGenerateDependenciesFile = Other.bGenerateDependenciesFile; bAllowRemotelyCompiledPCHs = Other.bAllowRemotelyCompiledPCHs; UserIncludePaths = new HashSet(Other.UserIncludePaths); SystemIncludePaths = new HashSet(Other.SystemIncludePaths); ModuleInterfacePaths = new HashSet(Other.ModuleInterfacePaths); bCheckSystemHeadersForModification = Other.bCheckSystemHeadersForModification; ForceIncludeFiles.AddRange(Other.ForceIncludeFiles); AdditionalPrerequisites.AddRange(Other.AdditionalPrerequisites); Definitions.AddRange(Other.Definitions); AdditionalArguments = Other.AdditionalArguments; AdditionalFrameworks.AddRange(Other.AdditionalFrameworks); PrecompiledHeaderFile = Other.PrecompiledHeaderFile; bHackHeaderGenerator = Other.bHackHeaderGenerator; bHideSymbolsByDefault = Other.bHideSymbolsByDefault; CppStandard = Other.CppStandard; bEnableCoroutines = Other.bEnableCoroutines; IncludeOrderVersion = Other.IncludeOrderVersion; CrashDiagnosticDirectory = Other.CrashDiagnosticDirectory; } } }