Ejemplo n.º 1
0
 /// <summary>
 /// Generates a full path to action history file for the specified target.
 /// </summary>
 public static string GeneratePathForTarget(STBuildTarget Target)
 {
     string Folder = null;
     if (Target.ShouldCompileMonolithic() || Target.TargetType == TargetRules.TargetType.Program)
     {
         // Monolithic configs and programs have their Action History stored in their respective project folders
         // or under engine intermediate folder + program name folder
         string RootDirectory = STBuildTool.GetUProjectPath();
         if (String.IsNullOrEmpty(RootDirectory))
         {
             RootDirectory = Path.GetFullPath(BuildConfiguration.RelativeEnginePath);
         }
         Folder = Path.Combine(RootDirectory, BuildConfiguration.PlatformIntermediateFolder, Target.GetTargetName());
     }
     else
     {
         // Shared action history (unless this is a rocket target)
         Folder = STBuildTool.RunningRocket() ?
             Path.Combine(STBuildTool.GetUProjectPath(), BuildConfiguration.BaseIntermediateFolder) :
             BuildConfiguration.BaseIntermediatePath;
     }
     return Path.Combine(Folder, "ActionHistory.bin").Replace("\\", "/");
 }
Ejemplo n.º 2
0
        public override void RecursivelyProcessUnboundModules(STBuildTarget Target, ref Dictionary<string, STBuildBinary> Binaries, STBuildBinary ExecutableBinary)
        {
            try
            {
                // Make sure this module is bound to a binary
                if (!bIncludedInTarget)
                {
                    throw new BuildException("Module '{0}' should already have been bound to a binary!", Name);
                }

                var AllModuleNames = new List<string>();
                AllModuleNames.AddRange(PrivateDependencyModuleNames);
                AllModuleNames.AddRange(PublicDependencyModuleNames);
                AllModuleNames.AddRange(DynamicallyLoadedModuleNames);
                AllModuleNames.AddRange(PlatformSpecificDynamicallyLoadedModuleNames);

                foreach (var DependencyName in AllModuleNames)
                {
                    var DependencyModule = Target.FindOrCreateModuleByName(DependencyName);

                    // Skip modules that are included with the target (externals)
                    if (!DependencyModule.bIncludedInTarget)
                    {
                        if (!Binaries.ContainsKey(DependencyModule.Name))
                        {
                            STBuildBinary BinaryToBindTo;
                            if (Target.ShouldCompileMonolithic())
                            {
                                // When linking monolithically, any unbound modules will be linked into the main executable
                                BinaryToBindTo = ExecutableBinary;
                            }
                            else
                            {
                                // Is this a plugin module?
                                var PluginInfo = Plugins.GetPluginInfoForModule(DependencyName);

                                string[] OutputFilePaths = Target.MakeBinaryPaths(DependencyModule.Name, Target.GetAppName() + "-" + DependencyModule.Name, STBuildBinaryType.DynamicLinkLibrary, Target.TargetType, PluginInfo, "");

                                // If it's an engine module, output intermediates to the engine intermediates directory.
                                string IntermediateDirectory = Binary.Config.IntermediateDirectory;
                                if (IntermediateDirectory != Target.EngineIntermediateDirectory && Path.GetFullPath(DependencyModule.ModuleDirectory).StartsWith(Path.GetFullPath(BuildConfiguration.RelativeEnginePath)))
                                {
                                    IntermediateDirectory = Target.EngineIntermediateDirectory;
                                }

                                // When using modular linkage, unbound modules will be linked into their own DLL files
                                STBuildBinaryConfiguration Config = new STBuildBinaryConfiguration(InType: STBuildBinaryType.DynamicLinkLibrary,
                                                                                                    InOutputFilePaths: OutputFilePaths,
                                                                                                    InIntermediateDirectory: IntermediateDirectory,
                                                                                                    bInAllowExports: true,
                                                                                                    InModuleNames: new List<string> { DependencyModule.Name },
                                                                                                    InTargetName: Target.GetAppName(),
                                                                                                    bInIsCrossTarget: PlatformSpecificDynamicallyLoadedModuleNames.Contains(DependencyName) && !DynamicallyLoadedModuleNames.Contains(DependencyName),
                                                                                                    InTargetConfiguration: Target.Configuration,
                                                                                                    bInCompileMonolithic: Target.ShouldCompileMonolithic());

                                // Fix up the binary path if this is module specifies an alternate output directory
                                for (int Index = 0; Index < Config.OutputFilePaths.Length; Index++)
                                {
                                    Config.OutputFilePaths[Index] = DependencyModule.FixupOutputPath(Config.OutputFilePaths[Index]);
                                }

                                BinaryToBindTo = new STBuildBinaryCPP(Target, Config);
                            }

                            Binaries[DependencyModule.Name] = BinaryToBindTo;

                            // Bind this module
                            DependencyModule.Binary = BinaryToBindTo;
                            DependencyModule.bIncludedInTarget = true;

                            // Also add binaries for this module's dependencies
                            DependencyModule.RecursivelyProcessUnboundModules(Target, ref Binaries, ExecutableBinary);
                        }
                    }

                    if (Target.ShouldCompileMonolithic() == false)
                    {
                        // Check to see if there is a circular relationship between the module and it's referencer
                        if (DependencyModule.Binary != null)
                        {
                            if (CircularlyReferencedDependentModules.Contains(DependencyName))
                            {
                                DependencyModule.Binary.SetCreateImportLibrarySeparately(true);
                            }
                        }
                    }
                }

                // Also make sure module entries are created for any module that is pulled in as an "include path" module.
                // These modules are never linked in unless they were referenced as an actual dependency of a different module,
                // but we still need to keep track of them so that we can find their include paths when setting up our
                // module's include paths.
                RecursivelyAddIncludePathModules(Target, bPublicIncludesOnly: false);
            }
            catch (System.Exception ex)
            {
                throw new ModuleProcessingException(this, ex);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Determines where generated code files will be stored for this module
        /// </summary>
        /// <param name="ModuleDirectory">Module's base directory</param>
        /// <param name="ModuleName">Name of module</param>
        /// <returns></returns>
        public static string GetGeneratedCodeDirectoryForModule(STBuildTarget Target, string ModuleDirectory, string ModuleName)
        {
            string BaseDirectory = null;
            if ((Target.ShouldCompileMonolithic() || Target.TargetType == TargetRules.TargetType.Program) &&
                (!STBuildTool.BuildingRocket()) &&
                (!STBuildTool.RunningRocket() || Utils.IsFileUnderDirectory(ModuleDirectory, STBuildTool.GetUProjectPath())))
            {
                // Monolithic configurations and programs have their intermediate headers stored under their
                // respective project folders with the exception of rocket which always stores engine modules in the engine folder.
                string RootDirectory = STBuildTool.GetUProjectPath();
                if (String.IsNullOrEmpty(RootDirectory))
                {
                    // Intermediates under Engine intermediate folder (program name will be appended later)
                    RootDirectory = Path.GetFullPath(BuildConfiguration.RelativeEnginePath);
                }
                BaseDirectory = Path.Combine(RootDirectory, BuildConfiguration.PlatformIntermediateFolder, Target.GetTargetName(), "Inc");
            }
            else if (Plugins.IsPluginModule(ModuleName))
            {
                // Plugin module
                string PluginIntermediateIncPath;
                {
                    PluginInfo Plugin = Plugins.GetPluginInfoForModule(ModuleName);
                    if (Plugin.LoadedFrom == PluginInfo.LoadedFromType.Engine)
                    {
                        // Plugin folder is in the engine directory
                        PluginIntermediateIncPath = Path.GetFullPath(Path.Combine(BuildConfiguration.RelativeEnginePath, BuildConfiguration.PlatformIntermediateFolder));
                    }
                    else
                    {
                        // Plugin folder is in the project directory
                        PluginIntermediateIncPath = Path.GetFullPath(Path.Combine(Target.ProjectDirectory, BuildConfiguration.PlatformIntermediateFolder));
                    }
                    PluginIntermediateIncPath = Path.Combine(PluginIntermediateIncPath, "Inc", "Plugins");
                }
                BaseDirectory = PluginIntermediateIncPath;
            }
            else
            {
                var AllProjectFolders = STBuildTarget.DiscoverAllGameFolders();		// @todo fastubt: This will be called again and again for every UObject module (80+)
                BaseDirectory = AllProjectFolders.Find(ProjectFolder => Utils.IsFileUnderDirectory(ModuleDirectory, ProjectFolder));
                if (BaseDirectory == null)
                {
                    // Must be an engine module or program module
                    BaseDirectory = ProjectFileGenerator.EngineRelativePath;
                }

                BaseDirectory = Path.GetFullPath(Path.Combine(BaseDirectory, BuildConfiguration.PlatformIntermediateFolder, "Inc"));
            }

            // Construct the intermediate path.
            var GeneratedCodeDirectory = Path.Combine(BaseDirectory, ModuleName);
            return GeneratedCodeDirectory + Path.DirectorySeparatorChar;
        }
Ejemplo n.º 4
0
        /**
         *	Setup the target environment for building
         *
         *	@param	InBuildTarget		The target being built
         */
        public override void SetUpEnvironment(STBuildTarget InBuildTarget)
        {
            InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("WIN32=1");

            // Win32 XP is only supported at this time.
            SupportWindowsXP = SupportWindowsXPIfAvailable && (GetCPPTargetPlatform(InBuildTarget.Platform) == CPPTargetPlatform.Win32);
            if (IsWindowsXPSupported())
            {
                // Windows XP SP3 or higher required
                InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("_WIN32_WINNT=0x0502");
                InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("WINVER=0x0502");
            }
            else
            {
                // Windows Vista or higher required
                InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("_WIN32_WINNT=0x0600");
                InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("WINVER=0x0600");
            }
            InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("PLATFORM_WINDOWS=1");

            String MorpheusShaderPath = Path.Combine(BuildConfiguration.RelativeEnginePath, "Shaders/PS4/PostProcessHMDMorpheus.usf");
            if (File.Exists(MorpheusShaderPath))
            {
                InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("HAS_MORPHEUS=1");

                //on PS4 the SDK now handles distortion correction.  On PC we will still have to handle it manually,
                //but we require SDK changes before we can get the required data.  For the moment, no platform does in-engine morpheus distortion
                InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Add("MORPHEUS_ENGINE_DISTORTION=0");
            }

            if (InBuildTarget.Rules != null)
            {
                // Explicitly exclude the MS C++ runtime libraries we're not using, to ensure other libraries we link with use the same
                // runtime library as the engine.
                bool bUseDebugCRT = InBuildTarget.Configuration == STTargetConfiguration.Debug && BuildConfiguration.bDebugBuildsActuallyUseDebugCRT;
                if (!InBuildTarget.Rules.bUseStaticCRT || bUseDebugCRT)
                {
                    InBuildTarget.GlobalLinkEnvironment.Config.ExcludedLibraries.Add("LIBCMT");
                    InBuildTarget.GlobalLinkEnvironment.Config.ExcludedLibraries.Add("LIBCPMT");
                }
                if (!InBuildTarget.Rules.bUseStaticCRT || !bUseDebugCRT)
                {
                    InBuildTarget.GlobalLinkEnvironment.Config.ExcludedLibraries.Add("LIBCMTD");
                    InBuildTarget.GlobalLinkEnvironment.Config.ExcludedLibraries.Add("LIBCPMTD");
                }
                if (InBuildTarget.Rules.bUseStaticCRT || bUseDebugCRT)
                {
                    InBuildTarget.GlobalLinkEnvironment.Config.ExcludedLibraries.Add("MSVCRT");
                    InBuildTarget.GlobalLinkEnvironment.Config.ExcludedLibraries.Add("MSVCPRT");
                }
                if (InBuildTarget.Rules.bUseStaticCRT || !bUseDebugCRT)
                {
                    InBuildTarget.GlobalLinkEnvironment.Config.ExcludedLibraries.Add("MSVCRTD");
                    InBuildTarget.GlobalLinkEnvironment.Config.ExcludedLibraries.Add("MSVCPRTD");
                }
                InBuildTarget.GlobalLinkEnvironment.Config.ExcludedLibraries.Add("LIBC");
                InBuildTarget.GlobalLinkEnvironment.Config.ExcludedLibraries.Add("LIBCP");
                InBuildTarget.GlobalLinkEnvironment.Config.ExcludedLibraries.Add("LIBCD");
                InBuildTarget.GlobalLinkEnvironment.Config.ExcludedLibraries.Add("LIBCPD");

                //@todo ATL: Currently, only VSAccessor requires ATL (which is only used in editor builds)
                // When compiling games, we do not want to include ATL - and we can't when compiling Rocket games
                // due to VS 2012 Express not including ATL.
                // If more modules end up requiring ATL, this should be refactored into a BuildTarget flag (bNeedsATL)
                // that is set by the modules the target includes to allow for easier tracking.
                // Alternatively, if VSAccessor is modified to not require ATL than we should always exclude the libraries.
                if (InBuildTarget.ShouldCompileMonolithic() && (InBuildTarget.Rules != null) &&
                    (TargetRules.IsGameType(InBuildTarget.TargetType)) && (TargetRules.IsEditorType(InBuildTarget.TargetType) == false))
                {
                    InBuildTarget.GlobalLinkEnvironment.Config.ExcludedLibraries.Add("atl");
                    InBuildTarget.GlobalLinkEnvironment.Config.ExcludedLibraries.Add("atls");
                    InBuildTarget.GlobalLinkEnvironment.Config.ExcludedLibraries.Add("atlsd");
                    InBuildTarget.GlobalLinkEnvironment.Config.ExcludedLibraries.Add("atlsn");
                    InBuildTarget.GlobalLinkEnvironment.Config.ExcludedLibraries.Add("atlsnd");
                }

                // Add the library used for the delayed loading of DLLs.
                InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("delayimp.lib");

                //@todo - remove once FB implementation uses Http module
                if (STBuildConfiguration.bCompileAgainstEngine)
                {
                    // link against wininet (used by FBX and Facebook)
                    InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("wininet.lib");
                }

                // Compile and link with Win32 API libraries.
                InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("rpcrt4.lib");
                //InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("wsock32.lib");
                InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("ws2_32.lib");
                InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("dbghelp.lib");
                InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("comctl32.lib");
                InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("Winmm.lib");
                InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("kernel32.lib");
                InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("user32.lib");
                InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("gdi32.lib");
                InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("winspool.lib");
                InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("comdlg32.lib");
                InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("advapi32.lib");
                InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("shell32.lib");
                InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("ole32.lib");
                InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("oleaut32.lib");
                InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("uuid.lib");
                InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("odbc32.lib");
                InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("odbccp32.lib");
                InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("netapi32.lib");
                InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("iphlpapi.lib");
                InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("setupapi.lib"); //  Required for access monitor device enumeration

                // Windows Vista/7 Desktop Windows Manager API for Slate Windows Compliance
                if (IsWindowsXPSupported() == false)		// Windows XP does not support DWM
                {
                    InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("dwmapi.lib");
                }

                // IME
                InBuildTarget.GlobalLinkEnvironment.Config.AdditionalLibraries.Add("imm32.lib");

                // Setup assembly path for .NET modules.  This will only be used when CLR is enabled. (CPlusPlusCLR module types)
                InBuildTarget.GlobalCompileEnvironment.Config.SystemDotNetAssemblyPaths.Add(
                    Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) +
                    "/Reference Assemblies/Microsoft/Framework/.NETFramework/v4.0");

                // Setup default assemblies for .NET modules.  These will only be used when CLR is enabled. (CPlusPlusCLR module types)
                InBuildTarget.GlobalCompileEnvironment.Config.FrameworkAssemblyDependencies.Add("System.dll");
                InBuildTarget.GlobalCompileEnvironment.Config.FrameworkAssemblyDependencies.Add("System.Data.dll");
                InBuildTarget.GlobalCompileEnvironment.Config.FrameworkAssemblyDependencies.Add("System.Drawing.dll");
                InBuildTarget.GlobalCompileEnvironment.Config.FrameworkAssemblyDependencies.Add("System.Xml.dll");
                InBuildTarget.GlobalCompileEnvironment.Config.FrameworkAssemblyDependencies.Add("System.Management.dll");
                InBuildTarget.GlobalCompileEnvironment.Config.FrameworkAssemblyDependencies.Add("System.Windows.Forms.dll");
                InBuildTarget.GlobalCompileEnvironment.Config.FrameworkAssemblyDependencies.Add("WindowsBase.dll");
            }

            // Disable Simplygon support if compiling against the NULL RHI.
            if (InBuildTarget.GlobalCompileEnvironment.Config.Definitions.Contains("USE_NULL_RHI=1"))
            {
                STBuildConfiguration.bCompileSimplygon = false;
            }

            // For 64-bit builds, we'll forcibly ignore a linker warning with DirectInput.  This is
            // Microsoft's recommended solution as they don't have a fixed .lib for us.
            if (InBuildTarget.Platform == STTargetPlatform.Win64)
            {
                InBuildTarget.GlobalLinkEnvironment.Config.AdditionalArguments += " /ignore:4078";
            }
        }