Added ability to list gem repos using CLI and integrated support into Project Manager
Signed-off-by: nggieber <nggieber@amazon.com>
This commit is contained in:
@@ -30,7 +30,7 @@ namespace O3DE::ProjectManager
|
||||
bool operator<(const GemRepoInfo& gemRepoInfo) const;
|
||||
|
||||
QString m_path = "";
|
||||
QString m_name = "Unknown Gem Repo Name";
|
||||
QString m_name = "Unknown Repo Name";
|
||||
QString m_creator = "Unknown Creator";
|
||||
bool m_isEnabled = false; //! Is the repo currently enabled for this engine?
|
||||
QString m_summary = "No summary provided.";
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <GemRepo/GemRepoItemDelegate.h>
|
||||
#include <GemRepo/GemRepoModel.h>
|
||||
#include <ProjectManagerDefs.h>
|
||||
|
||||
#include <QEvent>
|
||||
#include <QPainter>
|
||||
@@ -95,7 +96,7 @@ namespace O3DE::ProjectManager
|
||||
painter->drawText(repoCreatorRect, Qt::TextSingleLine, repoCreator);
|
||||
|
||||
// Repo update
|
||||
QString repoUpdatedDate = GemRepoModel::GetLastUpdated(modelIndex).toString("dd/MM/yyyy hh:mmap");
|
||||
QString repoUpdatedDate = GemRepoModel::GetLastUpdated(modelIndex).toString(RepoTimeFormat);
|
||||
repoUpdatedDate = standardFontMetrics.elidedText(repoUpdatedDate, Qt::TextElideMode::ElideRight, s_updatedMaxWidth);
|
||||
|
||||
QRect repoUpdatedDateRect = GetTextRect(standardFont, repoUpdatedDate, s_fontSize);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <GemRepo/GemRepoAddDialog.h>
|
||||
#include <GemRepo/GemRepoInspector.h>
|
||||
#include <PythonBindingsInterface.h>
|
||||
#include <ProjectManagerDefs.h>
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
@@ -104,9 +105,29 @@ namespace O3DE::ProjectManager
|
||||
{
|
||||
// Add all available repos to the model
|
||||
const QVector<GemRepoInfo> allGemRepoInfos = allGemRepoInfosResult.GetValue();
|
||||
QDateTime oldestRepoUpdate;
|
||||
if (!allGemRepoInfos.isEmpty())
|
||||
{
|
||||
oldestRepoUpdate = allGemRepoInfos[0].m_lastUpdated;
|
||||
}
|
||||
for (const GemRepoInfo& gemRepoInfo : allGemRepoInfos)
|
||||
{
|
||||
m_gemRepoModel->AddGemRepo(gemRepoInfo);
|
||||
|
||||
// Find least recently updated repo
|
||||
if (gemRepoInfo.m_lastUpdated < oldestRepoUpdate)
|
||||
{
|
||||
oldestRepoUpdate = gemRepoInfo.m_lastUpdated;
|
||||
}
|
||||
}
|
||||
|
||||
if (!allGemRepoInfos.isEmpty())
|
||||
{
|
||||
m_lastAllUpdateLabel->setText(tr("Last Updated: %1").arg(oldestRepoUpdate.toString(RepoTimeFormat)));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_lastAllUpdateLabel->setText(tr("Last Updated: Never"));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -26,4 +26,6 @@ namespace O3DE::ProjectManager
|
||||
static const QString ProjectCMakeCommand = "cmake";
|
||||
static const QString ProjectCMakeBuildTargetEditor = "Editor";
|
||||
|
||||
static const QString RepoTimeFormat = "dd/MM/yyyy hh:mmap";
|
||||
|
||||
} // namespace O3DE::ProjectManager
|
||||
|
||||
@@ -929,13 +929,55 @@ namespace O3DE::ProjectManager
|
||||
return AZ::Failure<AZStd::string>("Adding Gem Repo not implemented yet in o3de scripts.");
|
||||
}
|
||||
|
||||
GemRepoInfo PythonBindings::GemRepoInfoFromPath(pybind11::handle path, pybind11::handle pyEnginePath)
|
||||
GemRepoInfo PythonBindings::GetGemRepoInfo(pybind11::handle repoUri)
|
||||
{
|
||||
/* Placeholder Logic */
|
||||
(void)path;
|
||||
(void)pyEnginePath;
|
||||
GemRepoInfo gemRepoInfo;
|
||||
gemRepoInfo.m_repoLink = Py_To_String(repoUri);
|
||||
|
||||
return GemRepoInfo();
|
||||
auto data = m_manifest.attr("get_repo_json_data")(repoUri);
|
||||
if (pybind11::isinstance<pybind11::dict>(data))
|
||||
{
|
||||
try
|
||||
{
|
||||
// required
|
||||
gemRepoInfo.m_repoLink = Py_To_String(data["repo_uri"]);
|
||||
gemRepoInfo.m_name = Py_To_String(data["repo_name"]);
|
||||
gemRepoInfo.m_creator = Py_To_String(data["origin"]);
|
||||
|
||||
// optional
|
||||
gemRepoInfo.m_summary = Py_To_String_Optional(data, "summary", "No summary provided.");
|
||||
gemRepoInfo.m_additionalInfo = Py_To_String_Optional(data, "additional_info", "");
|
||||
|
||||
auto repoPath = m_manifest.attr("get_repo_path")(repoUri);
|
||||
gemRepoInfo.m_path = gemRepoInfo.m_directoryLink = Py_To_String(repoPath);
|
||||
|
||||
QString lastUpdated = Py_To_String_Optional(data, "last_updated", "");
|
||||
gemRepoInfo.m_lastUpdated = QDateTime::fromString(lastUpdated, RepoTimeFormat);
|
||||
|
||||
if (data.contains("enabled"))
|
||||
{
|
||||
gemRepoInfo.m_isEnabled = data["enabled"].cast<bool>();
|
||||
}
|
||||
else
|
||||
{
|
||||
gemRepoInfo.m_isEnabled = false;
|
||||
}
|
||||
|
||||
if (data.contains("gem_paths"))
|
||||
{
|
||||
for (auto gemPath : data["gem_paths"])
|
||||
{
|
||||
gemRepoInfo.m_includedGemPaths.push_back(Py_To_String(gemPath));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ([[maybe_unused]] const std::exception& e)
|
||||
{
|
||||
AZ_Warning("PythonBindings", false, "Failed to get GemRepoInfo for repo %s", Py_To_String(repoUri));
|
||||
}
|
||||
}
|
||||
|
||||
return gemRepoInfo;
|
||||
}
|
||||
|
||||
//#define MOCK_GEM_REPO_INFO true
|
||||
@@ -948,14 +990,10 @@ namespace O3DE::ProjectManager
|
||||
auto result = ExecuteWithLockErrorHandling(
|
||||
[&]
|
||||
{
|
||||
/* Placeholder Logic, o3de scripts need method added
|
||||
*
|
||||
for (auto path : m_manifest.attr("get_gem_repos")())
|
||||
for (auto repoUri : m_manifest.attr("get_repos")())
|
||||
{
|
||||
gemRepos.push_back(GemRepoInfoFromPath(path, pybind11::none()));
|
||||
gemRepos.push_back(GetGemRepoInfo(repoUri));
|
||||
}
|
||||
*
|
||||
*/
|
||||
});
|
||||
if (!result.IsSuccess())
|
||||
{
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace O3DE::ProjectManager
|
||||
AZ::Outcome<void, AZStd::string> ExecuteWithLockErrorHandling(AZStd::function<void()> executionCallback);
|
||||
bool ExecuteWithLock(AZStd::function<void()> executionCallback);
|
||||
GemInfo GemInfoFromPath(pybind11::handle path, pybind11::handle pyProjectPath);
|
||||
GemRepoInfo GemRepoInfoFromPath(pybind11::handle path, pybind11::handle pyEnginePath);
|
||||
GemRepoInfo GetGemRepoInfo(pybind11::handle repoUri);
|
||||
ProjectInfo ProjectInfoFromPath(pybind11::handle path);
|
||||
ProjectTemplateInfo ProjectTemplateInfoFromPath(pybind11::handle path, pybind11::handle pyProjectPath);
|
||||
bool RegisterThisEngine();
|
||||
|
||||
Reference in New Issue
Block a user