Fixing the enable_gem.py and disable_gem.py commands (#1207)

* Fixing the enable_gem.py and disable_gem.py commands
The project path wasn't taking into account when querying for gems,
templates and restricted directories registered with the project

Fixing the cmake.py add_gem_dependency and remove_gem_dependency methods
to properly detect a gem within a `set(ENABLED_GEM ...)` cmake variable
Also updated the add_gem_dependency to add the gem right before the end
marker of ')'
Updated the remove_gem_dependency to remove each instance of a gem with
a content that is in between in the `set(ENABLED_GEM ...)` cmake
variable

* Correct Typo in manifest.get_registered doc string
This commit is contained in:
lumberyard-employee-dm
2021-06-09 14:14:01 -05:00
committed by GitHub
parent b26b472bba
commit 217eddc8bd
8 changed files with 302 additions and 55 deletions
@@ -452,9 +452,9 @@ namespace O3DE::ProjectManager
return result;
}
AZ::Outcome<GemInfo> PythonBindings::GetGemInfo(const QString& path)
AZ::Outcome<GemInfo> PythonBindings::GetGemInfo(const QString& path, const QString& projectPath)
{
GemInfo gemInfo = GemInfoFromPath(pybind11::str(path.toStdString()));
GemInfo gemInfo = GemInfoFromPath(pybind11::str(path.toStdString()), pybind11::str(projectPath.toStdString()));
if (gemInfo.IsValid())
{
return AZ::Success(AZStd::move(gemInfo));
@@ -473,7 +473,7 @@ namespace O3DE::ProjectManager
{
for (auto path : m_manifest.attr("get_engine_gems")())
{
gems.push_back(GemInfoFromPath(path));
gems.push_back(GemInfoFromPath(path, pybind11::none()));
}
});
if (!result.IsSuccess())
@@ -494,7 +494,7 @@ namespace O3DE::ProjectManager
pybind11::str pyProjectPath = projectPath.toStdString();
for (auto path : m_manifest.attr("get_all_gems")(pyProjectPath))
{
gems.push_back(GemInfoFromPath(path));
gems.push_back(GemInfoFromPath(path, pyProjectPath));
}
});
if (!result.IsSuccess())
@@ -632,12 +632,12 @@ namespace O3DE::ProjectManager
}
}
GemInfo PythonBindings::GemInfoFromPath(pybind11::handle path)
GemInfo PythonBindings::GemInfoFromPath(pybind11::handle path, pybind11::handle pyProjectPath)
{
GemInfo gemInfo;
gemInfo.m_path = Py_To_String(path);
auto data = m_manifest.attr("get_gem_json_data")(pybind11::none(), path);
auto data = m_manifest.attr("get_gem_json_data")(pybind11::none(), path, pyProjectPath);
if (pybind11::isinstance<pybind11::dict>(data))
{
try
@@ -782,12 +782,12 @@ namespace O3DE::ProjectManager
});
}
ProjectTemplateInfo PythonBindings::ProjectTemplateInfoFromPath(pybind11::handle path)
ProjectTemplateInfo PythonBindings::ProjectTemplateInfoFromPath(pybind11::handle path, pybind11::handle pyProjectPath)
{
ProjectTemplateInfo templateInfo;
templateInfo.m_path = Py_To_String(pybind11::str(path));
auto data = m_manifest.attr("get_template_json_data")(pybind11::none(), path);
auto data = m_manifest.attr("get_template_json_data")(pybind11::none(), path, pyProjectPath);
if (pybind11::isinstance<pybind11::dict>(data))
{
try
@@ -829,14 +829,15 @@ namespace O3DE::ProjectManager
return templateInfo;
}
AZ::Outcome<QVector<ProjectTemplateInfo>> PythonBindings::GetProjectTemplates()
AZ::Outcome<QVector<ProjectTemplateInfo>> PythonBindings::GetProjectTemplates(const QString& projectPath)
{
QVector<ProjectTemplateInfo> templates;
bool result = ExecuteWithLock([&] {
pybind11::str pyProjectPath = projectPath.toStdString();
for (auto path : m_manifest.attr("get_templates_for_project_creation")())
{
templates.push_back(ProjectTemplateInfoFromPath(path));
templates.push_back(ProjectTemplateInfoFromPath(path, pyProjectPath));
}
});