Ejemplo n.º 1
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.º 2
0
        public override void RecursivelyAddIncludePathModules(STBuildTarget Target, bool bPublicIncludesOnly)
        {
            var AllIncludePathModuleNames = new List<string>();
            AllIncludePathModuleNames.AddRange(PublicIncludePathModuleNames);
            if (!bPublicIncludesOnly)
            {
                AllIncludePathModuleNames.AddRange(PrivateIncludePathModuleNames);
            }
            foreach (var IncludePathModuleName in AllIncludePathModuleNames)
            {
                var IncludePathModule = Target.FindOrCreateModuleByName(IncludePathModuleName);

                // No need to do anything here.  We just want to make sure that we've instantiated our representation of the
                // module so that we can find it later when processing include path module names.  Unlike actual dependency
                // modules, these include path modules may never be "bound" (have Binary or bIncludedInTarget member variables set)

                // We'll also need to make sure we know about all dependent public include path modules, too!
                IncludePathModule.RecursivelyAddIncludePathModules(Target, bPublicIncludesOnly: true);
            }
        }