Ejemplo n.º 1
0
        /// <summary>
        /// Gets all the runtime dependencies Copies all the runtime dependencies from any modules in
        /// </summary>
        /// <param name="RuntimeDependencies">The output list of runtime dependencies, mapping target file to type</param>
        /// <param name="TargetFileToSourceFile">Map of target files to source files that need to be copied</param>
        /// <param name="ExeDir">Output directory for the executable</param>
        public void PrepareRuntimeDependencies(List <RuntimeDependency> RuntimeDependencies, Dictionary <FileReference, FileReference> TargetFileToSourceFile, DirectoryReference ExeDir)
        {
            foreach (UEBuildModule Module in Modules)
            {
                foreach (ModuleRules.RuntimeDependency Dependency in Module.Rules.RuntimeDependencies.Inner)
                {
                    if (Dependency.SourcePath == null)
                    {
                        // Expand the target path
                        string ExpandedPath = Module.ExpandPathVariables(Dependency.Path, OutputDir, ExeDir);
                        if (FileFilter.FindWildcardIndex(ExpandedPath) == -1)
                        {
                            RuntimeDependencies.Add(new RuntimeDependency(new FileReference(ExpandedPath), Dependency.Type));
                        }
                        else
                        {
                            RuntimeDependencies.AddRange(FileFilter.ResolveWildcard(ExpandedPath).Select(x => new RuntimeDependency(x, Dependency.Type)));
                        }
                    }
                    else
                    {
                        // Parse the source and target patterns
                        FilePattern SourcePattern = new FilePattern(UnrealBuildTool.EngineSourceDirectory, Module.ExpandPathVariables(Dependency.SourcePath, OutputDir, ExeDir));
                        FilePattern TargetPattern = new FilePattern(UnrealBuildTool.EngineSourceDirectory, Module.ExpandPathVariables(Dependency.Path, OutputDir, ExeDir));

                        // Skip non-essential single files if they do not exist
                        if (Dependency.Type == StagedFileType.DebugNonUFS && !SourcePattern.ContainsWildcards() && !FileReference.Exists(SourcePattern.GetSingleFile()))
                        {
                            continue;
                        }

                        // Resolve all the wildcards between the source and target paths
                        Dictionary <FileReference, FileReference> Mapping;
                        try
                        {
                            Mapping = FilePattern.CreateMapping(null, ref SourcePattern, ref TargetPattern);
                        }
                        catch (FilePatternException Ex)
                        {
                            ExceptionUtils.AddContext(Ex, "while creating runtime dependencies for module '{0}'", Module.Name);
                            throw;
                        }

                        // Add actions to copy everything
                        foreach (KeyValuePair <FileReference, FileReference> Pair in Mapping)
                        {
                            FileReference ExistingSourceFile;
                            if (!TargetFileToSourceFile.TryGetValue(Pair.Key, out ExistingSourceFile))
                            {
                                TargetFileToSourceFile[Pair.Key] = Pair.Value;
                                RuntimeDependencies.Add(new RuntimeDependency(Pair.Key, Dependency.Type));
                            }
                            else if (ExistingSourceFile != Pair.Value)
                            {
                                throw new BuildException("Runtime dependency '{0}' is configured to be staged from '{1}' and '{2}'", Pair.Key, Pair.Value, ExistingSourceFile);
                            }
                        }
                    }
                }
            }
        }