Beispiel #1
0
        public static bool Robust_DirectoryExists_NoExceptions(string Directoryname, string Message)
        {
            bool bFound = false;

            if (!CommandUtils.DirectoryExists_NoExceptions(Directoryname))
            {
                // mac is terrible on shares, this isn't a solution, but a stop gap
                if (Directoryname.StartsWith("/Volumes/"))
                {
                    int Retry = 0;
                    while (!bFound && Retry < 60)
                    {
                        //@todo: These retries should be reported so we can track how often they are occurring.
                        CommandUtils.LogInformation("*** Mac temp storage retry {0}", Directoryname);
                        System.Threading.Thread.Sleep(10000);
                        bFound = CommandUtils.DirectoryExists_NoExceptions(Directoryname);
                        Retry++;
                    }
                }
            }
            else
            {
                bFound = true;
            }
            return(bFound);
        }
Beispiel #2
0
        public List <string> Distill(string FullPathAndWildcard, bool bRecursive = false, bool bAllowMissing = false, bool MoveSymbols = true, params string[] Exclusions)
        {
            var FilesToCopy = new List <string>();

            string AbsFile = CommandUtils.CombinePaths(FullPathAndWildcard);

            CommandUtils.Log("Distilling {0}", AbsFile);
            string PathOnly = Path.GetDirectoryName(AbsFile);

            if (!CommandUtils.DirectoryExists_NoExceptions(PathOnly))
            {
                if (bAllowMissing)
                {
                    return(FilesToCopy);
                }
                throw new AutomationException("Path {0} was used to distill {1} but it doesn't exist.", PathOnly, AbsFile);
            }
            var Files   = CommandUtils.FindFiles(Path.GetFileName(AbsFile), bRecursive, PathOnly);
            var Exclude = new List <string>();

            foreach (var Excl in Exclusions)
            {
                if (!Excl.Contains("/") && !Excl.Contains("\\"))
                {
                    var ExFiles = CommandUtils.FindFiles(Excl, bRecursive, PathOnly);
                    Exclude.AddRange(ExFiles);
                }
            }

            foreach (var FileToCopy in Files)
            {
                bool bOk = !Exclude.Contains(FileToCopy) && !RejectFile(FileToCopy, PathOnly);
                foreach (var Excl in Exclusions)
                {
                    if (Excl.Contains("/") || Excl.Contains("\\"))
                    {
                        if (Excl.Contains("*") || Excl.Contains("?"))
                        {
                            throw new AutomationException("Exclusion {0} is illegal, must either be a substring or a wildcard without a path", Excl);
                        }
                        bOk = bOk && !RejectFileOnSubstring(FileToCopy, Excl, PathOnly);
                    }
                }
                if (bOk)
                {
                    FilesToCopy.Add(CopyFileToDest(FileToCopy, MoveSymbols));
                }
            }
            if (FilesToCopy.Count < 1 && !bAllowMissing)
            {
                throw new AutomationException("Distill {0} did not produce any files. Recursive option was {1}.", AbsFile, bRecursive.ToString());
            }
            return(FilesToCopy);
        }
        /// <summary>
        /// Finds all targets for the project.
        /// </summary>
        /// <param name="Properties">Project properties.</param>
        /// <param name="ExtraSearchPaths">Additional search paths.</param>
        private static void DetectTargetsForProject(ProjectProperties Properties, List <string> ExtraSearchPaths = null)
        {
            Properties.Targets = new Dictionary <TargetType, SingleTargetProperties>();
            FileReference TargetsDllFilename;
            string        FullProjectPath = null;

            var GameFolders = new List <DirectoryReference>();
            var RulesFolder = new DirectoryReference(GetRulesAssemblyFolder());

            if (Properties.RawProjectPath != null)
            {
                CommandUtils.LogVerbose("Looking for targets for project {0}", Properties.RawProjectPath);

                TargetsDllFilename = FileReference.Combine(RulesFolder, String.Format("UATRules{0}.dll", Properties.RawProjectPath.GetHashCode()));

                FullProjectPath = CommandUtils.GetDirectoryName(Properties.RawProjectPath.FullName);
                GameFolders.Add(new DirectoryReference(FullProjectPath));
                CommandUtils.LogVerbose("Searching for target rule files in {0}", FullProjectPath);
            }
            else
            {
                TargetsDllFilename = FileReference.Combine(RulesFolder, String.Format("UATRules{0}.dll", "_BaseEngine_"));
            }

            // the UBT code assumes a certain CWD, but artists don't have this CWD.
            var  SourceDir = CommandUtils.CombinePaths(CommandUtils.CmdEnv.LocalRoot, "Engine", "Source");
            bool DirPushed = false;

            if (CommandUtils.DirectoryExists_NoExceptions(SourceDir))
            {
                CommandUtils.PushDir(SourceDir);
                DirPushed = true;
            }
            var ExtraSearchDirectories = (ExtraSearchPaths == null)? null : ExtraSearchPaths.Select(x => new DirectoryReference(x)).ToList();
            var TargetScripts          = RulesCompiler.FindAllRulesSourceFiles(RulesCompiler.RulesFileType.Target, GameFolders: GameFolders, ForeignPlugins: null, AdditionalSearchPaths: ExtraSearchDirectories, bIncludeEnterprise: false);

            if (DirPushed)
            {
                CommandUtils.PopDir();
            }

            if (!CommandUtils.IsNullOrEmpty(TargetScripts))
            {
                // We only care about project target script so filter out any scripts not in the project folder, or take them all if we are just doing engine stuff
                var ProjectTargetScripts = new List <FileReference>();
                foreach (var TargetScript in TargetScripts)
                {
                    if (FullProjectPath == null || TargetScript.IsUnderDirectory(new DirectoryReference(FullProjectPath)))
                    {
                        ProjectTargetScripts.Add(TargetScript);
                    }
                }
                TargetScripts = ProjectTargetScripts;
            }

            if (!CommandUtils.IsNullOrEmpty(TargetScripts))
            {
                CommandUtils.LogVerbose("Found {0} target rule files:", TargetScripts.Count);
                foreach (var Filename in TargetScripts)
                {
                    CommandUtils.LogVerbose("  {0}", Filename);
                }

                // Check if the scripts require compilation
                bool DoNotCompile = false;
                if (!CommandUtils.IsBuildMachine && !CheckIfScriptAssemblyIsOutOfDate(TargetsDllFilename, TargetScripts))
                {
                    Log.TraceVerbose("Targets DLL {0} is up to date.", TargetsDllFilename);
                    DoNotCompile = true;
                }
                if (!DoNotCompile && CommandUtils.FileExists_NoExceptions(TargetsDllFilename.FullName))
                {
                    if (!CommandUtils.DeleteFile_NoExceptions(TargetsDllFilename.FullName, true))
                    {
                        DoNotCompile = true;
                        CommandUtils.LogVerbose("Could not delete {0} assuming it is up to date and reusable for a recursive UAT call.", TargetsDllFilename);
                    }
                }

                CompileAndLoadTargetsAssembly(Properties, TargetsDllFilename, DoNotCompile, TargetScripts);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Finds all targets for the project.
        /// </summary>
        /// <param name="Properties">Project properties.</param>
        /// <param name="ExtraSearchPaths">Additional search paths.</param>
        private static void DetectTargetsForProject(ProjectProperties Properties, List <string> ExtraSearchPaths = null)
        {
            Properties.Targets = new Dictionary <TargetRules.TargetType, SingleTargetProperties>();
            string TargetsDllFilename;
            string FullProjectPath = null;

            var GameFolders = new List <string>();
            var RulesFolder = GetRulesAssemblyFolder();

            if (!String.IsNullOrEmpty(Properties.RawProjectPath))
            {
                CommandUtils.Log("Looking for targets for project {0}", Properties.RawProjectPath);

                TargetsDllFilename = CommandUtils.CombinePaths(RulesFolder, String.Format("UATRules{0}.dll", Properties.RawProjectPath.GetHashCode()));

                FullProjectPath = CommandUtils.GetDirectoryName(Properties.RawProjectPath);
                GameFolders.Add(FullProjectPath);
                CommandUtils.Log("Searching for target rule files in {0}", FullProjectPath);
            }
            else
            {
                TargetsDllFilename = CommandUtils.CombinePaths(RulesFolder, String.Format("UATRules{0}.dll", "_BaseEngine_"));
            }
            RulesCompiler.SetAssemblyNameAndGameFolders(TargetsDllFilename, GameFolders);

            // the UBT code assumes a certain CWD, but artists don't have this CWD.
            var  SourceDir = CommandUtils.CombinePaths(CommandUtils.CmdEnv.LocalRoot, "Engine", "Source");
            bool DirPushed = false;

            if (CommandUtils.DirectoryExists_NoExceptions(SourceDir))
            {
                CommandUtils.PushDir(SourceDir);
                DirPushed = true;
            }
            var TargetScripts = RulesCompiler.FindAllRulesSourceFiles(RulesCompiler.RulesFileType.Target, ExtraSearchPaths);

            if (DirPushed)
            {
                CommandUtils.PopDir();
            }

            if (!CommandUtils.IsNullOrEmpty(TargetScripts))
            {
                // We only care about project target script so filter out any scripts not in the project folder, or take them all if we are just doing engine stuff
                var ProjectTargetScripts = new List <string>();
                foreach (var Filename in TargetScripts)
                {
                    var FullScriptPath = CommandUtils.CombinePaths(Path.GetFullPath(Filename));
                    if (FullProjectPath == null || FullScriptPath.StartsWith(FullProjectPath, StringComparison.InvariantCultureIgnoreCase))
                    {
                        ProjectTargetScripts.Add(FullScriptPath);
                    }
                }
                TargetScripts = ProjectTargetScripts;
            }

            if (!CommandUtils.IsNullOrEmpty(TargetScripts))
            {
                CommandUtils.LogVerbose("Found {0} target rule files:", TargetScripts.Count);
                foreach (var Filename in TargetScripts)
                {
                    CommandUtils.LogVerbose("  {0}", Filename);
                }

                // Check if the scripts require compilation
                bool DoNotCompile = false;
                if (!CommandUtils.IsBuildMachine && !CheckIfScriptAssemblyIsOutOfDate(TargetsDllFilename, TargetScripts))
                {
                    Log.TraceInformation("Targets DLL {0} is up to date.", TargetsDllFilename);
                    DoNotCompile = true;
                }
                if (!DoNotCompile && CommandUtils.FileExists_NoExceptions(TargetsDllFilename))
                {
                    if (!CommandUtils.DeleteFile_NoExceptions(TargetsDllFilename, true))
                    {
                        DoNotCompile = true;
                        CommandUtils.Log("Could not delete {0} assuming it is up to date and reusable for a recursive UAT call.", TargetsDllFilename);
                    }
                }

                CompileAndLoadTargetsAssembly(Properties, TargetsDllFilename, DoNotCompile, TargetScripts);
            }
        }