#pragma warning restore CS0168 // Variable is declared but never used

        private void StreamReaderThread()
        {
            while (true)
            {
                ValidateConnection();
                try
                {
                    var lines = ReadLines();
                    foreach (var line in lines)
                    {
                        System.Diagnostics.Debug.WriteLine(line);
                        LineRead?.Invoke(line);
                    }
                    Thread.Sleep(10);
                }
                // As far as i can tell there isn't a way to handle the socket exception without a try catch.
                // it might just be that valve f****d it up on their end.
                catch (Exception)
                {
                    return;
                }
            }
        }
Exemple #2
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);
        }
Exemple #3
0
        /// <summary>
        /// Discover and fill in the project info
        /// </summary>
        public static void FillProjectInfo()
        {
            DateTime StartTime = DateTime.Now;

            List <string> DirectoriesToSearch = new List <string>();

            // Find all the .uprojectdirs files contained in the root folder and add their entries to the search array
            string RootDirectory         = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetOriginalLocation()), "..", "..", "..");
            string EngineSourceDirectory = Path.GetFullPath(Path.Combine(RootDirectory, "Engine", "Source"));

            foreach (string File in Directory.EnumerateFiles(RootDirectory, "*.uprojectdirs", SearchOption.TopDirectoryOnly))
            {
                string FilePath = Path.GetFullPath(File);
                Log.TraceVerbose("\tFound uprojectdirs file {0}", FilePath);

                using (StreamReader Reader = new StreamReader(FilePath))
                {
                    string LineRead;
                    while ((LineRead = Reader.ReadLine()) != null)
                    {
                        string ProjDirEntry = LineRead.Trim();
                        if (String.IsNullOrEmpty(ProjDirEntry) == false)
                        {
                            if (ProjDirEntry.StartsWith(";"))
                            {
                                // Commented out line... skip it
                                continue;
                            }
                            else
                            {
                                string DirPath = Path.GetFullPath(Path.Combine(RootDirectory, ProjDirEntry));
                                DirectoriesToSearch.Add(DirPath);
                            }
                        }
                    }
                }
            }

            Log.TraceVerbose("\tFound {0} directories to search", DirectoriesToSearch.Count);

            foreach (string DirToSearch in DirectoriesToSearch)
            {
                Log.TraceVerbose("\t\tSearching {0}", DirToSearch);
                if (Directory.Exists(DirToSearch))
                {
                    foreach (string SubDir in Directory.EnumerateDirectories(DirToSearch, "*", SearchOption.TopDirectoryOnly))
                    {
                        Log.TraceVerbose("\t\t\tFound subdir {0}", SubDir);
                        string[] SubDirFiles = Directory.GetFiles(SubDir, "*.uproject", SearchOption.TopDirectoryOnly);
                        foreach (string UProjFile in SubDirFiles)
                        {
                            Log.TraceVerbose("\t\t\t\t{0}", UProjFile);
                            AddProject(new FileReference(UProjFile));
                        }
                    }
                }
                else
                {
                    Log.TraceVerbose("ProjectInfo: Skipping directory {0} from .uprojectdirs file as it doesn't exist.", DirToSearch);
                }
            }

            DateTime StopTime = DateTime.Now;

            if (BuildConfiguration.bPrintPerformanceInfo)
            {
                TimeSpan TotalProjectInfoTime = StopTime - StartTime;
                Log.TraceInformation("FillProjectInfo took {0} milliseconds", TotalProjectInfoTime.Milliseconds);
            }

            if (UnrealBuildTool.CommandLineContains("-dumpprojectinfo"))
            {
                UProjectInfo.DumpProjectInfo();
            }
        }
Exemple #4
0
 private void OnOutputDataReceived(object sender, DataReceivedEventArgs e)
 {
     LineRead?.Invoke(sender, new LineReadEventArgs(e.Data));
 }
Exemple #5
0
 private void RaiseReadLine(string logLine)
 {
     LineRead?.Invoke(logLine);
 }
Exemple #6
0
 public static void LineRed(string s)
 {
     LineRead?.Invoke(s);
 }
Exemple #7
0
        /// <summary>
        /// Discover and fill in the project info
        /// </summary>
        public static void FillProjectInfo()
        {
            DateTime StartTime = DateTime.Now;

            List <string> DirectoriesToSearch = new List <string>();

            // Find all the .uprojectdirs files contained in the root folder and add their entries to the search array
            string RootDirectory         = Path.Combine(Utils.GetExecutingAssemblyDirectory(), "..", "..", "..");
            string EngineSourceDirectory = Path.GetFullPath(Path.Combine(RootDirectory, "Engine", "Source"));

            foreach (var File in Directory.EnumerateFiles(RootDirectory, "*.uprojectdirs", SearchOption.TopDirectoryOnly))
            {
                string FilePath = Path.GetFullPath(File);
                Log.TraceVerbose("\tFound uprojectdirs file {0}", FilePath);

                using (StreamReader Reader = new StreamReader(FilePath))
                {
                    string LineRead;
                    while ((LineRead = Reader.ReadLine()) != null)
                    {
                        string ProjDirEntry = LineRead.Trim();
                        if (String.IsNullOrEmpty(ProjDirEntry) == false)
                        {
                            if (ProjDirEntry.StartsWith(";"))
                            {
                                // Commented out line... skip it
                                continue;
                            }
                            else
                            {
                                string DirPath = Path.GetFullPath(Path.Combine(RootDirectory, ProjDirEntry));
                                DirectoriesToSearch.Add(DirPath);
                            }
                        }
                    }
                }
            }

            Log.TraceVerbose("\tFound {0} directories to search", DirectoriesToSearch.Count);

            // Initialize the target finding time to 0
            TimeSpan TotalTargetTime = DateTime.Now - DateTime.Now;

            foreach (string DirToSearch in DirectoriesToSearch)
            {
                Log.TraceVerbose("\t\tSearching {0}", DirToSearch);
                if (Directory.Exists(DirToSearch))
                {
                    foreach (string SubDir in Directory.EnumerateDirectories(DirToSearch, "*", SearchOption.TopDirectoryOnly))
                    {
                        Log.TraceVerbose("\t\t\tFound subdir {0}", SubDir);
                        string[] SubDirFiles = Directory.GetFiles(SubDir, "*.uproject", SearchOption.TopDirectoryOnly);
                        foreach (string UProjFile in SubDirFiles)
                        {
                            string RelativePath = Utils.MakePathRelativeTo(UProjFile, EngineSourceDirectory);
                            Log.TraceVerbose("\t\t\t\t{0}", RelativePath);
                            if (!ProjectInfoDictionary.ContainsKey(RelativePath))
                            {
                                DateTime TargetStartTime = DateTime.Now;

                                string SourceFolder   = Path.Combine(Path.GetDirectoryName(UProjFile), "Source");
                                bool   bIsCodeProject = Directory.Exists(SourceFolder);

                                AddProject(RelativePath, bIsCodeProject);

                                if (bIsCodeProject)
                                {
                                    // Find all Target.cs files
                                    bool bFoundTargetFiles = false;
                                    if (!FindTargetFiles(SourceFolder, ref bFoundTargetFiles))
                                    {
                                        Log.TraceVerbose("No target files found under " + SourceFolder);
                                    }
                                }

                                DateTime TargetStopTime = DateTime.Now;

                                TotalTargetTime += TargetStopTime - TargetStartTime;
                            }
                        }
                    }
                }
                else
                {
                    Log.TraceVerbose("ProjectInfo: Skipping directory {0} from .uprojectdirs file as it doesn't exist.", DirToSearch);
                }
            }

            DateTime StopTime = DateTime.Now;

            if (BuildConfiguration.bPrintPerformanceInfo)
            {
                TimeSpan TotalProjectInfoTime = StopTime - StartTime;
                Log.TraceInformation("FillProjectInfo took {0} milliseconds (AddTargetInfo {1} ms)",
                                     TotalProjectInfoTime.Milliseconds, TotalTargetTime.Milliseconds);
            }

            if (UnrealBuildTool.CommandLineContains("-dumpprojectinfo"))
            {
                UProjectInfo.DumpProjectInfo();
            }
        }
Exemple #8
0
        /// <summary>
        /// Load a certificate from file. This will first try to open the secret file by append _secret to the
        /// file name (filename + "_secret"). If the secret file isn't found only the public key is loaded and the secret key will contain 32 zeros.
        /// </summary>
        /// <param name="filename">Filename (excluding the "_secret" ending).</param>
        /// <returns>Return the loaded certificate. OBS! null is returned if the file isn't found.</returns>
        public static ZCert Load(string filename)
        {
            ZCert cert = new ZCert();
            //  Try first to load secret certificate, which has both keys
            //  Then fallback to loading public certificate
            string         filenameSecret = filename + "_secret";
            Queue <string> lines;

            if (File.Exists(filenameSecret))
            {
                lines = new Queue <string>(File.ReadAllLines(filenameSecret).ToList());
            }
            else if (File.Exists(filename))
            {
                lines = new Queue <string>(File.ReadAllLines(filename).ToList());
            }
            else
            {
                return(null);
            }
            LineRead reader = null;

            while (lines.Count > 0)
            {
                string line = lines.Dequeue();
                if (line.TrimStart().StartsWith("#"))
                {
                    continue;
                }
                if (line.TrimStart().StartsWith("metadata"))
                {
                    reader = (str, c) =>
                    {
                        string[] metadata = Split(str);
                        if (metadata.Length == 2)
                        {
                            c.SetMeta(metadata[0].Trim(), metadata[1].Trim(new char[] { '"', ' ', '\t' }));
                        }
                    };
                }
                if (line.TrimStart().StartsWith("curve"))
                {
                    reader = (str, c) =>
                    {
                        var key = Split(str);
                        if (key.Length == 2)
                        {
                            if (key[0].Trim() == "public-key")
                            {
                                c.PublicTxt = key[1].Trim(new char[] { '"', ' ', '\t' });
                            }
                            if (key[0].Trim() == "secret-key")
                            {
                                c.SecretTxt = key[1].Trim(new char[] { '"', ' ', '\t' });
                            }
                        }
                    };
                }
                if (reader != null)
                {
                    reader(line, cert);
                }
            }
            return(cert);
        }
 public GoogleTestOutputParser(TestComplete a, LineRead b)
 {
     notifyTestComplete = a;
     notifyLineRead = b;
 }
Exemple #10
0
 public GoogleTestOutputParser(TestComplete a, LineRead b)
 {
     notifyTestComplete = a;
     notifyLineRead     = b;
 }