private void RegenerateProjectFiles(FileSystemPath uprojectFilePath) { void LogFailedRefreshProjectFiles() { myUnrealHost.myModel.RiderLinkInstallMessage(new InstallMessage("Failed to refresh project files", ContentType.Normal)); myUnrealHost.myModel.RiderLinkInstallMessage( new InstallMessage("RiderLink will not be visible in solution explorer", ContentType.Normal)); myUnrealHost.myModel.RiderLinkInstallMessage(new InstallMessage( "Need to refresh project files in Unreal Editor or in File Explorer with context action for .uproject file 'Refresh Project files'", ContentType.Normal)); } if (uprojectFilePath.IsNullOrEmpty()) { myLogger.Warn( $"[UnrealLink]: Failed refresh project files, couldn't find uproject path: {uprojectFilePath}"); LogFailedRefreshProjectFiles(); return; } var engineRoot = CppUE4FolderFinder.FindUnrealEngineRoot(uprojectFilePath); if (engineRoot.IsEmpty) { myLogger.Warn($"[UnrealLink]: Couldn't find Unreal Engine root for {uprojectFilePath}"); LogFailedRefreshProjectFiles(); return; } var pathToUnrealBuildToolBin = CppUE4FolderFinder.GetAbsolutePathToUnrealBuildToolBin(engineRoot); // 1. If project is under engine root, use GenerateProjectFiles.{extension} first if (GenerateProjectFilesCmd(engineRoot)) { return; } // 2. If it's a standalone project, use UnrealVersionSelector // The same way "Generate project files" from context menu of .uproject works if (RegenerateProjectUsingUVS(uprojectFilePath, engineRoot)) { return; } // 3. If UVS is missing or have failed, fallback to UnrealBuildTool if (RegenerateProjectUsingUBT(uprojectFilePath, pathToUnrealBuildToolBin, engineRoot)) { return; } myLogger.Warn("[UnrealLink]: Couldn't refresh project files"); LogFailedRefreshProjectFiles(); }
private static void RegenerateProjectFiles(Lifetime lifetime, ISolution solution, UnrealHost unrealHost, VirtualFileSystemPath engineRoot, VirtualFileSystemPath uprojectFile) { void LogFailedRefreshProjectFiles() { unrealHost.myModel.RiderLinkInstallMessage(new InstallMessage("Failed to refresh project files", ContentType.Normal)); unrealHost.myModel.RiderLinkInstallMessage( new InstallMessage("RiderLink will not be visible in solution explorer", ContentType.Normal)); unrealHost.myModel.RiderLinkInstallMessage(new InstallMessage( "Need to refresh project files in Unreal Editor or in File Explorer with context action for .uproject file 'Refresh Project files'", ContentType.Normal)); } if (!engineRoot.IsValidAndExistDirectory()) { ourLogger.Warn($"[UnrealLink]: Couldn't find Unreal Engine root"); LogFailedRefreshProjectFiles(); return; } var pathToUnrealBuildToolBin = CppUE4FolderFinder.GetAbsolutePathToUnrealBuildToolBin(engineRoot); // 1. If project is under engine root, use GenerateProjectFiles.{extension} first if (GenerateProjectFilesCmd(lifetime, solution, unrealHost, uprojectFile, engineRoot)) { return; } // 2. If it's a standalone project, use UnrealVersionSelector // The same way "Generate project files" from context menu of .uproject works if (RegenerateProjectUsingBundledUVS(lifetime, unrealHost, uprojectFile, engineRoot)) { return; } if (RegenerateProjectUsingSystemUVS(lifetime, solution, unrealHost, uprojectFile)) { return; } // 3. If UVS is missing or have failed, fallback to UnrealBuildTool if (RegenerateProjectUsingUBT(lifetime, unrealHost, uprojectFile, pathToUnrealBuildToolBin, engineRoot)) { return; } ourLogger.Warn("[UnrealLink]: Couldn't refresh project files"); LogFailedRefreshProjectFiles(); }
private bool TryGetEnginePluginFromUproject(FileSystemPath uprojectPath, UnrealPluginInstallInfo installInfo) { if (!uprojectPath.ExistsFile) { return(false); } var unrealEngineRoot = CppUE4FolderFinder.FindUnrealEngineRoot(uprojectPath); if (unrealEngineRoot.IsEmpty) { return(false); } return(TryGetEnginePluginFromEngineRoot(installInfo, unrealEngineRoot)); }
private async Task <bool> BuildPlugin(Lifetime lifetime, FileSystemPath upluginPath, FileSystemPath outputDir, FileSystemPath uprojectFile, Action <double> progressPump) { //engineRoot\Engine\Build\BatchFiles\RunUAT.{extension}" BuildPlugin -Plugin="D:\tmp\RiderLink\RiderLink.uplugin" -Package="D:\PROJECTS\UE\FPS_D_TEST\Plugins\Developer\RiderLink" -Rocket var engineRoot = CppUE4FolderFinder.FindUnrealEngineRoot(uprojectFile); if (engineRoot.IsEmpty) { myLogger.Warn( $"[UnrealLink]: Failed to build plugin for {uprojectFile}, couldn't find Unreal Engine root"); var text = $"Couldn't find Unreal Engine root for {uprojectFile}"; myUnrealHost.myModel.RiderLinkInstallMessage( new InstallMessage($"Failed to build RiderLink plugin for {uprojectFile}", ContentType.Error)); myUnrealHost.myModel.RiderLinkInstallMessage(new InstallMessage(text, ContentType.Error)); return(false); } var runUatName = $"RunUAT.{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 {uprojectFile}", ContentType.Error)); myUnrealHost.myModel.RiderLinkInstallMessage(new InstallMessage(text, ContentType.Error)); return(false); } var command = GetPlatformCommand(pathToUat); var commandLine = GetPlatformCommandLine(pathToUat, "BuildPlugin", $"-Plugin=\"{upluginPath.FullPath}\"", $"-Package=\"{outputDir.FullPath}\"", "-Rocket", "-WaitMutex"); List <string> stdOut = new List <string>(); List <string> stdErr = new List <string>(); try { var pipeStreams = InvokeChildProcess.PipeStreams.Custom((chunk, isErr, logger) => { myUnrealHost.myModel.RiderLinkInstallMessage(new InstallMessage(chunk, isErr ? ContentType.Error : ContentType.Normal)); if (isErr) { stdErr.Add(chunk); } else { stdOut.Add(chunk); } if (isErr) { return; } var progressText = chunk.Trim(); if (!progressText.StartsWith("[")) { return; } var closingBracketIndex = progressText.IndexOf(']'); if (closingBracketIndex == -1) { return; } var progressNumberWithDivision = progressText.Substring(1, closingBracketIndex - 1); var numbers = progressNumberWithDivision.Split('/'); if (numbers.Length != 2) { return; } if (!int.TryParse(numbers[0], out var leftInt)) { return; } if (!int.TryParse(numbers[1], out var rightInt)) { return; } progressPump((double)leftInt / rightInt); }); myLogger.Info($"[UnrealLink]: Building UnrealLink plugin with: {commandLine}"); myLogger.Verbose("[UnrealLink]: Start building UnrealLink"); var result = await StartUBTBuildPluginAsync(lifetime, command, commandLine, pipeStreams); lifetime.ToCancellationToken().ThrowIfCancellationRequested(); myLogger.Verbose("[UnrealLink]: Stop building UnrealLink"); myLogger.Verbose("[UnrealLink]: Build logs:"); myLogger.Verbose(stdOut.Join("\n")); if (!stdErr.IsEmpty()) { myLogger.Warn(stdErr.Join("\n")); } if (result != 0) { myLogger.Warn($"[UnrealLink]: Failed to build plugin for {uprojectFile}"); myUnrealHost.myModel.RiderLinkInstallMessage(new InstallMessage("Failed to build RiderLink plugin", ContentType.Error)); return(false); } } catch (OperationCanceledException) { throw; } catch (Exception exception) { myLogger.Verbose("[UnrealLink]: Stop building UnrealLink"); myLogger.Verbose("[UnrealLink]: Build logs:"); myLogger.Verbose(stdOut.Join("\n")); if (!stdErr.IsEmpty()) { myLogger.Warn(stdErr.Join("\n")); } myLogger.Warn(exception, $"[UnrealLink]: Failed to build plugin for {uprojectFile}"); myUnrealHost.myModel.RiderLinkInstallMessage( new InstallMessage($"Failed to build RiderLink plugin for {uprojectFile}", ContentType.Error)); return(false); } return(true); }