예제 #1
0
 public static void CopyFile(string Source, string Dest, bool bIsUpload)
 {
     if (RemoteToolChain.bUseRPCUtil)
     {
         if (bIsUpload)
         {
             RPCUtility.CommandHelper.RPCUpload(GetSocket(), Source, Dest);
         }
         else
         {
             RPCUtility.CommandHelper.RPCDownload(GetSocket(), Source, Dest);
         }
     }
     else
     {
         if (bIsUpload)
         {
             RemoteToolChain.UploadFile(Source, Dest);
         }
         else
         {
             RemoteToolChain.DownloadFile(Source, Dest);
         }
     }
 }
        protected void AddPrerequisiteSourceFile(UEBuildTarget Target, UEBuildPlatform BuildPlatform, CPPEnvironment CompileEnvironment, FileItem SourceFile, List <FileItem> PrerequisiteItems)
        {
            PrerequisiteItems.Add(SourceFile);

            RemoteToolChain RemoteThis      = this as RemoteToolChain;
            bool            bAllowUploading = RemoteThis != null && BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Mac;     // Don't use remote features when compiling from a Mac

            if (bAllowUploading)
            {
                RemoteThis.QueueFileForBatchUpload(SourceFile);
            }

            if (!BuildConfiguration.bUseUBTMakefiles)                   // In fast build iteration mode, we'll gather includes later on
            {
                // @todo ubtmake: What if one of the prerequisite files has become missing since it was updated in our cache? (usually, because a coder eliminated the source file)
                //		-> Two CASES:
                //				1) NOT WORKING: Non-unity file went away (SourceFile in this context).  That seems like an existing old use case.  Compile params or Response file should have changed?
                //				2) WORKING: Indirect file went away (unity'd original source file or include).  This would return a file that no longer exists and adds to the prerequiteitems list
                List <FileItem> IncludedFileList = CPPEnvironment.FindAndCacheAllIncludedFiles(Target, SourceFile, BuildPlatform, CompileEnvironment.Config.CPPIncludeInfo, bOnlyCachedDependencies: BuildConfiguration.bUseUBTMakefiles);
                if (IncludedFileList != null)
                {
                    foreach (FileItem IncludedFile in IncludedFileList)
                    {
                        PrerequisiteItems.Add(IncludedFile);

                        if (bAllowUploading &&
                            !BuildConfiguration.bUseUBTMakefiles)                               // With fast dependency scanning, we will not have an exhaustive list of dependencies here.  We rely on PostCodeGeneration() to upload these files.
                        {
                            RemoteThis.QueueFileForBatchUpload(IncludedFile);
                        }
                    }
                }
            }
        }
예제 #3
0
        public static Hashtable Command(string WorkingDirectory, string Command, string CommandArgs, string RemoteOutputPath)
        {
            if (RemoteToolChain.bUseRPCUtil)
            {
                int RetriesRemaining = 6;
                do
                {
                    // a $ on the commandline will actually be converted, so we need to quote it
                    CommandArgs = CommandArgs.Replace("$", "\\$");

                    try
                    {
                        Hashtable Results = RPCUtility.CommandHelper.RPCCommand(GetSocket(), WorkingDirectory, Command, CommandArgs, RemoteOutputPath);
                        return(Results);
                    }
                    catch (Exception Ex)
                    {
                        if (RetriesRemaining > 0)
                        {
                            Int32 RetryTimeoutMS = 1000;
                            Debug.WriteLine("Retrying command after sleeping for " + RetryTimeoutMS + " milliseconds. Command is:" + Command + " " + CommandArgs);
                            Thread.Sleep(RetryTimeoutMS);
                        }
                        else
                        {
                            Log.TraceInformation("Out of retries, too many exceptions:" + Ex.ToString());
                            // We've tried enough times, just throw the error
                            throw new Exception("Deep Exception, retries exhausted... ", Ex);
                        }
                        RetriesRemaining--;
                    }
                }while (RetriesRemaining > 0);

                return(null);
            }
            else
            {
                return(RemoteToolChain.SSHCommand(WorkingDirectory, Command + " " + CommandArgs, RemoteOutputPath));
            }
        }
예제 #4
0
        public static void BatchFileInfo(FileItem[] Files)
        {
            if (RemoteToolChain.bUseRPCUtil)
            {
                // build a list of file paths to get info about
                StringBuilder FileList = new StringBuilder();
                foreach (FileItem File in Files)
                {
                    FileList.AppendFormat("{0}\n", File.AbsolutePath);
                }

                DateTime Now = DateTime.Now;

                // execute the command!
                Int64[] FileSizeAndDates = RPCUtility.CommandHelper.RPCBatchFileInfo(GetSocket(), FileList.ToString());

                Console.WriteLine("BatchFileInfo version 1 took {0}", (DateTime.Now - Now).ToString());

                // now update the source times
                for (int Index = 0; Index < Files.Length; Index++)
                {
                    Files[Index].Length        = FileSizeAndDates[Index * 2 + 0];
                    Files[Index].LastWriteTime = new DateTimeOffset(RPCUtility.CommandHelper.FromRemoteTime(FileSizeAndDates[Index * 2 + 1]));
                    Files[Index].bExists       = FileSizeAndDates[Index * 2 + 0] >= 0;
                }
            }
            else
            {
                // build a list of file paths to get info about
                StringBuilder Commands = new StringBuilder();
                Commands.Append("#!/bin/bash\n");
                foreach (FileItem File in Files)
                {
                    Commands.AppendFormat("if [ -e \"{0}\" ]; then eval $(stat -s \"{0}\") && echo $st_mtime && echo $st_size; else echo 0 && echo -1; fi\n", File.AbsolutePath);
                }

                // write out locally
                string LocalCommandsFile = Path.GetTempFileName();
                System.IO.File.WriteAllText(LocalCommandsFile, Commands.ToString());

                string RemoteDir          = "/var/tmp/" + Environment.MachineName;
                string RemoteCommandsFile = Path.GetFileName(LocalCommandsFile) + ".sh";

                DateTime Now = DateTime.Now;
                RemoteToolChain.UploadFile(LocalCommandsFile, RemoteDir + "/" + RemoteCommandsFile);

                // execute the file, not a commandline
                Hashtable Results = Command(RemoteDir, "sh", RemoteCommandsFile + " && rm " + RemoteCommandsFile, null);

                Console.WriteLine("BatchFileInfo took {0}", (DateTime.Now - Now).ToString());

                string[] Lines = ((string)Results["CommandOutput"]).Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                if (Lines.Length != Files.Length * 2)
                {
                    throw new BuildException("Received the wrong number of results from BatchFileInfo");
                }

                for (int Index = 0; Index < Files.Length; Index++)
                {
                    Files[Index].LastWriteTime = new DateTimeOffset(RemoteToLocalTime(Lines[Index * 2 + 0]));
                    Files[Index].Length        = long.Parse(Lines[Index * 2 + 1]);
                    Files[Index].bExists       = Files[Index].Length >= 0;
                }
            }
        }
예제 #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="RemotePath"></param>
 /// <returns></returns>
 public static string UnconvertPath(string RemotePath)
 {
     return(RemoteToolChain.UnconvertPath(RemotePath));
 }
예제 #6
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public static string ConvertPath(string Path)
 {
     return(RemoteToolChain.ConvertPath(Path));
 }