/// <summary> /// Sets the location of the exe. /// </summary> protected void SetUATLocation() { if (String.IsNullOrEmpty(UATExe)) { UATExe = CommandUtils.CombinePaths(Path.GetFullPath(InternalUtils.ExecutingAssemblyLocation)); } if (!CommandUtils.FileExists_NoExceptions(UATExe)) { throw new AutomationException("Could not find AutomationTool.exe. Reflection indicated it was here: {0}", UATExe); } }
public override string GetMsBuildExe() { var DotNETToolsFolder = CommandUtils.CombinePaths(CommandUtils.GetEnvVar(EnvVarNames.NETFrameworkDir), CommandUtils.GetEnvVar(EnvVarNames.NETFrameworkVersion)); var MsBuildExe = CommandUtils.CombinePaths(DotNETToolsFolder, "MSBuild.exe"); if (!CommandUtils.FileExists_NoExceptions(MsBuildExe)) { throw new NotSupportedException("MsBuild.exe does not exist."); } return(MsBuildExe); }
/// <summary> /// Sets the location of the exe. /// </summary> protected void SetUATLocation() { if (String.IsNullOrEmpty(UATExe)) { UATExe = Assembly.GetEntryAssembly().GetOriginalLocation(); } if (!CommandUtils.FileExists_NoExceptions(UATExe)) { throw new AutomationException("Could not find AutomationTool.exe. Reflection indicated it was here: {0}", UATExe); } }
public BranchUProject(FileReference ProjectFile) { GameName = ProjectFile.GetFileNameWithoutExtension(); //not sure what the heck this path is relative to FilePath = ProjectFile; if (!CommandUtils.FileExists_NoExceptions(FilePath.FullName)) { throw new AutomationException("Could not resolve relative path corrctly {0} -> {1} which doesn't exist.", ProjectFile, FilePath); } }
/// <summary> /// Makes a version file writeable. If P4 is enabled, syncs it to revision 0 to prevent conflicts with the P4 have table rather than checking it out, since we never intend to /// submit it to Perforce. For existing writeable files, P4V prompts the user to overwrite the next time they sync. /// </summary> /// <param name="FileName">The file to make writeable</param> public static void MakeFileWriteable(string FileName) { if (CommandUtils.IsReadOnly(FileName)) { if (CommandUtils.P4Enabled) { CommandUtils.P4.Sync(String.Format("\"{0}#0\"", FileName), false, false); } if (CommandUtils.FileExists_NoExceptions(FileName) && CommandUtils.IsReadOnly(FileName)) { throw new AutomationException("Cannot write to {0}; file is read-only", FileName); } } }
public BranchUProject(UnrealBuildTool.UProjectInfo InfoEntry) { GameName = InfoEntry.GameName; //not sure what the heck this path is relative to FilePath = InfoEntry.FilePath; if (!CommandUtils.FileExists_NoExceptions(FilePath.FullName)) { throw new AutomationException("Could not resolve relative path corrctly {0} -> {1} which doesn't exist.", InfoEntry.FilePath, FilePath); } Properties = ProjectUtils.GetProjectProperties(FilePath); }
public BranchUProject(UnrealBuildTool.UProjectInfo InfoEntry) { GameName = InfoEntry.GameName; //not sure what the heck this path is relative to FilePath = Path.GetFullPath(CommandUtils.CombinePaths(CommandUtils.CmdEnv.LocalRoot, "Engine", "Binaries", InfoEntry.FilePath)); if (!CommandUtils.FileExists_NoExceptions(FilePath)) { throw new AutomationException("Could not resolve relative path corrctly {0} -> {1} which doesn't exist.", InfoEntry.FilePath, FilePath); } Properties = ProjectUtils.GetProjectProperties(Path.GetFullPath(FilePath)); }
public string CopyFileToDest(string FileToCopy, bool MoveSymbols = true) { if (!CommandUtils.FileExists_NoExceptions(FileToCopy)) { throw new AutomationException("Can't distill {0}; it doesn't exist", FileToCopy); } { FileInfo FileInfo = new FileInfo(FileToCopy); FileToCopy = CommandUtils.CombinePaths(FileInfo.FullName); } string Dest; if (MoveSymbols && !String.IsNullOrEmpty(DestBaseDirSymbols) && IsSymbolFile(FileToCopy)) { Dest = CommandUtils.MakeRerootedFilePath(FileToCopy, SourceBaseDir, DestBaseDirSymbols); } else { Dest = CommandUtils.MakeRerootedFilePath(FileToCopy, SourceBaseDir, DestBaseDir); } if (CommandUtils.FileExists_NoExceptions(Dest)) { throw new AutomationException("Can't distill to {0}; it already exists", Dest); } CommandUtils.CopyFile(FileToCopy, Dest); { FileInfo FileInfo = new FileInfo(Dest); FileInfo.IsReadOnly = false; FileInfo.CreationTime = DestinationTime; FileInfo.LastWriteTime = DestinationTime; Dest = CommandUtils.CombinePaths(FileInfo.FullName); } if (!CommandUtils.FileExists_NoExceptions(Dest)) { throw new AutomationException("Couldn't distill {0} to {1}", FileToCopy, Dest); } return(Dest); }
public static void Robust_FileExists(bool bQuiet, string Filename, string Message) { if (!CommandUtils.FileExists_NoExceptions(bQuiet, Filename)) { bool bFound = false; // mac is terrible on shares, this isn't a solution, but a stop gap if (Filename.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}", Filename); System.Threading.Thread.Sleep(10000); bFound = CommandUtils.FileExists_NoExceptions(bQuiet, Filename); Retry++; } } if (!bFound) { throw new AutomationException(Message, Filename); } } }
/// <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); } }
/// <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); } }