Esempio n. 1
0
        /// <summary>
        /// Checks whether the binary output paths are appropriate for the distribution
        /// level of its direct module dependencies
        /// </summary>
        public void CheckOutputDistributionLevelAgainstDependencies(Dictionary <UEBuildModule, UEBuildModuleDistribution> ModuleDistributionCache)
        {
            // Find maximum distribution level of its direct dependencies
            UEBuildModuleDistribution DistributionLevel = UEBuildModuleDistribution.Public;
            List <UEBuildModule>      DependantModules  = GetAllDependencyModules(false, false);

            List <string>[] DependantModuleNames = new List <string> [Enum.GetNames(typeof(UEBuildModuleDistribution)).Length];
            foreach (UEBuildModule Module in DependantModules)
            {
                UEBuildModuleDistribution ModuleDistributionLevel;
                if (!ModuleDistributionCache.TryGetValue(Module, out ModuleDistributionLevel))
                {
                    ModuleDistributionLevel = Module.DetermineDistributionLevel();
                    ModuleDistributionCache.Add(Module, ModuleDistributionLevel);
                }
                if (ModuleDistributionLevel != UEBuildModuleDistribution.Public)
                {
                    // Make a list of non-public dependant modules so that exception
                    // message can be more helpful
                    int DistributionIndex = (int)ModuleDistributionLevel;
                    if (DependantModuleNames[DistributionIndex] == null)
                    {
                        DependantModuleNames[DistributionIndex] = new List <string>();
                    }
                    DependantModuleNames[DistributionIndex].Add(Module.Name);

                    DistributionLevel = Utils.Max(DistributionLevel, ModuleDistributionLevel);
                }
            }

            // Check Output Paths if dependencies shouldn't be distributed to everyone
            if (DistributionLevel != UEBuildModuleDistribution.Public)
            {
                foreach (FileReference OutputFilePath in Config.OutputFilePaths)
                {
                    UEBuildModuleDistribution OutputDistributionLevel = UEBuildModule.GetModuleDistributionLevelBasedOnLocation(OutputFilePath.FullName);

                    // Throw exception if output path is not appropriate
                    if (OutputDistributionLevel < DistributionLevel)
                    {
                        string JoinedModuleNames = String.Join(",", DependantModuleNames[(int)DistributionLevel]);
                        throw new BuildException("Output file \"{0}\" has distribution level of \"{1}\" but has direct dependencies on modules with distribution level of \"{2}\" ({3}).\nEither change to dynamic dependencies, set BinariesSubFolder/ExeBinariesSubFolder to \"{2}\" or set bOutputPubliclyDistributable to true in the target.cs or build.cs file.",
                                                 OutputFilePath, OutputDistributionLevel.ToString(), DistributionLevel.ToString(), JoinedModuleNames);
                    }
                }
            }
        }