/* * 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 * */ #pragma once #include #include #include // Qt defines slots, which interferes with the use here. #pragma push_macro("slots") #undef slots #include #include #pragma pop_macro("slots") namespace O3DE::ProjectManager { class PythonBindings : public PythonBindingsInterface::Registrar { public: PythonBindings() = default; PythonBindings(const AZ::IO::PathView& enginePath); ~PythonBindings() override; // PythonBindings overrides bool PythonStarted() override; // Engine AZ::Outcome GetEngineInfo() override; bool SetEngineInfo(const EngineInfo& engineInfo) override; // Gem AZ::Outcome GetGemInfo(const QString& path, const QString& projectPath = {}) override; AZ::Outcome, AZStd::string> GetEngineGemInfos() override; AZ::Outcome, AZStd::string> GetAllGemInfos(const QString& projectPath) override; AZ::Outcome, AZStd::string> GetEnabledGemNames(const QString& projectPath) override; // Project AZ::Outcome CreateProject(const QString& projectTemplatePath, const ProjectInfo& projectInfo) override; AZ::Outcome GetProject(const QString& path) override; AZ::Outcome> GetProjects() override; bool AddProject(const QString& path) override; bool RemoveProject(const QString& path) override; AZ::Outcome UpdateProject(const ProjectInfo& projectInfo) override; AZ::Outcome AddGemToProject(const QString& gemPath, const QString& projectPath) override; AZ::Outcome RemoveGemFromProject(const QString& gemPath, const QString& projectPath) override; bool RemoveInvalidProjects() override; // ProjectTemplate AZ::Outcome> GetProjectTemplates(const QString& projectPath = {}) override; // Gem Repos AZ::Outcome, AZStd::string> GetAllGemRepoInfos() override; private: AZ_DISABLE_COPY_MOVE(PythonBindings); AZ::Outcome ExecuteWithLockErrorHandling(AZStd::function executionCallback); bool ExecuteWithLock(AZStd::function executionCallback); GemInfo GemInfoFromPath(pybind11::handle path, pybind11::handle pyProjectPath); GemRepoInfo GemRepoInfoFromPath(pybind11::handle path, pybind11::handle pyEnginePath); ProjectInfo ProjectInfoFromPath(pybind11::handle path); ProjectTemplateInfo ProjectTemplateInfoFromPath(pybind11::handle path, pybind11::handle pyProjectPath); bool RegisterThisEngine(); bool StartPython(); bool StopPython(); bool m_pythonStarted = false; AZ::IO::FixedMaxPath m_enginePath; AZStd::recursive_mutex m_lock; pybind11::handle m_engineTemplate; pybind11::handle m_cmake; pybind11::handle m_register; pybind11::handle m_manifest; pybind11::handle m_enableGemProject; pybind11::handle m_disableGemProject; pybind11::handle m_editProjectProperties; pybind11::handle m_pathlib; }; }