Esempio n. 1
0
        /// <summary>
        /// Loads JunkManifest.txt file.
        /// </summary>
        /// <returns>Junk manifest file contents.</returns>
        static private List <string> LoadJunkManifest()
        {
            string        ManifestPath = ".." + Path.DirectorySeparatorChar + "Build" + Path.DirectorySeparatorChar + "JunkManifest.txt";
            List <string> JunkManifest = new List <string>();

            if (File.Exists(ManifestPath))
            {
                string MachineName = Environment.MachineName;
                using (StreamReader reader = new StreamReader(ManifestPath))
                {
                    string CurrentToRootDir = ".." + Path.DirectorySeparatorChar + "..";
                    string LineRead;
                    while ((LineRead = reader.ReadLine()) != null)
                    {
                        string JunkEntry = LineRead.Trim();
                        if (String.IsNullOrEmpty(JunkEntry) == false)
                        {
                            string[] Tokens           = JunkEntry.Split(":".ToCharArray());
                            bool     bIsValidJunkLine = true;
                            foreach (string Token in Tokens)
                            {
                                if (Token.StartsWith("Machine=", StringComparison.InvariantCultureIgnoreCase) == true)
                                {
                                    string[] InnerTokens = Token.Split("=".ToCharArray());
                                    // check if the machine name on the line matches the current machine name, if not, we don't apply this junk
                                    if (InnerTokens.Length == 2 && MachineName.StartsWith(InnerTokens[1]) == false)
                                    {
                                        // Not meant for this machine
                                        bIsValidJunkLine = false;
                                    }
                                }
                                else if (Token.StartsWith("Platform=", StringComparison.InvariantCultureIgnoreCase) == true)
                                {
                                    string[] InnerTokens = Token.Split("=".ToCharArray());
                                    // check if the machine name on the line matches the current machine name, if not, we don't apply this junk
                                    if (InnerTokens.Length == 2)
                                    {
                                        UnrealTargetPlatform ParsedPlatform = UEBuildPlatform.ConvertStringToPlatform(InnerTokens[1]);
                                        // if the platform is valid, then we want to keep the files, which means that we don't want to apply the junk line
                                        if (ParsedPlatform != UnrealTargetPlatform.Unknown)
                                        {
                                            if (UEBuildPlatform.GetBuildPlatform(ParsedPlatform, bInAllowFailure: true) != null)
                                            {
                                                // this is a good platform, so don't delete any files!
                                                bIsValidJunkLine = false;
                                            }
                                        }
                                    }
                                }
                            }

                            // All paths within the manifest are UE4 root directory relative.
                            // UBT's working directory is Engine\Source so add "..\..\" to each of the entires.
                            if (bIsValidJunkLine)
                            {
                                // the entry is always the last element in the token array (after the final :)
                                string FixedPath = Path.Combine(CurrentToRootDir, Tokens[Tokens.Length - 1]);
                                FixedPath = FixedPath.Replace('\\', Path.DirectorySeparatorChar);
                                JunkManifest.Add(FixedPath);
                            }
                        }
                    }
                }
            }
            return(JunkManifest);
        }
Esempio n. 2
0
        public static bool ParseProjectPath(string[] Arguments, out string ProjectPath)
        {
            string TargetName = null;

            foreach (var Argument in Arguments)
            {
                // Treat any platform names as such
                UnrealTargetPlatform ParsedPlatform = UEBuildPlatform.ConvertStringToPlatform(Argument);
                if (ParsedPlatform == UnrealTargetPlatform.Unknown)
                {
                    var ArgUpper = Argument.ToUpperInvariant();
                    switch (ArgUpper)
                    {
                    // Skip any build configurations
                    case "DEBUG":
                    case "DEBUGGAME":
                    case "DEVELOPMENT":
                    case "SHIPPING":
                    case "TEST":
                        break;

                    default:
                        // Ignore any args except -project
                        if (!ArgUpper.StartsWith("-") || ArgUpper.StartsWith("-PROJECT="))
                        {
                            if (ArgUpper.StartsWith("-PROJECT="))
                            {
                                ArgUpper = ArgUpper.Remove(0, 9).Trim();
                            }
                            // If running Rocket, the PossibleTargetName could contain a path
                            TargetName = ArgUpper;

                            // If a project file was not specified see if we can find one
                            string CheckProjectFile = UProjectInfo.GetProjectForTarget(TargetName);
                            if (string.IsNullOrEmpty(CheckProjectFile))
                            {
                                CheckProjectFile = UProjectInfo.GetProjectFilePath(TargetName);
                            }
                            if (string.IsNullOrEmpty(CheckProjectFile) == false)
                            {
                                Log.TraceVerbose("Found project file for {0} - {1}", TargetName, CheckProjectFile);
                                string NewProjectFilename = CheckProjectFile;
                                if (Path.IsPathRooted(NewProjectFilename) == false)
                                {
                                    NewProjectFilename = Path.GetFullPath(NewProjectFilename);
                                }

                                NewProjectFilename = NewProjectFilename.Replace("\\", "/");
                                ProjectPath        = Path.GetDirectoryName(NewProjectFilename);
                                return(true);
                            }

                            if ((TargetName.Contains("/") || TargetName.Contains("\\")) && TargetName.Contains(".UPROJECT"))
                            {
                                // Parse off the path
                                ProjectPath = Path.GetDirectoryName(TargetName);
                                return(true);
                            }
                        }
                        break;
                    }
                }
            }

            ProjectPath = "";
            return(false);
        }