Hi Epic dev team
Not sure where to talk about this so I thought to make a new thread here. I am working atm on a patch that supports multiple IDE on a platform. Actually it works already and I tested on GNU/Linux and Mac but should work on Windows too. I can select either XCode or CodeLite on Mac and on Linux and on Windows you may select VisualStudio and CodeLite or later whatever. I was thinking to make later a PR. Maybe you would be interested in because a lot of people asking for support of other IDE’s too. If not that is ok too :D.
What I mainly did is to put everything related to source code and IDE into the ISourceCodeAccessor interface and remove all hardcoded #if PLATFORM… stuff. So there are no
#if PLATFORM_WINDOWS
// Do stuff for VisualStudio
#elif PLATFORM_MAC
// Do stuff for XCode
#elif PLATFORM_LINUX
// Do stuff for …
#endif
The SourceCodeAccessor knows which IDE to use and which flags are needed for UBT to create the project files. The IDE in UE4 is opened in: (modified version of mine using CanAccessSolution with extended ISourceCodeAccessor)
bool GameProjectUtils::OpenCodeIDE(const FString& ProjectFile, FText& OutFailReason)
{
if ( ProjectFile.IsEmpty() )
{
OutFailReason = LOCTEXT( "NoProjectFileSpecified", "You must specify a project file." );
return false;
}
// Check whether this project is a foreign project. Don't use the cached project dictionary; we may have just created a new project.
FString SolutionFolder;
FString SolutionFilenameWithoutExtension;
if( FUProjectDictionary(FPaths::RootDir()).IsForeignProject(ProjectFile) )
{
SolutionFolder = IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead(*FPaths::GetPath(ProjectFile));
SolutionFilenameWithoutExtension = FPaths::GetBaseFilename(ProjectFile);
}
else
{
SolutionFolder = IFileManager::Get().ConvertToAbsolutePathForExternalAppForRead(*FPaths::RootDir());
SolutionFilenameWithoutExtension = TEXT("UE4");
}
ISourceCodeAccessModule& SourceCodeAccessModule = FModuleManager::LoadModuleChecked<ISourceCodeAccessModule>("SourceCodeAccess");
// Open the solution with the default application
FString FullPath;
if ( SourceCodeAccessModule.GetAccessor().CanAccessSolution(SolutionFolder, SolutionFilenameWithoutExtension, FullPath) )
{
FPlatformProcess::LaunchFileInDefaultExternalApplication( *FullPath );
return true;
}
FFormatNamedArguments Args;
Args.Add( TEXT("Path"), FText::FromString( FullPath ) );
OutFailReason = FText::Format( LOCTEXT( "OpenCodeIDE_MissingFile", "Could not edit the code editing IDE. {Path} could not be found." ), Args );
return false;
}
I am just wondering if the FPlatformProcess::LaunchFileInDefaultExternalApplication( *FullPath ); has to be in the GameProjectUtils class. In short, is there any reason not to start the IDE within the accessor module? I think it would be better to put it into the Accessor.
I could then replace CanAccessSolution with something similar to GameProjectUtils::OpenCodeIDE, like ISourceCodeAccessor::OpenCodeIDE.
Hope you have some suggestions.