public int ArchiveFiles(string InPath, string Wildcard = "*", bool bRecursive = true, string[] ExcludeWildcard = null, string NewPath = null) { int FilesAdded = 0; if (CommandUtils.DirectoryExists(InPath)) { var All = CommandUtils.FindFiles(Wildcard, bRecursive, InPath); var Exclude = new HashSet <string>(); if (ExcludeWildcard != null) { foreach (var Excl in ExcludeWildcard) { var Remove = CommandUtils.FindFiles(Excl, bRecursive, InPath); foreach (var File in Remove) { Exclude.Add(CommandUtils.CombinePaths(File)); } } } foreach (var AllFile in All) { var FileToCopy = CommandUtils.CombinePaths(AllFile); if (Exclude.Contains(FileToCopy)) { continue; } if (!bIsCombiningMultiplePlatforms) { FileReference InputFile = new FileReference(FileToCopy); bool OtherPlatform = false; foreach (UnrealTargetPlatform Plat in Enum.GetValues(typeof(UnrealTargetPlatform))) { if (Plat != StageTargetPlatform.PlatformType && Plat != UnrealTargetPlatform.Unknown) { var Search = FileToCopy; if (InputFile.IsUnderDirectory(LocalRoot)) { Search = InputFile.MakeRelativeTo(LocalRoot); } else if (InputFile.IsUnderDirectory(ProjectRoot)) { Search = InputFile.MakeRelativeTo(ProjectRoot); } if (Search.IndexOf(CommandUtils.CombinePaths("/" + Plat.ToString() + "/"), 0, StringComparison.InvariantCultureIgnoreCase) >= 0) { OtherPlatform = true; break; } } } if (OtherPlatform) { continue; } } string Dest; if (!FileToCopy.StartsWith(InPath)) { throw new AutomationException("Can't archive {0}; it was supposed to start with {1}", FileToCopy, InPath); } // If the specified a new directory, first we deal with that, then apply the other things // this is used to collapse the sandbox, among other things if (NewPath != null) { Dest = FileToCopy.Substring(InPath.Length); if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } Dest = CommandUtils.CombinePaths(NewPath, Dest); } else { Dest = FileToCopy.Substring(InPath.Length); } if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } if (ArchivedFiles.ContainsKey(FileToCopy)) { if (ArchivedFiles[FileToCopy] != Dest) { throw new AutomationException("Can't archive {0}: it was already in the files to archive with a different destination '{1}'", FileToCopy, Dest); } } else { ArchivedFiles.Add(FileToCopy, Dest); } FilesAdded++; } } return(FilesAdded); }
public void StageFiles(StagedFileType FileType, string InPath, string Wildcard = "*", bool bRecursive = true, string[] ExcludeWildcard = null, string NewPath = null, bool bAllowNone = false, bool bRemap = true, string NewName = null, bool bAllowNotForLicenseesFiles = true, bool bStripFilesForOtherPlatforms = true, bool bConvertToLower = false) { int FilesAdded = 0; // make sure any ..'s are removed Utils.CollapseRelativeDirectories(ref InPath); if (CommandUtils.DirectoryExists(InPath)) { var All = CommandUtils.FindFiles(Wildcard, bRecursive, InPath); var Exclude = new HashSet <string>(); if (ExcludeWildcard != null) { foreach (var Excl in ExcludeWildcard) { var Remove = CommandUtils.FindFiles(Excl, bRecursive, InPath); foreach (var File in Remove) { Exclude.Add(CommandUtils.CombinePaths(File)); } } } foreach (var AllFile in All) { var FileToCopy = CommandUtils.CombinePaths(AllFile); if (Exclude.Contains(FileToCopy)) { continue; } if (!bAllowNotForLicenseesFiles && (FileToCopy.Contains("NotForLicensees") || FileToCopy.Contains("NoRedist"))) { continue; } if (bStripFilesForOtherPlatforms && !bIsCombiningMultiplePlatforms) { bool OtherPlatform = false; foreach (UnrealTargetPlatform Plat in Enum.GetValues(typeof(UnrealTargetPlatform))) { bool bMatchesIniPlatform = (AllFile.EndsWith(".ini") && Plat == StageTargetPlatform.IniPlatformType); // filter ini files for the ini file platform bool bMatchesTargetPlatform = (Plat == StageTargetPlatform.PlatformType || Plat == UnrealTargetPlatform.Unknown); // filter platform files for the target platform if (!bMatchesIniPlatform && !bMatchesTargetPlatform) { var Search = FileToCopy; if (Search.StartsWith(LocalRoot, StringComparison.InvariantCultureIgnoreCase)) { if (LocalRoot.EndsWith("\\") || LocalRoot.EndsWith("/")) { Search = Search.Substring(LocalRoot.Length - 1); } else { Search = Search.Substring(LocalRoot.Length); } } if (Search.StartsWith(ProjectRoot, StringComparison.InvariantCultureIgnoreCase)) { if (ProjectRoot.EndsWith("\\") || ProjectRoot.EndsWith("/")) { Search = Search.Substring(ProjectRoot.Length - 1); } else { Search = Search.Substring(ProjectRoot.Length); } } if (Search.IndexOf(CommandUtils.CombinePaths("/" + Plat.ToString() + "/"), 0, StringComparison.InvariantCultureIgnoreCase) >= 0) { OtherPlatform = true; break; } } } if (OtherPlatform) { continue; } } string Dest; if (!FileToCopy.StartsWith(InPath)) { throw new AutomationException("Can't deploy {0}; it was supposed to start with {1}", FileToCopy, InPath); } string FileToRemap = FileToCopy; // If the specified a new directory, first we deal with that, then apply the other things // this is used to collapse the sandbox, among other things if (NewPath != null) { Dest = FileToRemap.Substring(InPath.Length); if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } Dest = CommandUtils.CombinePaths(NewPath, Dest); #if false // if the cooker rebases, I don't think we need to ever rebase while staging to a new path if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } // project relative stuff in a collapsed sandbox if (Dest.StartsWith(SourceRelativeProjectRoot, StringComparison.InvariantCultureIgnoreCase)) { Dest = Dest.Substring(SourceRelativeProjectRoot.Length); if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } Dest = CommandUtils.CombinePaths(RelativeProjectRootForStage, Dest); } #endif } // project relative file else if (FileToRemap.StartsWith(ProjectRoot, StringComparison.InvariantCultureIgnoreCase)) { Dest = FileToRemap.Substring(ProjectRoot.Length); if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } Dest = CommandUtils.CombinePaths(RelativeProjectRootForStage, Dest); } // engine relative file else if (FileToRemap.StartsWith(LocalRoot, StringComparison.InvariantCultureIgnoreCase)) { Dest = CommandUtils.CombinePaths(FileToRemap.Substring(LocalRoot.Length)); } else { throw new AutomationException("Can't deploy {0} because it doesn't start with {1} or {2}", FileToRemap, ProjectRoot, LocalRoot); } if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } if (NewName != null) { Dest = CommandUtils.CombinePaths(Path.GetDirectoryName(Dest), NewName); } if (bRemap) { Dest = StageTargetPlatform.Remap(Dest); } if (bConvertToLower) { Dest = Dest.ToLowerInvariant(); } if (FileType == StagedFileType.UFS) { AddUniqueStagingFile(UFSStagingFiles, FileToCopy, Dest); } else if (FileType == StagedFileType.NonUFS) { AddStagingFile(NonUFSStagingFiles, FileToCopy, Dest); } else if (FileType == StagedFileType.DebugNonUFS) { AddStagingFile(NonUFSStagingFilesDebug, FileToCopy, Dest); } FilesAdded++; } } if (FilesAdded == 0 && !bAllowNone && !bIsCombiningMultiplePlatforms) { throw new AutomationException(ExitCode.Error_StageMissingFile, "No files found to deploy for {0} with wildcard {1} and exclusions {2}", InPath, Wildcard, ExcludeWildcard); } }
public void StageFiles(StagedFileType FileType, DirectoryReference InputDir, string Wildcard = "*", bool bRecursive = true, string[] ExcludeWildcards = null, StagedDirectoryReference NewPath = null, bool bAllowNone = false, bool bRemap = true, string NewName = null, bool bAllowNotForLicenseesFiles = true, bool bStripFilesForOtherPlatforms = true, bool bConvertToLower = false) { int FilesAdded = 0; if (DirectoryReference.Exists(InputDir)) { FileReference[] InputFiles = CommandUtils.FindFiles(Wildcard, bRecursive, InputDir); HashSet <FileReference> ExcludeFiles = new HashSet <FileReference>(); if (ExcludeWildcards != null) { foreach (string ExcludeWildcard in ExcludeWildcards) { ExcludeFiles.UnionWith(CommandUtils.FindFiles(ExcludeWildcard, bRecursive, InputDir)); } } foreach (FileReference InputFile in InputFiles) { if (ExcludeFiles.Contains(InputFile)) { continue; } if (bStripFilesForOtherPlatforms && !bIsCombiningMultiplePlatforms && IsFileForOtherPlatform(InputFile)) { continue; } // Get the staged location for this file StagedFileReference Dest; if (NewPath != null) { // If the specified a new directory, first we deal with that, then apply the other things. This is used to collapse the sandbox, among other things. Dest = StagedFileReference.Combine(NewPath, InputFile.MakeRelativeTo(InputDir)); } else if (InputFile.IsUnderDirectory(ProjectRoot)) { // Project relative file Dest = StagedFileReference.Combine(RelativeProjectRootForStage, InputFile.MakeRelativeTo(ProjectRoot)); } else if (InputFile.IsUnderDirectory(LocalRoot)) { // Engine relative file Dest = new StagedFileReference(InputFile.MakeRelativeTo(LocalRoot)); } else { throw new AutomationException("Can't deploy {0} because it doesn't start with {1} or {2}", InputFile, ProjectRoot, LocalRoot); } if (!bAllowNotForLicenseesFiles && (Dest.ContainsName(new FileSystemName("NotForLicensees")) || Dest.ContainsName(new FileSystemName("NoRedist")))) { continue; } if (NewName != null) { Dest = StagedFileReference.Combine(Dest.Directory, NewName); } if (bRemap) { Dest = StageTargetPlatform.Remap(Dest); } if (bConvertToLower) { Dest = Dest.ToLowerInvariant(); } FilesToStage.Add(FileType, Dest, InputFile); FilesAdded++; } } if (FilesAdded == 0 && !bAllowNone && !bIsCombiningMultiplePlatforms) { throw new AutomationException(ExitCode.Error_StageMissingFile, "No files found to deploy for {0} with wildcard {1} and exclusions {2}", InputDir, Wildcard, String.Join(", ", ExcludeWildcards)); } }
public int ArchiveFiles(string InPath, string Wildcard = "*", bool bRecursive = true, string[] ExcludeWildcard = null) { int FilesAdded = 0; if (CommandUtils.DirectoryExists(InPath)) { var All = CommandUtils.FindFiles(Wildcard, bRecursive, InPath); var Exclude = new HashSet <string>(); if (ExcludeWildcard != null) { foreach (var Excl in ExcludeWildcard) { var Remove = CommandUtils.FindFiles(Excl, bRecursive, InPath); foreach (var File in Remove) { Exclude.Add(CommandUtils.CombinePaths(File)); } } } foreach (var AllFile in All) { var FileToCopy = CommandUtils.CombinePaths(AllFile); if (Exclude.Contains(FileToCopy)) { continue; } bool OtherPlatform = false; foreach (UnrealTargetPlatform Plat in Enum.GetValues(typeof(UnrealTargetPlatform))) { if (Plat != StageTargetPlatform.PlatformType && Plat != UnrealTargetPlatform.Unknown && FileToCopy.IndexOf(CommandUtils.CombinePaths("/" + Plat.ToString() + "/"), 0, StringComparison.InvariantCultureIgnoreCase) >= 0) { OtherPlatform = true; break; } } if (OtherPlatform) { continue; } string Dest; if (!FileToCopy.StartsWith(InPath)) { throw new AutomationException("Can't archive {0}; it was supposed to start with {1}", FileToCopy, InPath); } Dest = FileToCopy.Substring(InPath.Length); if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } ArchivedFiles.Add(FileToCopy, Dest); FilesAdded++; } } return(FilesAdded); }
public int ArchiveFiles(string InPath, string Wildcard = "*", bool bRecursive = true, string[] ExcludeWildcard = null) { int FilesAdded = 0; if (CommandUtils.DirectoryExists(InPath)) { var All = CommandUtils.FindFiles(Wildcard, bRecursive, InPath); var Exclude = new HashSet <string>(); if (ExcludeWildcard != null) { foreach (var Excl in ExcludeWildcard) { var Remove = CommandUtils.FindFiles(Excl, bRecursive, InPath); foreach (var File in Remove) { Exclude.Add(CommandUtils.CombinePaths(File)); } } } foreach (var AllFile in All) { var FileToCopy = CommandUtils.CombinePaths(AllFile); if (Exclude.Contains(FileToCopy)) { continue; } if (!bIsCombiningMultiplePlatforms) { bool OtherPlatform = false; foreach (UnrealTargetPlatform Plat in Enum.GetValues(typeof(UnrealTargetPlatform))) { if (Plat != StageTargetPlatform.PlatformType && Plat != UnrealTargetPlatform.Unknown) { var Search = FileToCopy; if (Search.StartsWith(LocalRoot, StringComparison.InvariantCultureIgnoreCase)) { if (LocalRoot.EndsWith("\\") || LocalRoot.EndsWith("/")) { Search = Search.Substring(LocalRoot.Length - 1); } else { Search = Search.Substring(LocalRoot.Length); } } if (Search.StartsWith(ProjectRoot, StringComparison.InvariantCultureIgnoreCase)) { if (ProjectRoot.EndsWith("\\") || ProjectRoot.EndsWith("/")) { Search = Search.Substring(ProjectRoot.Length - 1); } else { Search = Search.Substring(ProjectRoot.Length); } } if (Search.IndexOf(CommandUtils.CombinePaths("/" + Plat.ToString() + "/"), 0, StringComparison.InvariantCultureIgnoreCase) >= 0) { OtherPlatform = true; break; } } } if (OtherPlatform) { continue; } } string Dest; if (!FileToCopy.StartsWith(InPath)) { throw new AutomationException("Can't archive {0}; it was supposed to start with {1}", FileToCopy, InPath); } Dest = FileToCopy.Substring(InPath.Length); if (Dest.StartsWith("/") || Dest.StartsWith("\\")) { Dest = Dest.Substring(1); } if (ArchivedFiles.ContainsKey(FileToCopy)) { if (ArchivedFiles[FileToCopy] != Dest) { throw new AutomationException("Can't archive {0}: it was already in the files to archive with a different destination '{1}'", FileToCopy, Dest); } } else { ArchivedFiles.Add(FileToCopy, Dest); } FilesAdded++; } } return(FilesAdded); }