本文整理汇总了C#中UnrealBuildTool.CPPEnvironment类的典型用法代码示例。如果您正苦于以下问题:C# CPPEnvironment类的具体用法?C# CPPEnvironment怎么用?C# CPPEnvironment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CPPEnvironment类属于UnrealBuildTool命名空间,在下文中一共展示了CPPEnvironment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDesiredOnlineSubsystem
/** Get the desired OnlineSubsystem. */
public string GetDesiredOnlineSubsystem( CPPEnvironment CPPEnv, UnrealTargetPlatform Platform )
{
string ForcedOSS = UE3BuildTarget.ForceOnlineSubsystem( Platform );
if( ForcedOSS != null )
{
return ( ForcedOSS );
}
return ( "PC" );
}
示例2: SetUpGameEnvironment
/** Allows the game to add any additional environment settings before building */
public void SetUpGameEnvironment(CPPEnvironment GameCPPEnvironment, LinkEnvironment FinalLinkEnvironment, List<UE3ProjectDesc> GameProjects)
{
GameCPPEnvironment.IncludePaths.Add("ExampleGame/Inc");
GameProjects.Add( new UE3ProjectDesc( "ExampleGame/ExampleGame.vcproj") );
if (UE3BuildConfiguration.bBuildEditor &&
(GameCPPEnvironment.TargetPlatform == CPPTargetPlatform.Win32 || GameCPPEnvironment.TargetPlatform == CPPTargetPlatform.Win64))
{
GameProjects.Add( new UE3ProjectDesc( "ExampleEditor/ExampleEditor.vcproj") );
GameCPPEnvironment.IncludePaths.Add("ExampleEditor/Inc");
}
GameCPPEnvironment.Definitions.Add("GAMENAME=EXAMPLEGAME");
GameCPPEnvironment.Definitions.Add("IS_EXAMPLEGAME=1");
FinalLinkEnvironment.AdditionalLibraries.Add("ws2_32.lib");
FinalLinkEnvironment.AdditionalLibraries.Add("../../Binaries/win32/Network.lib");
}
示例3: GetCLArguments_Global
static string GetCLArguments_Global(CPPEnvironment CompileEnvironment, string Architecture)
{
string Result = "";
switch (Architecture)
{
case "-armv7": Result += ToolchainParamsArm; break;
case "-arm64": Result += ToolchainParamsArm64; break;
case "-x86": Result += ToolchainParamsx86; break;
case "-x64": Result += ToolchainParamsx64; break;
default: Result += ToolchainParamsArm; break;
}
// build up the commandline common to C and C++
Result += " -c";
Result += " -fdiagnostics-format=msvc";
Result += " -Wall";
Result += " -Wno-unused-variable";
// this will hide the warnings about static functions in headers that aren't used in every single .cpp file
Result += " -Wno-unused-function";
// this hides the "enumeration value 'XXXXX' not handled in switch [-Wswitch]" warnings - we should maybe remove this at some point and add UE_LOG(, Fatal, ) to default cases
Result += " -Wno-switch";
// this hides the "warning : comparison of unsigned expression < 0 is always false" type warnings due to constant comparisons, which are possible with template arguments
Result += " -Wno-tautological-compare";
//This will prevent the issue of warnings for unused private variables.
Result += " -Wno-unused-private-field";
Result += " -Wno-local-type-template-args"; // engine triggers this
Result += " -Wno-return-type-c-linkage"; // needed for PhysX
Result += " -Wno-reorder"; // member initialization order
Result += " -Wno-unknown-pragmas"; // probably should kill this one, sign of another issue in PhysX?
Result += " -Wno-invalid-offsetof"; // needed to suppress warnings about using offsetof on non-POD types.
Result += " -Wno-logical-op-parentheses"; // needed for external headers we can't change
if (CompileEnvironment.Config.bEnableShadowVariableWarning)
{
Result += " -Wshadow -Wno-error=shadow";
}
// new for clang4.5 warnings:
if (ClangVersionFloat >= 3.5f)
{
Result += " -Wno-undefined-bool-conversion"; // 'this' pointer cannot be null in well-defined C++ code; pointer may be assumed to always convert to true (if (this))
}
if (ClangVersionFloat >= 3.6f)
{
Result += " -Wno-unused-local-typedef"; // clang is being overly strict here? PhysX headers trigger this.
Result += " -Wno-inconsistent-missing-override"; // these have to be suppressed for UE 4.8, should be fixed later.
}
// shipping builds will cause this warning with "ensure", so disable only in those case
if (CompileEnvironment.Config.Target.Configuration == CPPTargetConfiguration.Shipping)
{
Result += " -Wno-unused-value";
}
// debug info
if (CompileEnvironment.Config.bCreateDebugInfo)
{
Result += " -g2 -gdwarf-2";
}
// optimization level
if (CompileEnvironment.Config.Target.Configuration == CPPTargetConfiguration.Debug)
{
Result += " -O0";
}
else
{
if (UEBuildConfiguration.bCompileForSize)
{
Result += " -Oz";
}
else
{
Result += " -O3";
}
}
//@todo android: these are copied verbatim from UE3 and probably need adjustment
if (Architecture == "-armv7")
{
// Result += " -mthumb-interwork"; // Generates code which supports calling between ARM and Thumb instructions, w/o it you can't reliability use both together
Result += " -funwind-tables"; // Just generates any needed static data, affects no code
Result += " -fstack-protector"; // Emits extra code to check for buffer overflows
// Result += " -mlong-calls"; // Perform function calls by first loading the address of the function into a reg and then performing the subroutine call
Result += " -fno-strict-aliasing"; // Prevents unwanted or invalid optimizations that could produce incorrect code
Result += " -fpic"; // Generates position-independent code (PIC) suitable for use in a shared library
Result += " -fno-exceptions"; // Do not enable exception handling, generates extra code needed to propagate exceptions
Result += " -fno-rtti"; //
Result += " -fno-short-enums"; // Do not allocate to an enum type only as many bytes as it needs for the declared range of possible values
// Result += " -finline-limit=64"; // GCC limits the size of functions that can be inlined, this flag allows coarse control of this limit
// Result += " -Wno-psabi"; // Warn when G++ generates code that is probably not compatible with the vendor-neutral C++ ABI
Result += " -march=armv7-a";
Result += " -mfloat-abi=softfp";
Result += " -mfpu=vfpv3-d16"; //@todo android: UE3 was just vfp. arm7a should all support v3 with 16 registers
//.........这里部分代码省略.........
示例4: CompileCPPFiles
public override CPPOutput CompileCPPFiles(UEBuildTarget Target, CPPEnvironment CompileEnvironment, List<FileItem> SourceFiles, string ModuleName)
{
var Arguments = new StringBuilder();
var PCHArguments = new StringBuilder();
Arguments.Append(GetCompileArguments_Global(CompileEnvironment));
if (CompileEnvironment.Config.PrecompiledHeaderAction == PrecompiledHeaderAction.Include)
{
// Add the precompiled header file's path to the include path so GCC can find it.
// This needs to be before the other include paths to ensure GCC uses it instead of the source header file.
var PrecompiledFileExtension = UEBuildPlatform.BuildPlatformDictionary[UnrealTargetPlatform.Mac].GetBinaryExtension(UEBuildBinaryType.PrecompiledHeader);
PCHArguments.Append(" -include \"");
PCHArguments.Append(CompileEnvironment.PrecompiledHeaderFile.AbsolutePath.Replace(PrecompiledFileExtension, ""));
PCHArguments.Append("\"");
}
// Add include paths to the argument list.
HashSet<string> AllIncludes = new HashSet<string>(CompileEnvironment.Config.CPPIncludeInfo.IncludePaths);
AllIncludes.UnionWith(CompileEnvironment.Config.CPPIncludeInfo.SystemIncludePaths);
foreach (string IncludePath in AllIncludes)
{
Arguments.Append(" -I\"");
if (BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac)
{
Arguments.Append(ConvertPath(Path.GetFullPath(IncludePath)));
// sync any third party headers we may need
if (IncludePath.Contains("ThirdParty"))
{
string[] FileList = Directory.GetFiles(IncludePath, "*.h", SearchOption.AllDirectories);
foreach (string File in FileList)
{
FileItem ExternalDependency = FileItem.GetItemByPath(File);
LocalToRemoteFileItem(ExternalDependency, true);
}
FileList = Directory.GetFiles(IncludePath, "*.cpp", SearchOption.AllDirectories);
foreach (string File in FileList)
{
FileItem ExternalDependency = FileItem.GetItemByPath(File);
LocalToRemoteFileItem(ExternalDependency, true);
}
}
}
else
{
Arguments.Append(IncludePath);
}
Arguments.Append("\"");
}
foreach (string Definition in CompileEnvironment.Config.Definitions)
{
Arguments.Append(" -D\"");
Arguments.Append(Definition);
Arguments.Append("\"");
}
var BuildPlatform = UEBuildPlatform.GetBuildPlatformForCPPTargetPlatform(CompileEnvironment.Config.Target.Platform);
CPPOutput Result = new CPPOutput();
// Create a compile action for each source file.
foreach (FileItem SourceFile in SourceFiles)
{
Action CompileAction = new Action(ActionType.Compile);
string FileArguments = "";
string Extension = Path.GetExtension(SourceFile.AbsolutePath).ToUpperInvariant();
if (CompileEnvironment.Config.PrecompiledHeaderAction == PrecompiledHeaderAction.Create)
{
// Compile the file as a C++ PCH.
FileArguments += GetCompileArguments_PCH();
}
else if (Extension == ".C")
{
// Compile the file as C code.
FileArguments += GetCompileArguments_C();
}
else if (Extension == ".CC")
{
// Compile the file as C++ code.
FileArguments += GetCompileArguments_CPP();
}
else if (Extension == ".MM")
{
// Compile the file as Objective-C++ code.
FileArguments += GetCompileArguments_MM();
}
else if (Extension == ".M")
{
// Compile the file as Objective-C++ code.
FileArguments += GetCompileArguments_M();
}
else
{
// Compile the file as C++ code.
FileArguments += GetCompileArguments_CPP();
//.........这里部分代码省略.........
示例5: CompileCPPFiles
public override CPPOutput CompileCPPFiles(UEBuildTarget Target, CPPEnvironment CompileEnvironment, List<FileItem> SourceFiles, string ModuleName)
{
if (CompileEnvironment.Config.Target.Architecture == "-win32") // simulator
{
return base.CompileCPPFiles(Target, CompileEnvironment, SourceFiles, ModuleName);
}
string Arguments = GetCLArguments_Global(CompileEnvironment);
CPPOutput Result = new CPPOutput();
// Add include paths to the argument list.
foreach (string IncludePath in CompileEnvironment.Config.CPPIncludeInfo.IncludePaths)
{
Arguments += string.Format(" -I\"{0}\"", IncludePath);
}
foreach (string IncludePath in CompileEnvironment.Config.CPPIncludeInfo.SystemIncludePaths)
{
Arguments += string.Format(" -I\"{0}\"", IncludePath);
}
// Add preprocessor definitions to the argument list.
foreach (string Definition in CompileEnvironment.Config.Definitions)
{
Arguments += string.Format(" -D{0}", Definition);
}
if (bEnableTracing)
{
Arguments += string.Format(" -D__EMSCRIPTEN_TRACING__");
}
var BuildPlatform = UEBuildPlatform.GetBuildPlatformForCPPTargetPlatform(CompileEnvironment.Config.Target.Platform);
foreach (FileItem SourceFile in SourceFiles)
{
Action CompileAction = new Action(ActionType.Compile);
bool bIsPlainCFile = Path.GetExtension(SourceFile.AbsolutePath).ToUpperInvariant() == ".C";
// Add the C++ source file and its included files to the prerequisite item list.
AddPrerequisiteSourceFile(Target, BuildPlatform, CompileEnvironment, SourceFile, CompileAction.PrerequisiteItems);
// Add the source file path to the command-line.
string FileArguments = string.Format(" \"{0}\"", SourceFile.AbsolutePath);
var ObjectFileExtension = UEBuildPlatform.GetBuildPlatform(UnrealTargetPlatform.HTML5).GetBinaryExtension(UEBuildBinaryType.Object);
// Add the object file to the produced item list.
FileItem ObjectFile = FileItem.GetItemByFileReference(
FileReference.Combine(
CompileEnvironment.Config.OutputDirectory,
Path.GetFileName(SourceFile.AbsolutePath) + ObjectFileExtension
)
);
CompileAction.ProducedItems.Add(ObjectFile);
FileArguments += string.Format(" -o \"{0}\"", ObjectFile.AbsolutePath);
// Add C or C++ specific compiler arguments.
if (bIsPlainCFile)
{
FileArguments += GetCLArguments_C(CompileEnvironment.Config.Target.Architecture);
}
else
{
FileArguments += GetCLArguments_CPP(CompileEnvironment);
}
CompileAction.WorkingDirectory = UnrealBuildTool.EngineSourceDirectory.FullName;
CompileAction.CommandPath = HTML5SDKInfo.Python();
CompileAction.CommandArguments = HTML5SDKInfo.EmscriptenCompiler() + " " + Arguments + FileArguments + CompileEnvironment.Config.AdditionalArguments;
//System.Console.WriteLine(CompileAction.CommandArguments);
CompileAction.StatusDescription = Path.GetFileName(SourceFile.AbsolutePath);
CompileAction.OutputEventHandler = new DataReceivedEventHandler(CompileOutputReceivedDataEventHandler);
// Don't farm out creation of precomputed headers as it is the critical path task.
CompileAction.bCanExecuteRemotely = CompileEnvironment.Config.PrecompiledHeaderAction != PrecompiledHeaderAction.Create;
// this is the final output of the compile step (a .abc file)
Result.ObjectFiles.Add(ObjectFile);
// VC++ always outputs the source file name being compiled, so we don't need to emit this ourselves
CompileAction.bShouldOutputStatusDescription = true;
// Don't farm out creation of precompiled headers as it is the critical path task.
CompileAction.bCanExecuteRemotely =
CompileEnvironment.Config.PrecompiledHeaderAction != PrecompiledHeaderAction.Create ||
BuildConfiguration.bAllowRemotelyCompiledPCHs;
}
return Result;
}
示例6: GetCLArguments_Global
static string GetCLArguments_Global(CPPEnvironment CompileEnvironment)
{
string Result = GetSharedArguments_Global(CompileEnvironment.Config.Target.Configuration, CompileEnvironment.Config.Target.Architecture, CompileEnvironment.Config.bEnableShadowVariableWarning);
if (CompileEnvironment.Config.Target.Architecture != "-win32") // ! simulator
{
// do we want debug info?
/* if (CompileEnvironment.Config.bCreateDebugInfo)
{
Result += " -g";
}*/
// Result += " -Wno-warn-absolute-paths "; // as of emscripten 1.35.0 complains that this is unknown
Result += " -Wno-reorder"; // we disable constructor order warnings.
if (CompileEnvironment.Config.Target.Configuration == CPPTargetConfiguration.Debug || CompileEnvironment.Config.Target.Configuration == CPPTargetConfiguration.Development)
{
Result += " -s GL_ASSERTIONS=1";
}
if (CompileEnvironment.Config.Target.Configuration == CPPTargetConfiguration.Debug)
{
Result += " -O0";
}
else // development & shipiing
{
Result += " -s ASM_JS=1";
if (UEBuildConfiguration.bCompileForSize)
{
Result += " -Oz -s OUTLINING_LIMIT=40000";
}
else
{
Result += " -s OUTLINING_LIMIT=110000";
if (CompileEnvironment.Config.Target.Configuration == CPPTargetConfiguration.Development)
{
Result += " -O2";
}
if (CompileEnvironment.Config.Target.Configuration == CPPTargetConfiguration.Shipping)
{
Result += " -O3";
}
}
}
}
return Result;
}
示例7: CompileCPPFiles
public abstract CPPOutput CompileCPPFiles(UEBuildTarget Target, CPPEnvironment CompileEnvironment, List<FileItem> SourceFiles, string ModuleName);
示例8: ExecuteHeaderToolIfNecessary
/**
* Builds and runs the header tool and touches the header directories.
* Performs any early outs if headers need no changes, given the UObject modules, tool path, game name, and configuration
*/
public static bool ExecuteHeaderToolIfNecessary( UEBuildTarget Target, CPPEnvironment GlobalCompileEnvironment, List<UHTModuleInfo> UObjectModules, string ModuleInfoFileName, ref ECompilationResult UHTResult )
{
if(ProgressWriter.bWriteMarkup)
{
Log.WriteLine(TraceEventType.Information, "@progress push 5%");
}
using (ProgressWriter Progress = new ProgressWriter("Generating code...", false))
{
// We never want to try to execute the header tool when we're already trying to build it!
var bIsBuildingUHT = Target.GetTargetName().Equals( "UnrealHeaderTool", StringComparison.InvariantCultureIgnoreCase );
var BuildPlatform = UEBuildPlatform.GetBuildPlatform(Target.Platform);
var CppPlatform = BuildPlatform.GetCPPTargetPlatform(Target.Platform);
var ToolChain = UEToolChain.GetPlatformToolChain(CppPlatform);
var RootLocalPath = Path.GetFullPath(ProjectFileGenerator.RootRelativePath);
// check if UHT is out of date
DateTime HeaderToolTimestamp = DateTime.MaxValue;
bool bHaveHeaderTool = !bIsBuildingUHT && GetHeaderToolTimestamp(out HeaderToolTimestamp);
// ensure the headers are up to date
bool bUHTNeedsToRun = (UEBuildConfiguration.bForceHeaderGeneration == true || !bHaveHeaderTool || AreGeneratedCodeFilesOutOfDate(UObjectModules, HeaderToolTimestamp));
if( bUHTNeedsToRun || UnrealBuildTool.IsGatheringBuild )
{
// Since code files are definitely out of date, we'll now finish computing information about the UObject modules for UHT. We
// want to save this work until we know that UHT actually needs to be run to speed up best-case iteration times.
if( UnrealBuildTool.IsGatheringBuild ) // In assembler-only mode, PCH info is loaded from our UBTMakefile!
{
foreach( var UHTModuleInfo in UObjectModules )
{
// Only cache the PCH name if we don't already have one. When running in 'gather only' mode, this will have already been cached
if( string.IsNullOrEmpty( UHTModuleInfo.PCH ) )
{
UHTModuleInfo.PCH = "";
// We need to figure out which PCH header this module is including, so that UHT can inject an include statement for it into any .cpp files it is synthesizing
var DependencyModuleCPP = (UEBuildModuleCPP)Target.GetModuleByName( UHTModuleInfo.ModuleName );
var ModuleCompileEnvironment = DependencyModuleCPP.CreateModuleCompileEnvironment(GlobalCompileEnvironment);
DependencyModuleCPP.CachePCHUsageForModuleSourceFiles(ModuleCompileEnvironment);
if (DependencyModuleCPP.ProcessedDependencies.UniquePCHHeaderFile != null)
{
UHTModuleInfo.PCH = DependencyModuleCPP.ProcessedDependencies.UniquePCHHeaderFile.AbsolutePath;
}
}
}
}
}
// @todo ubtmake: Optimization: Ideally we could avoid having to generate this data in the case where UHT doesn't even need to run! Can't we use the existing copy? (see below use of Manifest)
UHTManifest Manifest = new UHTManifest(Target, RootLocalPath, ToolChain.ConvertPath(RootLocalPath + '\\'), UObjectModules);
if( !bIsBuildingUHT && bUHTNeedsToRun )
{
// Always build UnrealHeaderTool if header regeneration is required, unless we're running within a Rocket ecosystem or hot-reloading
if (UnrealBuildTool.RunningRocket() == false &&
UEBuildConfiguration.bDoNotBuildUHT == false &&
UEBuildConfiguration.bHotReloadFromIDE == false &&
!( bHaveHeaderTool && !UnrealBuildTool.IsGatheringBuild && UnrealBuildTool.IsAssemblingBuild ) ) // If running in "assembler only" mode, we assume UHT is already up to date for much faster iteration!
{
// If it is out of date or not there it will be built.
// If it is there and up to date, it will add 0.8 seconds to the build time.
Log.TraceInformation("Building UnrealHeaderTool...");
var UBTArguments = new StringBuilder();
UBTArguments.Append( "UnrealHeaderTool" );
// Which desktop platform do we need to compile UHT for?
UBTArguments.Append(" " + BuildHostPlatform.Current.Platform.ToString());
// NOTE: We force Development configuration for UHT so that it runs quickly, even when compiling debug
UBTArguments.Append( " " + UnrealTargetConfiguration.Development.ToString() );
// NOTE: We disable mutex when launching UBT from within UBT to compile UHT
UBTArguments.Append( " -NoMutex" );
if (UnrealBuildTool.CommandLineContains("-noxge"))
{
UBTArguments.Append(" -noxge");
}
if ( RunExternalExecutable( UnrealBuildTool.GetUBTPath(), UBTArguments.ToString() ) != 0 )
{
return false;
}
}
Progress.Write(1, 3);
var ActualTargetName = String.IsNullOrEmpty( Target.GetTargetName() ) ? "UE4" : Target.GetTargetName();
Log.TraceInformation( "Parsing headers for {0}", ActualTargetName );
string HeaderToolPath = GetHeaderToolPath();
if (!File.Exists(HeaderToolPath))
{
throw new BuildException( "Unable to generate headers because UnrealHeaderTool binary was not found ({0}).", Path.GetFullPath( HeaderToolPath ) );
}
//.........这里部分代码省略.........
示例9: GeneratePCHCreationAction
/// <summary>
/// Creates a precompiled header action to generate a new pch file
/// </summary>
/// <param name="PCHHeaderNameInCode">The precompiled header name as it appeared in an #include statement</param>
/// <param name="PrecompiledHeaderIncludeFilename">Name of the header used for pch.</param>
/// <param name="ProjectCPPEnvironment">The environment the C/C++ files in the project are compiled with.</param>
/// <param name="OutputDirectory">The folder to save the generated PCH file to</param>
/// <param name="ModuleName">Name of the module this PCH is being generated for</param>
/// <param name="bAllowDLLExports">True if we should allow DLLEXPORT definitions for this PCH</param>
/// <returns>the compilation output result of the created pch.</returns>
public static CPPOutput GeneratePCHCreationAction(UEBuildTarget Target, string PCHHeaderNameInCode, FileItem PrecompiledHeaderIncludeFilename, CPPEnvironment ProjectCPPEnvironment, string OutputDirectory, string ModuleName, bool bAllowDLLExports )
{
// Find the header file to be precompiled. Don't skip external headers
if (PrecompiledHeaderIncludeFilename.bExists)
{
// Create a Dummy wrapper around the PCH to avoid problems with #pragma once on clang
var ToolChain = UEToolChain.GetPlatformToolChain(ProjectCPPEnvironment.Config.Target.Platform);
string PCHGuardDefine = Path.GetFileNameWithoutExtension(PrecompiledHeaderIncludeFilename.AbsolutePath).ToUpper();
string LocalPCHHeaderNameInCode = ToolChain.ConvertPath(PrecompiledHeaderIncludeFilename.AbsolutePath);
string TmpPCHHeaderContents = String.Format("#ifndef __AUTO_{0}_H__\n#define __AUTO_{0}_H__\n//Last Write: {2}\n#include \"{1}\"\n#endif//__AUTO_{0}_H__", PCHGuardDefine, LocalPCHHeaderNameInCode, PrecompiledHeaderIncludeFilename.LastWriteTime);
string DummyPath = Path.Combine(
ProjectCPPEnvironment.Config.OutputDirectory,
Path.GetFileName(PrecompiledHeaderIncludeFilename.AbsolutePath));
FileItem DummyPCH = FileItem.CreateIntermediateTextFile(DummyPath, TmpPCHHeaderContents);
// Create a new C++ environment that is used to create the PCH.
var ProjectPCHEnvironment = ProjectCPPEnvironment.DeepCopy();
ProjectPCHEnvironment.Config.PrecompiledHeaderAction = PrecompiledHeaderAction.Create;
ProjectPCHEnvironment.Config.PrecompiledHeaderIncludeFilename = PrecompiledHeaderIncludeFilename.AbsolutePath;
ProjectPCHEnvironment.Config.PCHHeaderNameInCode = PCHHeaderNameInCode;
ProjectPCHEnvironment.Config.OutputDirectory = OutputDirectory;
if( !bAllowDLLExports )
{
for( var CurDefinitionIndex = 0; CurDefinitionIndex < ProjectPCHEnvironment.Config.Definitions.Count; ++CurDefinitionIndex )
{
// We change DLLEXPORT to DLLIMPORT for "shared" PCH headers
var OldDefinition = ProjectPCHEnvironment.Config.Definitions[ CurDefinitionIndex ];
if( OldDefinition.EndsWith( "=DLLEXPORT" ) )
{
ProjectPCHEnvironment.Config.Definitions[ CurDefinitionIndex ] = OldDefinition.Replace( "DLLEXPORT", "DLLIMPORT" );
}
}
}
// Cache our CPP environment so that we can check for outdatedness quickly. Only files that have includes need this.
DummyPCH.CachedCPPIncludeInfo = ProjectPCHEnvironment.Config.CPPIncludeInfo;
Log.TraceVerbose( "Found PCH file \"{0}\".", PrecompiledHeaderIncludeFilename );
// Create the action to compile the PCH file.
return ProjectPCHEnvironment.CompileFiles(Target, new List<FileItem>() { DummyPCH }, ModuleName);
}
throw new BuildException( "Couldn't find PCH file \"{0}\".", PrecompiledHeaderIncludeFilename );
}
示例10: GetCLArguments_Global
static string GetCLArguments_Global(CPPEnvironment CompileEnvironment)
{
string Result = "";
//Result += " /showIncludes";
// Prevents the compiler from displaying its logo for each invocation.
Result += " /nologo";
// Enable intrinsic functions.
Result += " /Oi";
// Enable for static code analysis (where supported). Not treating analysis warnings as errors.
// Result += " /analyze:WX-";
// Pack struct members on 8-byte boundaries.
Result += " /Zp8";
// Calling convention - _cdecl
Result += " /Gd";
// Disable minimal rebuild
Result += " /Gm-";
// Security checks enabled
Result += " /GS";
// Separate functions for linker.
Result += " /Gy";
// Relaxes floating point precision semantics to allow more optimization.
Result += " /fp:fast";
// Compile into an .obj file, and skip linking.
Result += " /c";
// Allow 400% of the default memory allocation limit.
Result += " /Zm400";
// Allow large object files to avoid hitting the 2^16 section limit when running with -StressTestUnity.
Result += " /bigobj";
Result += " /Zc:wchar_t";
Result += " /Zc:forScope";
// Disable "The file contains a character that cannot be represented in the current code page" warning for non-US windows.
Result += " /wd4819";
if( BuildConfiguration.bUseSharedPCHs )
{
// @todo SharedPCH: Disable warning about PCH defines not matching .cpp defines. We "cheat" these defines a little
// bit to make shared PCHs work. But it's totally safe. Trust us.
Result += " /wd4651";
// @todo SharedPCH: Disable warning about redefining *API macros. The PCH header is compiled with various DLLIMPORTs, but
// when a module that uses that PCH header *IS* one of those imports, that module is compiled with EXPORTS, so the macro
// is redefined on the command-line. We need to clobber those defines to make shared PCHs work properly!
Result += " /wd4005";
}
// If compiling as a DLL, set the relevant defines
if (CompileEnvironment.Config.bIsBuildingDLL)
{
Result += " /D _WINDLL";
Result += " /D _USRDLLundefined_EXPORTS";
}
//
// Debug
//
if (CompileEnvironment.Config.Target.Configuration == CPPTargetConfiguration.Debug)
{
// Disable compiler optimization.
Result += " /Od";
// Favor code size (especially useful for embedded platforms).
Result += " /Os";
// Allow inline method expansion unless E&C support is requested
if (!BuildConfiguration.bSupportEditAndContinue)
{
// Allow inline method expansion of any suitable.
Result += " /Ob2";
}
// Perform runtime checks for (s) stack frames and (u) unintialized variables
// RTC1 == RTCsu
Result += " /RTC1";
}
//
// Release and LTCG
//
else
{
// Maximum optimizations.
Result += " /Ox";
// Enable intrinsics
Result += " /Oi";
// Allow inline method expansion
Result += " /Ob2";
//
//.........这里部分代码省略.........
示例11: GetCLArguments_CPP
static string GetCLArguments_CPP(CPPEnvironment CompileEnvironment)
{
string Result = "";
// Explicitly compile the file as C++.
Result += " /TP";
// C++/CLI requires that RTTI is left enabled
if (CompileEnvironment.Config.CLRMode == CPPCLRMode.CLRDisabled)
{
if (CompileEnvironment.Config.bUseRTTI)
{
// Enable C++ RTTI.
Result += " /GR";
}
else
{
// Disable C++ RTTI.
Result += " /GR-";
}
}
if (WinRTPlatform.ShouldCompileWinRT() == true)
{
// WinRT headers generate too many warnings for /W4
Result += " /W1";
}
else
{
// Level 3 warnings.
// Result += " /W3";
Result += " /W1";
}
return Result;
}
示例12: CompileCPPFiles
public override CPPOutput CompileCPPFiles(UEBuildTarget Target, CPPEnvironment CompileEnvironment, List<FileItem> SourceFiles, string ModuleName)
{
string Arguments = GetCLArguments_Global(CompileEnvironment);
// Add include paths to the argument list.
foreach (string IncludePath in CompileEnvironment.Config.CPPIncludeInfo.IncludePaths)
{
Arguments += string.Format(" /I \"{0}\"", IncludePath);
}
foreach (string IncludePath in CompileEnvironment.Config.CPPIncludeInfo.SystemIncludePaths)
{
Arguments += string.Format(" /I \"{0}\"", IncludePath);
}
if ((CompileEnvironment.Config.CLRMode == CPPCLRMode.CLREnabled) ||
(WinRTPlatform.ShouldCompileWinRT() == true))
{
// Add .NET framework assembly paths. This is needed so that C++/CLI projects
// can reference assemblies with #using, without having to hard code a path in the
// .cpp file to the assembly's location.
foreach (string AssemblyPath in CompileEnvironment.Config.SystemDotNetAssemblyPaths)
{
Arguments += string.Format(" /AI \"{0}\"", AssemblyPath);
}
// Add explicit .NET framework assembly references
foreach (string AssemblyName in CompileEnvironment.Config.FrameworkAssemblyDependencies)
{
Arguments += string.Format(" /FU \"{0}\"", AssemblyName);
}
// Add private assembly references
foreach (PrivateAssemblyInfo CurAssemblyInfo in CompileEnvironment.PrivateAssemblyDependencies)
{
Arguments += string.Format(" /FU \"{0}\"", CurAssemblyInfo.FileItem.AbsolutePath);
}
}
else
{
foreach (string AssemblyPath in CompileEnvironment.Config.SystemDotNetAssemblyPaths)
{
Arguments += string.Format(" /AI \"{0}\"", AssemblyPath);
}
// Add explicit .NET framework assembly references
foreach (string AssemblyName in CompileEnvironment.Config.FrameworkAssemblyDependencies)
{
Arguments += string.Format(" /FU \"{0}\"", AssemblyName);
}
}
// Add preprocessor definitions to the argument list.
foreach (string Definition in CompileEnvironment.Config.Definitions)
{
Arguments += string.Format(" /D \"{0}\"", Definition);
}
// Log.TraceInformation("Compile Arguments for {0}:", ModuleName);
// Log.TraceInformation(Arguments);
var BuildPlatform = UEBuildPlatform.GetBuildPlatformForCPPTargetPlatform(CompileEnvironment.Config.Target.Platform);
// Create a compile action for each source file.
CPPOutput Result = new CPPOutput();
foreach (FileItem SourceFile in SourceFiles)
{
Action CompileAction = new Action(ActionType.Compile);
string FileArguments = "";
bool bIsPlainCFile = Path.GetExtension(SourceFile.AbsolutePath).ToUpperInvariant() == ".C";
// Add the C++ source file and its included files to the prerequisite item list.
AddPrerequisiteSourceFile( Target, BuildPlatform, CompileEnvironment, SourceFile, CompileAction.PrerequisiteItems );
// If this is a CLR file then make sure our dependent assemblies are added as prerequisites
if (CompileEnvironment.Config.CLRMode == CPPCLRMode.CLREnabled)
{
foreach (PrivateAssemblyInfo CurPrivateAssemblyDependency in CompileEnvironment.PrivateAssemblyDependencies)
{
CompileAction.PrerequisiteItems.Add(CurPrivateAssemblyDependency.FileItem);
}
}
if (CompileEnvironment.Config.PrecompiledHeaderAction == PrecompiledHeaderAction.Create)
{
// Generate a CPP File that just includes the precompiled header.
string PCHCPPFilename = "PCH." + ModuleName + "." + Path.GetFileName(CompileEnvironment.Config.PrecompiledHeaderIncludeFilename) + ".cpp";
string PCHCPPPath = Path.Combine(CompileEnvironment.Config.OutputDirectory, PCHCPPFilename);
FileItem PCHCPPFile = FileItem.CreateIntermediateTextFile(
PCHCPPPath,
string.Format("#include \"{0}\"\r\n", CompileEnvironment.Config.PrecompiledHeaderIncludeFilename)
);
// Make sure the original source directory the PCH header file existed in is added as an include
// path -- it might be a private PCH header and we need to make sure that its found!
string OriginalPCHHeaderDirectory = Path.GetDirectoryName(SourceFile.AbsolutePath);
FileArguments += string.Format(" /I \"{0}\"", OriginalPCHHeaderDirectory);
var PCHExtension = UEBuildPlatform.BuildPlatformDictionary[UnrealTargetPlatform.WinRT].GetBinaryExtension(UEBuildBinaryType.PrecompiledHeader);
// Add the precompiled header file to the produced items list.
//.........这里部分代码省略.........
示例13: CPPEnvironment
/** Copy constructor. */
protected CPPEnvironment(CPPEnvironment InCopyEnvironment)
{
PrecompiledHeaderFile = InCopyEnvironment.PrecompiledHeaderFile;
PrivateAssemblyDependencies.AddRange(InCopyEnvironment.PrivateAssemblyDependencies);
SharedPCHHeaderFiles.AddRange( InCopyEnvironment.SharedPCHHeaderFiles );
SharedPCHEnvironments.AddRange( InCopyEnvironment.SharedPCHEnvironments );
bHackHeaderGenerator = InCopyEnvironment.bHackHeaderGenerator;
Config = new CPPEnvironmentConfiguration(InCopyEnvironment.Config);
}
示例14: GetCLArguments_Global
static string GetCLArguments_Global(CPPEnvironment CompileEnvironment)
{
string Result = GetSharedArguments_Global(CompileEnvironment.Config.Target.Configuration, CompileEnvironment.Config.Target.Architecture);
if (CompileEnvironment.Config.Target.Architecture != "-win32")
{
// do we want debug info?
/* if (CompileEnvironment.Config.bCreateDebugInfo)
{
Result += " -g";
}*/
Result += " -Wno-warn-absolute-paths ";
if (CompileEnvironment.Config.Target.Configuration == CPPTargetConfiguration.Debug)
{
Result += " -O0";
}
if (CompileEnvironment.Config.Target.Configuration == CPPTargetConfiguration.Debug || CompileEnvironment.Config.Target.Configuration == CPPTargetConfiguration.Development)
{
Result += " -s GL_ASSERTIONS=1 ";
}
if (CompileEnvironment.Config.Target.Configuration == CPPTargetConfiguration.Development)
{
if (UEBuildConfiguration.bCompileForSize)
{
Result += " -Oz -s ASM_JS=1 -s OUTLINING_LIMIT=40000";
}
else
{
Result += " -O2 -s ASM_JS=1 -s OUTLINING_LIMIT=110000";
}
}
if (CompileEnvironment.Config.Target.Configuration == CPPTargetConfiguration.Shipping)
{
if (UEBuildConfiguration.bCompileForSize)
{
Result += " -Oz -s ASM_JS=1 -s OUTLINING_LIMIT=40000";
}
else
{
Result += " -O3 -s ASM_JS=1 -s OUTLINING_LIMIT=110000";
}
}
}
return Result;
}
示例15: GenerateUnityCPPs
/// <summary>
/// Given a set of C++ files, generates another set of C++ files that #include all the original
/// files, the goal being to compile the same code in fewer translation units.
/// The "unity" files are written to the CompileEnvironment's OutputDirectory.
/// </summary>
/// <param name="Target">The target we're building</param>
/// <param name="CPPFiles">The C++ files to #include.</param>
/// <param name="CompileEnvironment">The environment that is used to compile the C++ files.</param>
/// <param name="BaseName">Base name to use for the Unity files</param>
/// <returns>The "unity" C++ files.</returns>
public static List<FileItem> GenerateUnityCPPs(
UEBuildTarget Target,
List<FileItem> CPPFiles,
CPPEnvironment CompileEnvironment,
string BaseName
)
{
var ToolChain = UEToolChain.GetPlatformToolChain(CompileEnvironment.Config.Target.Platform);
var BuildPlatform = UEBuildPlatform.GetBuildPlatformForCPPTargetPlatform(CompileEnvironment.Config.Target.Platform);
// Figure out size of all input files combined. We use this to determine whether to use larger unity threshold or not.
long TotalBytesInCPPFiles = CPPFiles.Sum(F => F.Info.Length);
// We have an increased threshold for unity file size if, and only if, all files fit into the same unity file. This
// is beneficial when dealing with PCH files. The default PCH creation limit is X unity files so if we generate < X
// this could be fairly slow and we'd rather bump the limit a bit to group them all into the same unity file.
//
// Optimization only makes sense if PCH files are enabled.
bool bForceIntoSingleUnityFile = BuildConfiguration.bStressTestUnity || (TotalBytesInCPPFiles < BuildConfiguration.NumIncludedBytesPerUnityCPP * 2 && CompileEnvironment.ShouldUsePCHs());
// Build the list of unity files.
List<FileCollection> AllUnityFiles;
{
var CPPUnityFileBuilder = new UnityFileBuilder(bForceIntoSingleUnityFile ? -1 : BuildConfiguration.NumIncludedBytesPerUnityCPP);
foreach( var CPPFile in CPPFiles )
{
if (!bForceIntoSingleUnityFile && CPPFile.AbsolutePath.Contains(".GeneratedWrapper."))
{
CPPUnityFileBuilder.EndCurrentUnityFile();
CPPUnityFileBuilder.AddFile(CPPFile);
CPPUnityFileBuilder.EndCurrentUnityFile();
}
else
{
CPPUnityFileBuilder.AddFile(CPPFile);
}
// Now that the CPPFile is part of this unity file, we will no longer need to treat it like a root level prerequisite for our
// dependency cache, as it is now an "indirect include" from the unity file. We'll clear out the compile environment
// attached to this file. This prevents us from having to cache all of the indirect includes from these files inside our
// dependency cache, which speeds up iterative builds a lot!
CPPFile.CachedCPPIncludeInfo = null;
}
AllUnityFiles = CPPUnityFileBuilder.GetUnityFiles();
}
//THIS CHANGE WAS MADE TO FIX THE BUILD IN OUR BRANCH
//DO NOT MERGE THIS BACK TO MAIN
string PCHHeaderNameInCode = CPPFiles.Count > 0 ? CPPFiles[0].PCHHeaderNameInCode : "";
if( CompileEnvironment.Config.PrecompiledHeaderIncludeFilename != null )
{
PCHHeaderNameInCode = ToolChain.ConvertPath( CompileEnvironment.Config.PrecompiledHeaderIncludeFilename );
// Generated unity .cpp files always include the PCH using an absolute path, so we need to update
// our compile environment's PCH header name to use this instead of the text it pulled from the original
// C++ source files
CompileEnvironment.Config.PCHHeaderNameInCode = PCHHeaderNameInCode;
}
// Create a set of CPP files that combine smaller CPP files into larger compilation units, along with the corresponding
// actions to compile them.
int CurrentUnityFileCount = 0;
var UnityCPPFiles = new List<FileItem>();
foreach( var UnityFile in AllUnityFiles )
{
++CurrentUnityFileCount;
StringWriter OutputUnityCPPWriter = new StringWriter();
StringWriter OutputUnityCPPWriterExtra = null;
// add an extra file for UBT to get the #include dependencies from
if (BuildPlatform.RequiresExtraUnityCPPWriter() == true)
{
OutputUnityCPPWriterExtra = new StringWriter();
}
OutputUnityCPPWriter.WriteLine("// This file is automatically generated at compile-time to include some subset of the user-created cpp files.");
// Explicitly include the precompiled header first, since Visual C++ expects the first top-level #include to be the header file
// that was used to create the PCH.
if (CompileEnvironment.Config.PrecompiledHeaderIncludeFilename != null)
{
OutputUnityCPPWriter.WriteLine("#include \"{0}\"", PCHHeaderNameInCode);
if (OutputUnityCPPWriterExtra != null)
{
OutputUnityCPPWriterExtra.WriteLine("#include \"{0}\"", PCHHeaderNameInCode);
}
}
//.........这里部分代码省略.........