Added a Warning When VS2019 is not Installed with Link to Download it (#2042)

* Added a warning when VS2019 is not installed with link to download it

Signed-off-by: nggieber <nggieber@amazon.com>

* Widden VSWarning dialog

Signed-off-by: nggieber <nggieber@amazon.com>

* Fix issue with checking for Visual Studio

Signed-off-by: nggieber <nggieber@amazon.com>

* PALify compiler detection

Signed-off-by: nggieber <nggieber@amazon.com>

* Changed windows compiler check to waitForFinished instead of waitForReadyRead

Signed-off-by: nggieber <nggieber@amazon.com>
main
AMZN-nggieber 4 years ago committed by GitHub
parent f83439e6c4
commit 2fad7f37db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -8,4 +8,5 @@
set(FILES set(FILES
Python_linux.cpp Python_linux.cpp
ProjectBuilderWorker_linux.cpp ProjectBuilderWorker_linux.cpp
ProjectUtils_linux.cpp
) )

@ -0,0 +1,21 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <ProjectUtils.h>
namespace O3DE::ProjectManager
{
namespace ProjectUtils
{
AZ::Outcome<void, QString> FindSupportedCompilerForPlatform()
{
// Compiler detection not supported on platform
return AZ::Success();
}
} // namespace ProjectUtils
} // namespace O3DE::ProjectManager

@ -8,4 +8,5 @@
set(FILES set(FILES
Python_mac.cpp Python_mac.cpp
ProjectBuilderWorker_mac.cpp ProjectBuilderWorker_mac.cpp
ProjectUtils_mac.cpp
) )

@ -0,0 +1,21 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <ProjectUtils.h>
namespace O3DE::ProjectManager
{
namespace ProjectUtils
{
AZ::Outcome<void, QString> FindSupportedCompilerForPlatform()
{
// Compiler detection not supported on platform
return AZ::Success();
}
} // namespace ProjectUtils
} // namespace O3DE::ProjectManager

@ -8,4 +8,5 @@
set(FILES set(FILES
Python_windows.cpp Python_windows.cpp
ProjectBuilderWorker_windows.cpp ProjectBuilderWorker_windows.cpp
ProjectUtils_windows.cpp
) )

@ -0,0 +1,60 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <ProjectUtils.h>
#include <QDir>
#include <QFileInfo>
#include <QProcess>
#include <QProcessEnvironment>
namespace O3DE::ProjectManager
{
namespace ProjectUtils
{
AZ::Outcome<void, QString> FindSupportedCompilerForPlatform()
{
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
QString programFilesPath = environment.value("ProgramFiles(x86)");
QString vsWherePath = QDir(programFilesPath).filePath("Microsoft Visual Studio/Installer/vswhere.exe");
QFileInfo vsWhereFile(vsWherePath);
if (vsWhereFile.exists() && vsWhereFile.isFile())
{
QProcess vsWhereProcess;
vsWhereProcess.setProcessChannelMode(QProcess::MergedChannels);
vsWhereProcess.start(
vsWherePath,
QStringList{
"-version",
"16.0",
"-latest",
"-requires",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"-property",
"isComplete"
});
if (vsWhereProcess.waitForStarted() && vsWhereProcess.waitForFinished())
{
QString vsWhereOutput(vsWhereProcess.readAllStandardOutput());
if (vsWhereOutput.startsWith("1"))
{
return AZ::Success();
}
}
}
return AZ::Failure(QObject::tr("Visual Studio 2019 not found.\n\n"
"Visual Studio 2019 is required to build this project."
" Install any edition of <a href='https://visualstudio.microsoft.com/downloads/'>Visual Studio 2019</a>"
" before proceeding to the next step."));
}
} // namespace ProjectUtils
} // namespace O3DE::ProjectManager

@ -12,6 +12,7 @@
#include <ScreenHeaderWidget.h> #include <ScreenHeaderWidget.h>
#include <GemCatalog/GemModel.h> #include <GemCatalog/GemModel.h>
#include <GemCatalog/GemCatalogScreen.h> #include <GemCatalog/GemCatalogScreen.h>
#include <ProjectUtils.h>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QHBoxLayout> #include <QHBoxLayout>
@ -221,6 +222,8 @@ namespace O3DE::ProjectManager
} }
void CreateProjectCtrl::CreateProject() void CreateProjectCtrl::CreateProject()
{
if (ProjectUtils::FindSupportedCompiler(this))
{ {
if (m_newProjectSettingsScreen->Validate()) if (m_newProjectSettingsScreen->Validate())
{ {
@ -252,7 +255,9 @@ namespace O3DE::ProjectManager
} }
else else
{ {
QMessageBox::warning(this, tr("Invalid project settings"), tr("Please correct the indicated project settings and try again.")); QMessageBox::warning(
this, tr("Invalid project settings"), tr("Please correct the indicated project settings and try again."));
}
} }
} }

@ -17,6 +17,8 @@
#include <QProcessEnvironment> #include <QProcessEnvironment>
#include <QGuiApplication> #include <QGuiApplication>
#include <QProgressDialog> #include <QProgressDialog>
#include <QSpacerItem>
#include <QGridLayout>
namespace O3DE::ProjectManager namespace O3DE::ProjectManager
{ {
@ -374,46 +376,27 @@ namespace O3DE::ProjectManager
return true; return true;
} }
static bool IsVS2019Installed_internal() bool FindSupportedCompiler(QWidget* parent)
{ {
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment(); auto findCompilerResult = FindSupportedCompilerForPlatform();
QString programFilesPath = environment.value("ProgramFiles(x86)");
QString vsWherePath = programFilesPath + "\\Microsoft Visual Studio\\Installer\\vswhere.exe";
QFileInfo vsWhereFile(vsWherePath); if (!findCompilerResult.IsSuccess())
if (vsWhereFile.exists() && vsWhereFile.isFile())
{ {
QProcess vsWhereProcess; QMessageBox vsWarningMessage(parent);
vsWhereProcess.setProcessChannelMode(QProcess::MergedChannels); vsWarningMessage.setIcon(QMessageBox::Warning);
vsWarningMessage.setWindowTitle(QObject::tr("Create Project"));
// Makes link clickable
vsWarningMessage.setTextFormat(Qt::RichText);
vsWarningMessage.setText(findCompilerResult.GetError());
vsWarningMessage.setStandardButtons(QMessageBox::Close);
vsWhereProcess.start( QSpacerItem* horizontalSpacer = new QSpacerItem(600, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
vsWherePath, QGridLayout* layout = reinterpret_cast<QGridLayout*>(vsWarningMessage.layout());
QStringList{ "-version", "16.0", "-latest", "-requires", "Microsoft.VisualStudio.Component.VC.Tools.x86.x64", layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount());
"-property", "isComplete" }); vsWarningMessage.exec();
if (!vsWhereProcess.waitForStarted())
{
return false;
}
while (vsWhereProcess.waitForReadyRead())
{
} }
QString vsWhereOutput(vsWhereProcess.readAllStandardOutput()); return findCompilerResult.IsSuccess();
if (vsWhereOutput.startsWith("1"))
{
return true;
}
}
return false;
}
bool IsVS2019Installed()
{
static bool vs2019Installed = IsVS2019Installed_internal();
return vs2019Installed;
} }
ProjectManagerScreen GetProjectManagerScreen(const QString& screen) ProjectManagerScreen GetProjectManagerScreen(const QString& screen)

@ -8,6 +8,7 @@
#include <ScreenDefs.h> #include <ScreenDefs.h>
#include <QWidget> #include <QWidget>
#include <AzCore/Outcome/Outcome.h>
namespace O3DE::ProjectManager namespace O3DE::ProjectManager
{ {
@ -23,7 +24,8 @@ namespace O3DE::ProjectManager
bool ReplaceFile(const QString& origFile, const QString& newFile, QWidget* parent = nullptr, bool interactive = true); bool ReplaceFile(const QString& origFile, const QString& newFile, QWidget* parent = nullptr, bool interactive = true);
bool IsVS2019Installed(); bool FindSupportedCompiler(QWidget* parent = nullptr);
AZ::Outcome<void, QString> FindSupportedCompilerForPlatform();
ProjectManagerScreen GetProjectManagerScreen(const QString& screen); ProjectManagerScreen GetProjectManagerScreen(const QString& screen);
} // namespace ProjectUtils } // namespace ProjectUtils

@ -516,7 +516,7 @@ namespace O3DE::ProjectManager
bool ProjectsScreen::StartProjectBuild(const ProjectInfo& projectInfo) bool ProjectsScreen::StartProjectBuild(const ProjectInfo& projectInfo)
{ {
if (ProjectUtils::IsVS2019Installed()) if (ProjectUtils::FindSupportedCompiler(this))
{ {
QMessageBox::StandardButton buildProject = QMessageBox::information( QMessageBox::StandardButton buildProject = QMessageBox::information(
this, this,

Loading…
Cancel
Save