// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace UnrealBuildTool
{
///
/// Encapsulates the environment that is used to link object files.
///
class LinkEnvironment
{
///
/// The platform to be compiled/linked for.
///
public readonly CppPlatform 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;
///
/// The directory to put the non-executable files in (PDBs, import library, etc)
///
public DirectoryReference OutputDirectory;
///
/// Intermediate file directory
///
public DirectoryReference IntermediateDirectory;
///
/// The directory to shadow source files in for syncing to remote compile servers
///
public DirectoryReference LocalShadowDirectory = null;
///
/// The file path for the executable file that is output by the linker.
///
public List OutputFilePaths = new List();
///
/// Returns the OutputFilePath is there is only one entry in OutputFilePaths
///
public FileReference OutputFilePath
{
get
{
if (OutputFilePaths.Count != 1)
{
throw new BuildException("Attempted to use LinkEnvironmentConfiguration.OutputFilePath property, but there are multiple (or no) OutputFilePaths. You need to handle multiple in the code that called this (size = {0})", OutputFilePaths.Count);
}
return OutputFilePaths[0];
}
}
///
/// The project file for this target
///
public FileReference ProjectFile = null;
///
/// A list of the paths used to find libraries.
///
public List LibraryPaths = new List();
///
/// A list of libraries to exclude from linking.
///
public List ExcludedLibraries = new List();
///
/// A list of additional libraries to link in.
///
public List AdditionalLibraries = new List();
///
/// A list of additional frameworks to link in.
///
public List AdditionalFrameworks = new List();
///
/// For builds that execute on a remote machine (e.g. iPhone), 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.
///
public List AdditionalShadowFiles = new List();
///
/// The iOS/Mac frameworks to link in
///
public List Frameworks = new List();
public List WeakFrameworks = new List();
///
/// iOS/Mac resources that should be copied to the app bundle
///
public List AdditionalBundleResources = new List();
///
/// A list of the dynamically linked libraries that shouldn't be loaded until they are first called
/// into.
///
public List DelayLoadDLLs = new List();
///
/// Additional arguments to pass to the linker.
///
public string AdditionalArguments = "";
///
/// True if debug info should be created.
///
public bool bCreateDebugInfo = true;
///
/// True if debug symbols that are cached for some platforms should not be created.
///
public bool bDisableSymbolCache = 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;
///
/// True if this is a console application that's being build
///
public bool bIsBuildingConsoleApplication = false;
///
/// This setting is replaced by UEBuildBinaryConfiguration.bBuildAdditionalConsoleApp.
///
[Obsolete("This setting is replaced by UEBuildBinaryConfiguration.bBuildAdditionalConsoleApp. It is explicitly set to true for editor targets, and defaults to false otherwise.")]
public bool bBuildAdditionalConsoleApplication { set { } }
///
/// If set, overrides the program entry function on Windows platform. This is used by the base UE4
/// program so we can link in either command-line mode or windowed mode without having to recompile the Launch module.
///
public string WindowsEntryPointOverride = String.Empty;
///
/// True if we're building a EXE/DLL target with an import library, and that library is needed by a dependency that
/// we're directly dependent on.
///
public bool bIsCrossReferenced = false;
///
/// True if we should include dependent libraries when building a static library
///
public bool bIncludeDependentLibrariesInLibrary = false;
///
/// True if the application we're linking has any exports, and we should be expecting the linker to
/// generate a .lib and/or .exp file along with the target output file
///
public bool bHasExports = true;
///
/// True if we're building a .NET assembly (e.g. C# project)
///
public bool bIsBuildingDotNetAssembly = false;
///
/// The default stack memory size allocation
///
public int DefaultStackSize = 5000000;
///
/// The amount of the default stack size to commit initially. Set to 0 to allow the OS to decide.
///
public int DefaultStackSizeCommit = 0;
///
/// Whether to optimize for minimal code size
///
public bool bOptimizeForSize = false;
///
/// Whether to omit frame pointers or not. Disabling is useful for e.g. memory profiling on the PC
///
public bool bOmitFramePointers = true;
///
/// 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 request the linker create a map file as part of the build
///
public bool bCreateMapFile;
///
/// Whether to allow the use of ASLR (address space layout randomization) if supported.
///
public bool bAllowALSR;
///
/// Whether PDB files should be used for Visual C++ builds.
///
public bool bUsePDBFiles;
///
/// Whether to use the :FASTLINK option when building with /DEBUG to create local PDBs
///
public bool bUseFastPDBLinking;
///
/// Whether to log detailed timing information
///
public bool bPrintTimingInfo;
///
/// Bundle version for Mac apps
///
public string BundleVersion;
///
/// Whether we're linking in monolithic mode. Determines if linking should produce import library file. Relevant only for VC++, clang stores imports in shared library.
///
public bool bShouldCompileMonolithic = false;
///
/// A list of the object files to be linked.
///
public List InputFiles = new List();
///
/// A list of dependent static or import libraries that need to be linked.
///
public List InputLibraries = new List();
///
/// The default resource file to link in to every binary if a custom one is not provided
///
public List DefaultResourceFiles = new List();
///
/// Resource files which should be compiled into every binary
///
public List CommonResourceFiles = new List();
///
/// Default constructor.
///
public LinkEnvironment(CppPlatform Platform, CppConfiguration Configuration, string Architecture)
{
this.Platform = Platform;
this.Configuration = Configuration;
this.Architecture = Architecture;
}
///
/// Copy constructor.
///
public LinkEnvironment(LinkEnvironment Other)
{
Platform = Other.Platform;
Configuration = Other.Configuration;
Architecture = Other.Architecture;
OutputDirectory = Other.OutputDirectory;
IntermediateDirectory = Other.IntermediateDirectory;
LocalShadowDirectory = Other.LocalShadowDirectory;
OutputFilePaths = Other.OutputFilePaths.ToList();
ProjectFile = Other.ProjectFile;
LibraryPaths.AddRange(Other.LibraryPaths);
ExcludedLibraries.AddRange(Other.ExcludedLibraries);
AdditionalLibraries.AddRange(Other.AdditionalLibraries);
Frameworks.AddRange(Other.Frameworks);
AdditionalShadowFiles.AddRange(Other.AdditionalShadowFiles);
AdditionalFrameworks.AddRange(Other.AdditionalFrameworks);
WeakFrameworks.AddRange(Other.WeakFrameworks);
AdditionalBundleResources.AddRange(Other.AdditionalBundleResources);
DelayLoadDLLs.AddRange(Other.DelayLoadDLLs);
AdditionalArguments = Other.AdditionalArguments;
bCreateDebugInfo = Other.bCreateDebugInfo;
bIsBuildingLibrary = Other.bIsBuildingLibrary;
bDisableSymbolCache = Other.bDisableSymbolCache;
bIsBuildingDLL = Other.bIsBuildingDLL;
bIsBuildingConsoleApplication = Other.bIsBuildingConsoleApplication;
WindowsEntryPointOverride = Other.WindowsEntryPointOverride;
bIsCrossReferenced = Other.bIsCrossReferenced;
bHasExports = Other.bHasExports;
bIsBuildingDotNetAssembly = Other.bIsBuildingDotNetAssembly;
bOptimizeForSize = Other.bOptimizeForSize;
bOmitFramePointers = Other.bOmitFramePointers;
bSupportEditAndContinue = Other.bSupportEditAndContinue;
bUseIncrementalLinking = Other.bUseIncrementalLinking;
bAllowLTCG = Other.bAllowLTCG;
bCreateMapFile = Other.bCreateMapFile;
bAllowALSR = Other.bAllowALSR;
bUsePDBFiles = Other.bUsePDBFiles;
bUseFastPDBLinking = Other.bUseFastPDBLinking;
bPrintTimingInfo = Other.bPrintTimingInfo;
BundleVersion = Other.BundleVersion;
InputFiles.AddRange(Other.InputFiles);
InputLibraries.AddRange(Other.InputLibraries);
DefaultResourceFiles.AddRange(Other.DefaultResourceFiles);
CommonResourceFiles.AddRange(Other.CommonResourceFiles);
}
}
}