Example #1
0
        private static bool RegenerateProjectUsingUBT(Lifetime lifetime, UnrealHost unrealHost, VirtualFileSystemPath uprojectFile,
                                                      VirtualFileSystemPath pathToUnrealBuildToolBin, VirtualFileSystemPath engineRoot)
        {
            if (uprojectFile.IsNullOrEmpty())
            {
                return(false);
            }

            bool isInstalledBuild = IsInstalledBuild(engineRoot);

            var pipeStreams = CreatePipeStreams(unrealHost, "[UBT]:");
            var startInfo   = CmdUtils.GetProcessStartInfo(pipeStreams, pathToUnrealBuildToolBin,
                                                           pathToUnrealBuildToolBin.Directory, "-ProjectFiles",
                                                           $"-project=\"{uprojectFile.FullPath}\"", "-game", isInstalledBuild ? "-rocket" : "-engine");

            try
            {
                var result = CmdUtils.RunCommandWithLock(lifetime, startInfo, ourLogger) == 0;
                if (!result)
                {
                    ourLogger.Warn($"[UnrealLink]: Failed refresh project files: calling {startInfo.Arguments}");
                }

                return(result);
            }
            catch (ErrorLevelException errorLevelException)
            {
                ourLogger.Error(errorLevelException,
                                $"[UnrealLink]: Failed refresh project files: calling {startInfo.Arguments}");
                return(false);
            }
        }
        private bool BuildPlugin(Lifetime lifetime, VirtualFileSystemPath upluginPath,
                                 VirtualFileSystemPath outputDir, VirtualFileSystemPath engineRoot,
                                 Action <double> progressPump)
        {
            var runUatName = $"RunUAT.{CmdUtils.GetPlatformCmdExtension()}";
            var pathToUat  = engineRoot / "Engine" / "Build" / "BatchFiles" / runUatName;

            if (!pathToUat.ExistsFile)
            {
                myLogger.Warn($"[UnrealLink]: Failed build plugin: {runUatName} is not available");
                var text = $"{runUatName} is not available is not available at expected destination: {pathToUat}<br>";
                myUnrealHost.myModel.RiderLinkInstallMessage(
                    new InstallMessage($"Failed to build RiderLink plugin for {engineRoot}", ContentType.Error));
                myUnrealHost.myModel.RiderLinkInstallMessage(new InstallMessage(text, ContentType.Error));
                return(false);
            }

            try
            {
                var pipeStreams = CreatePipeStreams("[UAT]:", progressPump);
                var startInfo   = CmdUtils.GetProcessStartInfo(pipeStreams, pathToUat, null, "BuildPlugin",
                                                               "-Unversioned", $"-Plugin=\"{upluginPath.FullPath}\"",
                                                               $"-Package=\"{outputDir.FullPath}\"");

                myLogger.Info($"[UnrealLink]: Building UnrealLink plugin with: {startInfo.Arguments}");
                myLogger.Verbose("[UnrealLink]: Start building UnrealLink");

                var result = CmdUtils.RunCommandWithLock(lifetime, startInfo, myLogger);
                myLogger.Verbose("[UnrealLink]: Stop building UnrealLink");
                lifetime.ToCancellationToken().ThrowIfCancellationRequested();

                if (result != 0)
                {
                    myLogger.Warn($"[UnrealLink]: Failed to build plugin for {engineRoot}");
                    myUnrealHost.myModel.RiderLinkInstallMessage(new InstallMessage("Failed to build RiderLink plugin",
                                                                                    ContentType.Error));
                    return(false);
                }
            }
            catch (OperationCanceledException)
            {
                myLogger.Verbose("[UnrealLink]: Build cancelled");
                throw;
            }
            catch (Exception exception)
            {
                myLogger.Verbose("[UnrealLink]: Stop building UnrealLink");
                myLogger.Warn(exception,
                              $"[UnrealLink]: Failed to build plugin for {engineRoot}");

                myUnrealHost.myModel.RiderLinkInstallMessage(
                    new InstallMessage($"Failed to build RiderLink plugin for {engineRoot}", ContentType.Error));
                return(false);
            }

            return(true);
        }
Example #3
0
        private static bool GenerateProjectFilesCmd(Lifetime lifetime, ISolution solution, UnrealHost unrealHost,
                                                    VirtualFileSystemPath uprojectFile, VirtualFileSystemPath engineRoot)
        {
            // Invalid uproject file means we couldn't get uproject file from solution detector and the project might be
            // under Engine source
            var invalidUprojectFile  = !uprojectFile.IsValidAndExistFile();
            var isProjectUnderEngine = uprojectFile.StartsWith(engineRoot) || invalidUprojectFile;

            if (!isProjectUnderEngine)
            {
                ourLogger.Info($"[UnrealLink]: {solution.SolutionFilePath} is not in {engineRoot} ");
                return(false);
            }

            var generateProjectFilesCmd = engineRoot / $"GenerateProjectFiles.{CmdUtils.GetPlatformCmdExtension()}";

            if (!generateProjectFilesCmd.ExistsFile)
            {
                ourLogger.Info($"[UnrealLink]: {generateProjectFilesCmd} is not available");
                return(false);
            }

            var pipeStreams = CreatePipeStreams(unrealHost, "[GenerateProjectFiles]:");
            var startInfo   = CmdUtils.GetProcessStartInfo(pipeStreams, generateProjectFilesCmd, generateProjectFilesCmd.Directory);

            ourLogger.Info($"[UnrealLink]: Regenerating project files: {startInfo.Arguments}");
            try
            {
                var result = CmdUtils.RunCommandWithLock(lifetime, startInfo, ourLogger) == 0;
                if (!result)
                {
                    ourLogger.Warn($"[UnrealLink]: Failed refresh project files, calling {generateProjectFilesCmd} went wrong");
                }

                return(result);
            }
            catch (ErrorLevelException errorLevelException)
            {
                ourLogger.Error(errorLevelException,
                                $"[UnrealLink]: Failed refresh project files, calling {generateProjectFilesCmd} went wrong");
                return(false);
            }
        }
Example #4
0
        private static bool RegenerateProjectUsingUVS(Lifetime lifetime, UnrealHost unrealHost, VirtualFileSystemPath uprojectFile,
                                                      VirtualFileSystemPath pathToUnrealVersionSelector)
        {
            if (!uprojectFile.IsValidAndExistFile())
            {
                return(false);
            }
            if (!pathToUnrealVersionSelector.ExistsFile)
            {
                ourLogger.Info($"[UnrealLink]: {pathToUnrealVersionSelector} is not available");
                return(false);
            }

            var pipeStreams = CreatePipeStreams(unrealHost, "[UVS]:");
            var startInfo   = CmdUtils.GetProcessStartInfo(pipeStreams, pathToUnrealVersionSelector,
                                                           pathToUnrealVersionSelector.Directory,
                                                           "-projectFiles", $"\"{uprojectFile}\"");

            try
            {
                var result = CmdUtils.RunCommandWithLock(lifetime, startInfo, ourLogger) == 0;
                if (!result)
                {
                    ourLogger.Warn(
                        $"[UnrealLink]: Failed refresh project files: calling {pathToUnrealVersionSelector} {startInfo.Arguments}");
                }

                return(result);
            }
            catch (ErrorLevelException errorLevelException)
            {
                ourLogger.Error(errorLevelException,
                                $"[UnrealLink]: Failed refresh project files: calling {pathToUnrealVersionSelector} {startInfo.Arguments}");
                return(false);
            }
        }