Browse Source

add/remove gem python bindings

Alex Peterson 4 years ago
parent
commit
cfbae9a18b

+ 36 - 0
Code/Tools/ProjectManager/Source/PythonBindings.cpp

@@ -508,6 +508,42 @@ namespace O3DE::ProjectManager
         }
     }
 
+    bool PythonBindings::AddGemToProject(const QString& gemPath, const QString& projectPath)
+    {
+        bool result = ExecuteWithLock([&] {
+            pybind11::str pyGemPath     = gemPath.toStdString();
+            pybind11::str pyProjectPath = projectPath.toStdString();
+
+            m_registration.attr("add_gem_to_project")(
+                pybind11::none(), // gem_name
+                pyGemPath,
+                pybind11::none(), // gem_target
+                pybind11::none(), // project_name
+                pyProjectPath
+                );
+        });
+
+        return result;
+    }
+
+    bool PythonBindings::RemoveGemFromProject(const QString& gemPath, const QString& projectPath)
+    {
+        bool result = ExecuteWithLock([&] {
+            pybind11::str pyGemPath     = gemPath.toStdString();
+            pybind11::str pyProjectPath = projectPath.toStdString();
+
+            m_registration.attr("remove_gem_to_project")(
+                pybind11::none(), // gem_name
+                pyGemPath,
+                pybind11::none(), // gem_target
+                pybind11::none(), // project_name
+                pyProjectPath
+                );
+        });
+
+        return result;
+    }
+
     bool PythonBindings::UpdateProject([[maybe_unused]] const ProjectInfo& projectInfo)  
     {
         return false;

+ 2 - 0
Code/Tools/ProjectManager/Source/PythonBindings.h

@@ -47,6 +47,8 @@ namespace O3DE::ProjectManager
         AZ::Outcome<ProjectInfo> GetProject(const QString& path) override;
         AZ::Outcome<QVector<ProjectInfo>> GetProjects() override;
         bool UpdateProject(const ProjectInfo& projectInfo) override;
+        bool AddGemToProject(const QString& gemPath, const QString& projectPath) override;
+        bool RemoveGemFromProject(const QString& gemPath, const QString& projectPath) override;
 
         // ProjectTemplate
         AZ::Outcome<QVector<ProjectTemplateInfo>> GetProjectTemplates() override;

+ 16 - 0
Code/Tools/ProjectManager/Source/PythonBindingsInterface.h

@@ -96,6 +96,22 @@ namespace O3DE::ProjectManager
          */
         virtual bool UpdateProject(const ProjectInfo& projectInfo) = 0;
 
+        /**
+         * Add a gem to a project
+         * @param gemPath the absolute path to the gem 
+         * @param projectPath the absolute path to the project
+         * @return true on success, false on failure
+         */
+        virtual bool AddGemToProject(const QString& gemPath, const QString& projectPath) = 0;
+
+        /**
+         * Remove gem to a project
+         * @param gemPath the absolute path to the gem 
+         * @param projectPath the absolute path to the project
+         * @return true on success, false on failure
+         */
+        virtual bool RemoveGemFromProject(const QString& gemPath, const QString& projectPath) = 0;
+
 
         // Project Templates