|
|
|
@ -313,33 +313,38 @@ namespace O3DE::ProjectManager
|
|
|
|
|
|
|
|
|
|
|
|
bool PythonBindings::RegisterThisEngine()
|
|
|
|
bool PythonBindings::RegisterThisEngine()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool registerThis = true;
|
|
|
|
bool registrationResult = true; // already registered is considered successful
|
|
|
|
|
|
|
|
bool pythonResult = ExecuteWithLock(
|
|
|
|
// check current engine path against all other registered engines
|
|
|
|
[&]
|
|
|
|
// to see if we are already registered
|
|
|
|
|
|
|
|
auto allEngines = m_registration.attr("get_engines")();
|
|
|
|
|
|
|
|
if (pybind11::isinstance<pybind11::list>(allEngines))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for (const auto& engine : allEngines)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
AZ::IO::FixedMaxPath enginePath(Py_To_String(engine["path"]));
|
|
|
|
bool registerThis = true;
|
|
|
|
if (enginePath.Compare(m_enginePath) == 0)
|
|
|
|
|
|
|
|
|
|
|
|
// check current engine path against all other registered engines
|
|
|
|
|
|
|
|
// to see if we are already registered
|
|
|
|
|
|
|
|
auto allEngines = m_registration.attr("get_engines")();
|
|
|
|
|
|
|
|
if (pybind11::isinstance<pybind11::list>(allEngines))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
registerThis = false;
|
|
|
|
for (const auto& engine : allEngines)
|
|
|
|
break;
|
|
|
|
{
|
|
|
|
|
|
|
|
AZ::IO::FixedMaxPath enginePath(Py_To_String(engine["path"]));
|
|
|
|
|
|
|
|
if (enginePath.Compare(m_enginePath) == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
registerThis = false;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool result = true;
|
|
|
|
if (registerThis)
|
|
|
|
if (registerThis)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto result = m_registration.attr("register")(m_enginePath.c_str());
|
|
|
|
auto registrationResult = m_registration.attr("register")(m_enginePath.c_str());
|
|
|
|
registrationResult = (result.cast<int>() == 0);
|
|
|
|
result = (registrationResult.cast<int>() == 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
AZ_Assert(result, "Registration of this engine failed!");
|
|
|
|
bool finalResult = (registrationResult && pythonResult);
|
|
|
|
return result;
|
|
|
|
AZ_Assert(finalResult, "Registration of this engine failed!");
|
|
|
|
|
|
|
|
return finalResult;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PythonBindings::ExecuteWithLock(AZStd::function<void()> executionCallback)
|
|
|
|
bool PythonBindings::ExecuteWithLock(AZStd::function<void()> executionCallback)
|
|
|
|
|