Example #1
0
	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;
	}
Example #2
0
    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));
    }
    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);
    }