static IEnumerable <FileReference> FilterPluginFiles(FileReference PluginFile, IEnumerable <FileReference> BuildProducts) { // Set up the default filter FileFilter Filter = new FileFilter(); Filter.AddRuleForFile(PluginFile, PluginFile.Directory, FileFilterType.Include); Filter.AddRuleForFiles(BuildProducts, PluginFile.Directory, FileFilterType.Include); Filter.Include("/Binaries/ThirdParty/..."); Filter.Include("/Resources/..."); Filter.Include("/Content/..."); Filter.Include("/Intermediate/Build/.../Inc/..."); Filter.Include("/Shaders/..."); Filter.Include("/Source/..."); // Add custom rules for each platform FileReference FilterFile = FileReference.Combine(PluginFile.Directory, "Config", "FilterPlugin.ini"); if (FileReference.Exists(FilterFile)) { CommandUtils.LogInformation("Reading filter rules from {0}", FilterFile); Filter.ReadRulesFromFile(FilterFile, "FilterPlugin"); } // Apply the standard exclusion rules foreach (string RestrictedFolderName in RestrictedFolder.GetNames()) { Filter.AddRule(String.Format(".../{0}/...", RestrictedFolderName), FileFilterType.Exclude); } // Apply the filter to the plugin directory return(Filter.ApplyToDirectory(PluginFile.Directory, true)); }
static List <string> FilterPluginFiles(string PluginFileName, List <BuildProduct> BuildProducts) { string PluginDirectory = Path.GetDirectoryName(PluginFileName); // Set up the default filter FileFilter Filter = new FileFilter(); Filter.AddRuleForFile(PluginFileName, PluginDirectory, FileFilterType.Include); Filter.AddRuleForFiles(BuildProducts.Select(x => x.Path), PluginDirectory, FileFilterType.Include); Filter.Include("/Resources/..."); Filter.Include("/Content/..."); Filter.Include("/Intermediate/Build/.../Inc/..."); Filter.Include("/Source/..."); // Add custom rules for each platform string FilterFileName = Path.Combine(Path.GetDirectoryName(PluginFileName), "Config", "FilterPlugin.ini"); if (File.Exists(FilterFileName)) { Filter.ReadRulesFromFile(FilterFileName, "FilterPlugin"); } // Apply the standard exclusion rules Filter.ExcludeConfidentialFolders(); Filter.ExcludeConfidentialPlatforms(); // Apply the filter to the plugin directory return(new List <string>(Filter.ApplyToDirectory(PluginDirectory, true))); }
public List<ISharedCookedBuild> FindValidLooseBuilds(string Path, string TargetPlatform) { List<ISharedCookedBuild> ValidBuilds = new List<ISharedCookedBuild>(); Tuple<string, string> SplitPath = SplitOnFixedPrefix(Path); Regex Pattern = RegexFromWildcards(SplitPath.Item2, LocalSync, TargetPlatform); // Search for all available builds const string MetaDataFilename = "\\Metadata\\DevelopmentAssetRegistry.bin"; string BuildRule = SplitPath.Item2 + MetaDataFilename; BuildRule = BuildRule.Replace("[BRANCHNAME]", LocalSync.BranchName); BuildRule = BuildRule.Replace("[PLATFORM]", TargetPlatform); string IncludeRule = BuildRule.Replace("[CL]", "*"); string ExcludeRule = BuildRule.Replace("[CL]", "*-PF-*"); // Exclude preflights FileFilter BuildSearch = new FileFilter(); BuildSearch.AddRule(IncludeRule); BuildSearch.AddRule(ExcludeRule, FileFilterType.Exclude); foreach (FileReference CandidateBuild in BuildSearch.ApplyToDirectory(new DirectoryReference(SplitPath.Item1), false)) { string BaseBuildPath = CandidateBuild.FullName.Replace(MetaDataFilename, ""); Match Match = Pattern.Match(BaseBuildPath); if (Match.Success) { int MatchCL = int.Parse(Match.Result("${CL}")); if (IsValidCL(MatchCL, BuildType, LocalSync)) { ValidBuilds.Add(new LooseSharedCookedBuild { CL = MatchCL, Path = new DirectoryReference(BaseBuildPath), Platform = TargetPlatform }); } } } return ValidBuilds; }
/// <summary> /// Creates a zip file containing the given input files /// </summary> /// <param name="ZipFileName">Filename for the zip</param> /// <param name="Filter">Filter which selects files to be included in the zip</param> /// <param name="BaseDirectory">Base directory to store relative paths in the zip file to</param> /// <param name="CopyModeOnly">No compression will be done. Only acts like a container. The default value is set to false.</param> internal static void InternalZipFiles(FileReference ZipFileName, DirectoryReference BaseDirectory, FileFilter Filter, int CompressionLevel = 0) { // Ionic.Zip.Zip64Option.Always option produces broken archives on Mono, so we use system zip tool instead if (Utils.IsRunningOnMono) { DirectoryReference.CreateDirectory(ZipFileName.Directory); CommandUtils.PushDir(BaseDirectory.FullName); string FilesList = ""; foreach (FileReference FilteredFile in Filter.ApplyToDirectory(BaseDirectory, true)) { FilesList += " \"" + FilteredFile.MakeRelativeTo(BaseDirectory) + "\""; if (FilesList.Length > 32000) { CommandUtils.RunAndLog(CommandUtils.CmdEnv, "zip", "-g -q \"" + ZipFileName + "\"" + FilesList); FilesList = ""; } } if (FilesList.Length > 0) { CommandUtils.RunAndLog(CommandUtils.CmdEnv, "zip", "-g -q \"" + ZipFileName + "\"" + FilesList); } CommandUtils.PopDir(); } else { using (Ionic.Zip.ZipFile Zip = new Ionic.Zip.ZipFile()) { Zip.UseZip64WhenSaving = Ionic.Zip.Zip64Option.Always; Zip.CompressionLevel = (Ionic.Zlib.CompressionLevel)CompressionLevel; if (Zip.CompressionLevel == Ionic.Zlib.CompressionLevel.Level0) { Zip.CompressionMethod = Ionic.Zip.CompressionMethod.None; } foreach (FileReference FilteredFile in Filter.ApplyToDirectory(BaseDirectory, true)) { Zip.AddFile(FilteredFile.FullName, Path.GetDirectoryName(FilteredFile.MakeRelativeTo(BaseDirectory))); } CommandUtils.CreateDirectory(Path.GetDirectoryName(ZipFileName.FullName)); Zip.Save(ZipFileName.FullName); } } }
/// <summary> /// Creates a zip file containing the given input files /// </summary> /// <param name="ZipFileName">Filename for the zip</param> /// <param name="Filter">Filter which selects files to be included in the zip</param> /// <param name="BaseDirectory">Base directory to store relative paths in the zip file to</param> /// <param name="CopyModeOnly">No compression will be done. Only acts like a container. The default value is set to false.</param> internal static void InternalZipFiles(FileReference ZipFileName, DirectoryReference BaseDirectory, FileFilter Filter, int CompressionLevel = 0) { using (Ionic.Zip.ZipFile Zip = new Ionic.Zip.ZipFile()) { Zip.UseZip64WhenSaving = Ionic.Zip.Zip64Option.AsNecessary; Zip.CompressionLevel = (Ionic.Zlib.CompressionLevel)CompressionLevel; if (Zip.CompressionLevel == Ionic.Zlib.CompressionLevel.Level0) { Zip.CompressionMethod = Ionic.Zip.CompressionMethod.None; } foreach (FileReference FilteredFile in Filter.ApplyToDirectory(BaseDirectory, true)) { Zip.AddFile(FilteredFile.FullName, Path.GetDirectoryName(FilteredFile.MakeRelativeTo(BaseDirectory))); } CommandUtils.CreateDirectory(Path.GetDirectoryName(ZipFileName.FullName)); Zip.Save(ZipFileName.FullName); } }
private static bool FindBestSharedCookedBuild(ref string FinalCookedBuildPath, string ProjectFullPath, UnrealTargetPlatform TargetPlatform, string CookPlatform, string SharedCookedBuildCL) { string BuildRoot = CommandUtils.P4Enabled ? CommandUtils.P4Env.Branch.Replace("/", "+") : ""; int CurrentCLInt = CommandUtils.P4Enabled ? CommandUtils.P4Env.Changelist : 0; BuildVersion Version; if (BuildVersion.TryRead(BuildVersion.GetDefaultFileName(), out Version)) { CurrentCLInt = Version.Changelist; BuildRoot = Version.BranchName; } System.GC.Collect(); string CurrentCL = CurrentCLInt.ToString(); FileReference ProjectFileRef = new FileReference(ProjectFullPath); // get network location ConfigHierarchy Hierarchy = ConfigCache.ReadHierarchy(ConfigHierarchyType.Engine, DirectoryReference.FromFile(ProjectFileRef), TargetPlatform); List <string> CookedBuildPaths; if (Hierarchy.GetArray("SharedCookedBuildSettings", "SharedCookedBuildPath", out CookedBuildPaths) == false) { CommandUtils.LogInformation("Unable to copy shared cooked build: SharedCookedBuildPath not set in Engine.ini SharedCookedBuildSettings"); return(false); } const string MetaDataFilename = "\\Metadata\\DevelopmentAssetRegistry.bin"; if (SharedCookedBuildCL == "usesyncedbuild") { foreach (string CookedBuildPath in CookedBuildPaths) { if (CurrentCL == "" && FinalCookedBuildPath.Contains("[CL]")) { CommandUtils.LogInformation("Unable to copy shared cooked build: Unable to determine CL number from P4 or UGS, and is required by SharedCookedBuildPath"); return(false); } if (CurrentCL == "" && FinalCookedBuildPath.Contains("[BRANCHNAME]")) { CommandUtils.LogInformation("Unable to copy shared cooked build: Unable to determine BRANCHNAME number from P4 or UGS, and is required by SharedCookedBuildPath"); return(false); } FinalCookedBuildPath = FinalCookedBuildPath.Replace("[CL]", CurrentCL.ToString()); FinalCookedBuildPath = FinalCookedBuildPath.Replace("[BRANCHNAME]", BuildRoot); FinalCookedBuildPath = FinalCookedBuildPath.Replace("[PLATFORM]", CookPlatform); // make sure that the directory and metadata file exist. otherwise this build might not be finished yet and we should skip it if (Directory.Exists(FinalCookedBuildPath)) { if (File.Exists(FinalCookedBuildPath + MetaDataFilename)) { return(true); } } } } else if (SharedCookedBuildCL == "userecentbuild") { // build our CookedBUildPath into a regex which we can execute on the directories and extract info from string BestBuild = null; int BestCLNumber = 0; // find all the recent builds which are valid foreach (string CookedBuildPath in CookedBuildPaths) { int IndexOfFirstParam = CookedBuildPath.IndexOf("["); int CustomFolderStart = CookedBuildPath.LastIndexOf("\\", IndexOfFirstParam); string CookedBuildDirectory = CookedBuildPath.Substring(0, CustomFolderStart); string BuildNameWildcard = CookedBuildPath.Substring(CustomFolderStart); BuildNameWildcard += MetaDataFilename; FileFilter BuildSearch = new FileFilter(); // we know the platform and the branch name; string BuildRule = BuildNameWildcard; BuildRule = BuildRule.Replace("[BRANCHNAME]", BuildRoot); BuildRule = BuildRule.Replace("[PLATFORM]", CookPlatform); string IncludeRule = BuildRule.Replace("[CL]", "*"); string ForgetRule = BuildRule.Replace("[CL]", "*-PF-*"); // get rid of any preflights from the list... they don't count because who knows what they did... BuildSearch.AddRule(IncludeRule); BuildSearch.AddRule(ForgetRule, FileFilterType.Exclude); List <FileReference> ValidBuilds = BuildSearch.ApplyToDirectory(new DirectoryReference(CookedBuildDirectory), false); // figure out what the CL is string BuildNameRegex = String.Format(".*{0}", CookedBuildPath.Substring(CustomFolderStart)); BuildNameRegex = BuildNameRegex.Replace("\\", "\\\\"); BuildNameRegex = BuildNameRegex.Replace("[BRANCHNAME]", BuildRoot); BuildNameRegex = BuildNameRegex.Replace("+", "\\+"); BuildNameRegex = BuildNameRegex.Replace("[PLATFORM]", CookPlatform); BuildNameRegex = BuildNameRegex.Replace("[CL]", "(?<CL>.*)"); Regex ExtractCL = new Regex(BuildNameRegex); foreach (FileReference ValidBuild in ValidBuilds) { string BuildPath = ValidBuild.FullName.Replace(MetaDataFilename, ""); Match CLMatch = ExtractCL.Match(BuildPath); if (CLMatch != null) { string CLNumber = CLMatch.Result("${CL}"); int CLNumberInt = int.Parse(CLNumber); if (CLNumberInt <= CurrentCLInt) { if (CLNumberInt > BestCLNumber) { BestCLNumber = CLNumberInt; BestBuild = BuildPath; } } } } } if (string.IsNullOrEmpty(BestBuild)) { return(false); } FinalCookedBuildPath = BestBuild; return(true); } return(false); }
static List<string> FilterPluginFiles(string PluginFileName, List<BuildProduct> BuildProducts) { string PluginDirectory = Path.GetDirectoryName(PluginFileName); // Set up the default filter FileFilter Filter = new FileFilter(); Filter.AddRuleForFile(PluginFileName, PluginDirectory, FileFilterType.Include); Filter.AddRuleForFiles(BuildProducts.Select(x => x.Path), PluginDirectory, FileFilterType.Include); Filter.Include("/Resources/..."); Filter.Include("/Content/..."); Filter.Include("/Intermediate/Build/.../Inc/..."); Filter.Include("/Source/..."); // Add custom rules for each platform string FilterFileName = Path.Combine(Path.GetDirectoryName(PluginFileName), "Config", "FilterPlugin.ini"); if(File.Exists(FilterFileName)) { Filter.ReadRulesFromFile(FilterFileName, "FilterPlugin"); } // Apply the standard exclusion rules Filter.ExcludeConfidentialFolders(); Filter.ExcludeConfidentialPlatforms(); // Apply the filter to the plugin directory return new List<string>(Filter.ApplyToDirectory(PluginDirectory, true)); }
static IEnumerable<FileReference> FilterPluginFiles(FileReference PluginFile, IEnumerable<FileReference> BuildProducts) { // Set up the default filter FileFilter Filter = new FileFilter(); Filter.AddRuleForFile(PluginFile.FullName, PluginFile.Directory.FullName, FileFilterType.Include); Filter.AddRuleForFiles(BuildProducts, PluginFile.Directory, FileFilterType.Include); Filter.Include("/Binaries/ThirdParty/..."); Filter.Include("/Resources/..."); Filter.Include("/Content/..."); Filter.Include("/Intermediate/Build/.../Inc/..."); Filter.Include("/Source/..."); // Add custom rules for each platform FileReference FilterFile = FileReference.Combine(PluginFile.Directory, "Config", "FilterPlugin.ini"); if(FilterFile.Exists()) { CommandUtils.Log("Reading filter rules from {0}", FilterFile); Filter.ReadRulesFromFile(FilterFile.FullName, "FilterPlugin"); } // Apply the standard exclusion rules Filter.ExcludeConfidentialFolders(); Filter.ExcludeConfidentialPlatforms(); // Apply the filter to the plugin directory return Filter.ApplyToDirectory(PluginFile.Directory, true); }