Esempio n. 1
0
        EditorBuild CreateEditorBuild(string InProjectName, string InUnrealPath)
        {
            if (string.IsNullOrEmpty(InUnrealPath))
            {
                return(null);
            }

            // check for the editor
            string EditorExe = Path.Combine(InUnrealPath, GetRelativeExecutablePath(UnrealTargetRole.Editor, BuildHostPlatform.Current.Platform, UnrealTargetConfiguration.Development));

            if (!Utils.SystemHelpers.ApplicationExists(EditorExe))
            {
                return(null);
            }

            // figure out the game name - they may have passed Foo or FooGame
            string ProjectPath = UnrealHelpers.GetProjectPath(InProjectName);

            if (File.Exists(ProjectPath))
            {
                ProjectName = InProjectName;
            }
            else
            {
                // todo - this is ok, because we want people to be able to run staged builds
                // where no uproject file is available.

                /*throw new AutomationException("Unable to find project file for {0}. Neither {1} nor {2} exists.",
                 *      InProjectName, ProjectOption1, ProjectOption2);*/
                return(null);
            }

            EditorBuild NewBuild = new EditorBuild(EditorExe);

            return(NewBuild);

            //List<string> Empty = new List<string>();
            //return CanSupportRole(new UnrealSessionRole(UnrealRoleType.Editor, BuildHostPlatform.Current.Platform, UnrealTargetConfiguration.Development), ref Empty); ;
        }
Esempio n. 2
0
        virtual protected bool ResolveBuildReference(string InBuildReference, Func <string, string> ResolutionDelegate, out IEnumerable <string> OutBuildPaths, out string OutBuildName)
        {
            OutBuildName  = null;
            OutBuildPaths = null;

            if (string.IsNullOrEmpty(InBuildReference))
            {
                return(false);
            }

            if (InBuildReference.Equals("AutoP4", StringComparison.InvariantCultureIgnoreCase))
            {
                if (!CommandUtils.P4Enabled)
                {
                    throw new AutomationException("-Build=AutoP4 requires -P4");
                }
                if (CommandUtils.P4Env.Changelist < 1000)
                {
                    throw new AutomationException("-Build=AutoP4 requires a CL from P4 and we have {0}", CommandUtils.P4Env.Changelist);
                }

                string BuildRoot = CommandUtils.CombinePaths(CommandUtils.RootBuildStorageDirectory());
                string CachePath = InternalUtils.GetEnvironmentVariable("UE-BuildCachePath", "");

                string SrcBuildPath  = CommandUtils.CombinePaths(BuildRoot, ProjectName);
                string SrcBuildPath2 = CommandUtils.CombinePaths(BuildRoot, ProjectName.Replace("Game", "").Replace("game", ""));

                string SrcBuildPath_Cache  = CommandUtils.CombinePaths(CachePath, ProjectName);
                string SrcBuildPath2_Cache = CommandUtils.CombinePaths(CachePath, ProjectName.Replace("Game", "").Replace("game", ""));

                if (!InternalUtils.SafeDirectoryExists(SrcBuildPath))
                {
                    if (!InternalUtils.SafeDirectoryExists(SrcBuildPath2))
                    {
                        throw new AutomationException("-Build=AutoP4: Neither {0} nor {1} exists.", SrcBuildPath, SrcBuildPath2);
                    }
                    SrcBuildPath       = SrcBuildPath2;
                    SrcBuildPath_Cache = SrcBuildPath2_Cache;
                }
                string SrcCLPath       = CommandUtils.CombinePaths(SrcBuildPath, CommandUtils.EscapePath(CommandUtils.P4Env.Branch) + "-CL-" + CommandUtils.P4Env.Changelist.ToString());
                string SrcCLPath_Cache = CommandUtils.CombinePaths(SrcBuildPath_Cache, CommandUtils.EscapePath(CommandUtils.P4Env.Branch) + "-CL-" + CommandUtils.P4Env.Changelist.ToString());
                if (!InternalUtils.SafeDirectoryExists(SrcCLPath))
                {
                    throw new AutomationException("-Build=AutoP4: {0} does not exist.", SrcCLPath);
                }

                if (InternalUtils.SafeDirectoryExists(SrcCLPath_Cache))
                {
                    InBuildReference = SrcCLPath_Cache;
                }
                else
                {
                    InBuildReference = SrcCLPath;
                }
                Log.Verbose("Using AutoP4 path {0}", InBuildReference);
            }

            // BuildParam could be a path, a name that we should resolve to a path, Staged, or Editor
            DirectoryInfo BuildDir = new DirectoryInfo(InBuildReference);

            if (BuildDir.Exists)
            {
                // Easy option first - is this a full path?
                OutBuildName  = BuildDir.Name;
                OutBuildPaths = new string[] { BuildDir.FullName };
            }
            else if (BuildDir.Name.Equals("local", StringComparison.OrdinalIgnoreCase) || BuildDir.Name.Equals("staged", StringComparison.OrdinalIgnoreCase))
            {
                string ProjectDir = Path.GetDirectoryName(UnrealHelpers.GetProjectPath(ProjectName));

                if (string.IsNullOrEmpty(ProjectDir))
                {
                    throw new AutomationException("Could not find uproject for {0}.", ProjectName);
                }

                // First special case - "Staged" means use whats locally staged
                OutBuildName = "Local";
                string StagedPath = Path.Combine(ProjectDir, "Saved", "StagedBuilds");

                if (Directory.Exists(StagedPath) == false)
                {
                    Log.Error("BuildReference was Staged but staged directory {0} not found", StagedPath);
                    return(false);
                }

                // include binaries path for packaged builds
                string BinariesPath = Path.Combine(ProjectDir, "Binaries");

                OutBuildPaths = new string[] { StagedPath, BinariesPath };
            }
            else if (BuildDir.Name.Equals("editor", StringComparison.OrdinalIgnoreCase))
            {
                // Second special case - "Editor" means run using the editor, no path needed
                OutBuildName  = "Editor";
                OutBuildPaths = new string[] { Environment.CurrentDirectory };
            }
            else
            {
                // todo - make this more generic
                if (BuildDir.Name.Equals("usesyncedbuild", StringComparison.OrdinalIgnoreCase))
                {
                    BuildVersion Version;
                    if (BuildVersion.TryRead(BuildVersion.GetDefaultFileName(), out Version))
                    {
                        InBuildReference = Version.BranchName + "-CL-" + Version.Changelist.ToString();
                    }
                }

                // See if it's in the passed locations
                if (ResolutionDelegate != null)
                {
                    string FullPath = ResolutionDelegate(InBuildReference);

                    if (string.IsNullOrEmpty(FullPath) == false)
                    {
                        DirectoryInfo Di = new DirectoryInfo(FullPath);

                        if (Di.Exists == false)
                        {
                            throw new AutomationException("Resolution delegate returned non existent path");
                        }

                        OutBuildName  = Di.Name;
                        OutBuildPaths = new string[] { Di.FullName };
                    }
                }
            }

            if (string.IsNullOrEmpty(OutBuildName) || (OutBuildPaths == null || OutBuildPaths.Count() == 0))
            {
                Log.Error("Unable to resolve build argument '{0}'", InBuildReference);
                return(false);
            }

            return(true);
        }
        virtual protected bool ResolveBuildReference(string InBuildReference, Func <string, string> ResolutionDelegate, out string OutBuildPath, out string OutBuildName)
        {
            OutBuildName = null;
            OutBuildPath = null;

            if (string.IsNullOrEmpty(InBuildReference))
            {
                return(false);
            }

            // BuildParam could be a path, a name that we should resolve to a path, Staged, or Editor
            DirectoryInfo BuildDir = new DirectoryInfo(InBuildReference);

            if (BuildDir.Exists)
            {
                // Easy option first - is this a full path?
                OutBuildName = BuildDir.Name;
                OutBuildPath = BuildDir.FullName;
            }
            else if (BuildDir.Name.Equals("staged", StringComparison.OrdinalIgnoreCase))
            {
                string ProjectDir = Path.GetDirectoryName(UnrealHelpers.GetProjectPath(ProjectName));

                if (string.IsNullOrEmpty(ProjectDir))
                {
                    throw new AutomationException("Could not find uproject for {0}.", ProjectName);
                }

                // First special case - "Staged" means use whats locally staged
                OutBuildName = "Staged";
                OutBuildPath = Path.Combine(ProjectDir, "Saved", "StagedBuilds");

                if (Directory.Exists(OutBuildPath) == false)
                {
                    Log.Error("BuildReference was Staged but staged directory {0} not found", OutBuildPath);
                    return(false);
                }
            }
            else if (BuildDir.Name.Equals("editor", StringComparison.OrdinalIgnoreCase))
            {
                // Second special case - "Editor" means run using the editor, no path needed
                OutBuildName = "Editor";
                OutBuildPath = Environment.CurrentDirectory;
            }
            else
            {
                // todo - make this more generic
                if (BuildDir.Name.Equals("usesyncedbuild", StringComparison.OrdinalIgnoreCase))
                {
                    BuildVersion Version;
                    if (BuildVersion.TryRead(BuildVersion.GetDefaultFileName(), out Version))
                    {
                        InBuildReference = Version.BranchName + "-CL-" + Version.Changelist.ToString();
                    }
                }

                // See if it's in the passed locations
                if (ResolutionDelegate != null)
                {
                    string FullPath = ResolutionDelegate(InBuildReference);

                    if (string.IsNullOrEmpty(FullPath) == false)
                    {
                        DirectoryInfo Di = new DirectoryInfo(FullPath);

                        if (Di.Exists == false)
                        {
                            throw new AutomationException("Resolution delegate returned non existent path");
                        }

                        OutBuildName = Di.Name;
                        OutBuildPath = Di.FullName;
                    }
                }
            }

            if (string.IsNullOrEmpty(OutBuildName) || string.IsNullOrEmpty(OutBuildPath))
            {
                Log.Error("Unable to resolve build argument '{0}'", InBuildReference);
                return(false);
            }

            return(true);
        }