コード例 #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));

                        // 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);
                            }
                        }
                    }
                }
            }
        }
コード例 #2
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="SourceFiles">Receives the list of source files that were copied</param>
        /// <param name="ActionGraph">Actions to be executed</param>
        public IEnumerable <FileItem> PrepareRuntimeDependencies(List <RuntimeDependency> RuntimeDependencies, List <FileReference> SourceFiles, ActionGraph ActionGraph)
        {
            List <FileItem> CopiedFiles = new List <FileItem>();

            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, this);
                        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, this));
                        FilePattern TargetPattern = new FilePattern(UnrealBuildTool.EngineSourceDirectory, Module.ExpandPathVariables(Dependency.Path, this));

                        // 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)
                        {
                            throw new BuildException(Ex, "While creating runtime dependencies for module {0}", Module.Name);
                        }

                        // Add actions to copy everything
                        foreach (KeyValuePair <FileReference, FileReference> Pair in Mapping)
                        {
                            CopiedFiles.Add(CreateCopyAction(Pair.Value, Pair.Key, ActionGraph));
                            SourceFiles.Add(Pair.Value);
                            RuntimeDependencies.Add(new RuntimeDependency(Pair.Key, Dependency.Type));
                        }
                    }
                }
            }
            return(CopiedFiles);
        }