Implement Project Manager 'build' button for Mac and Linux(#4248)
Signed-off-by: Steve Pham <spham@amazon.com>
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
|
||||
#include <ProjectUtils.h>
|
||||
|
||||
#include <PythonBindingsInterface.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QProcess>
|
||||
@@ -16,8 +18,44 @@ namespace O3DE::ProjectManager
|
||||
{
|
||||
namespace ProjectUtils
|
||||
{
|
||||
AZ::Outcome<void, QString> FindSupportedCompilerForPlatform()
|
||||
AZ::Outcome<QProcessEnvironment, QString> GetCommandLineProcessEnvironment()
|
||||
{
|
||||
// Use the engine path to insert a path for cmake
|
||||
auto engineInfoResult = PythonBindingsInterface::Get()->GetEngineInfo();
|
||||
if (!engineInfoResult.IsSuccess())
|
||||
{
|
||||
return AZ::Failure(QObject::tr("Failed to get engine info"));
|
||||
}
|
||||
auto engineInfo = engineInfoResult.GetValue();
|
||||
|
||||
QProcessEnvironment currentEnvironment(QProcessEnvironment::systemEnvironment());
|
||||
|
||||
// Append cmake path to PATH incase it is missing
|
||||
QDir cmakePath(engineInfo.m_path);
|
||||
cmakePath.cd("cmake/runtime/bin");
|
||||
QString pathValue = currentEnvironment.value("PATH");
|
||||
pathValue += ";" + cmakePath.path();
|
||||
currentEnvironment.insert("PATH", pathValue);
|
||||
return AZ::Success(currentEnvironment);
|
||||
}
|
||||
|
||||
AZ::Outcome<QString, QString> FindSupportedCompilerForPlatform()
|
||||
{
|
||||
// Validate that cmake is installed
|
||||
auto cmakeProcessEnvResult = GetCommandLineProcessEnvironment();
|
||||
if (!cmakeProcessEnvResult.IsSuccess())
|
||||
{
|
||||
return AZ::Failure(cmakeProcessEnvResult.GetError());
|
||||
}
|
||||
auto cmakeVersionQueryResult = ExecuteCommandResult("cmake", QStringList{"--version"}, cmakeProcessEnvResult.GetValue());
|
||||
if (!cmakeVersionQueryResult.IsSuccess())
|
||||
{
|
||||
return AZ::Failure(QObject::tr("CMake not found. \n\n"
|
||||
"Make sure that the minimum version of CMake is installed and available from the command prompt. "
|
||||
"Refer to the <a href='https://o3de.org/docs/welcome-guide/setup/requirements/#cmake'>O3DE requirements</a> for more information."));
|
||||
}
|
||||
|
||||
// Validate that the minimal version of visual studio is installed
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
QString programFilesPath = environment.value("ProgramFiles(x86)");
|
||||
QString vsWherePath = QDir(programFilesPath).filePath("Microsoft Visual Studio/Installer/vswhere.exe");
|
||||
@@ -25,27 +63,31 @@ namespace O3DE::ProjectManager
|
||||
QFileInfo vsWhereFile(vsWherePath);
|
||||
if (vsWhereFile.exists() && vsWhereFile.isFile())
|
||||
{
|
||||
QProcess vsWhereProcess;
|
||||
vsWhereProcess.setProcessChannelMode(QProcess::MergedChannels);
|
||||
QStringList vsWhereBaseArguments = QStringList{"-version",
|
||||
"16.9.2",
|
||||
"-latest",
|
||||
"-requires",
|
||||
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64"};
|
||||
|
||||
vsWhereProcess.start(
|
||||
vsWherePath,
|
||||
QStringList{
|
||||
"-version",
|
||||
"16.9.2",
|
||||
"-latest",
|
||||
"-requires",
|
||||
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
|
||||
"-property",
|
||||
"isComplete"
|
||||
});
|
||||
QProcess vsWhereIsCompleteProcess;
|
||||
vsWhereIsCompleteProcess.setProcessChannelMode(QProcess::MergedChannels);
|
||||
|
||||
if (vsWhereProcess.waitForStarted() && vsWhereProcess.waitForFinished())
|
||||
vsWhereIsCompleteProcess.start(vsWherePath, vsWhereBaseArguments + QStringList{ "-property", "isComplete" });
|
||||
|
||||
if (vsWhereIsCompleteProcess.waitForStarted() && vsWhereIsCompleteProcess.waitForFinished())
|
||||
{
|
||||
QString vsWhereOutput(vsWhereProcess.readAllStandardOutput());
|
||||
if (vsWhereOutput.startsWith("1"))
|
||||
QString vsWhereIsCompleteOutput(vsWhereIsCompleteProcess.readAllStandardOutput());
|
||||
if (vsWhereIsCompleteOutput.startsWith("1"))
|
||||
{
|
||||
return AZ::Success();
|
||||
QProcess vsWhereCompilerVersionProcess;
|
||||
vsWhereCompilerVersionProcess.setProcessChannelMode(QProcess::MergedChannels);
|
||||
vsWhereCompilerVersionProcess.start(vsWherePath, vsWhereBaseArguments + QStringList{"-property", "catalog_productDisplayVersion"});
|
||||
|
||||
if (vsWhereCompilerVersionProcess.waitForStarted() && vsWhereCompilerVersionProcess.waitForFinished())
|
||||
{
|
||||
QString vsWhereCompilerVersionOutput(vsWhereCompilerVersionProcess.readAllStandardOutput());
|
||||
return AZ::Success(vsWhereCompilerVersionOutput);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user