]> Creatis software - crea.git/commitdiff
Feature #1711
authorDaniel Gonzalez <daniel.gonzalez@creatis.insa-lyon.fr>
Wed, 2 Jan 2013 13:09:04 +0000 (14:09 +0100)
committerDaniel Gonzalez <daniel.gonzalez@creatis.insa-lyon.fr>
Wed, 2 Jan 2013 13:09:04 +0000 (14:09 +0100)
CreaDevManager application implementation

-Project configuration implemented for Linux
-Project compilation implemented for Linux
-Plugging Packages implemented for Linux

lib/creaDevManagerLib/CDMUtilities.cpp
lib/creaDevManagerLib/CDMUtilities.h
lib/creaDevManagerLib/modelCDMProject.cpp
lib/creaDevManagerLib/wxCDMMainFrame.cpp
lib/creaDevManagerLib/wxCDMProjectActionsPanel.cpp
lib/creaDevManagerLib/wxCDMProjectActionsPanel.h

index f0a538e00ee124e2114a4a79cab2e0edc88c1864..431ebef21c7477ab7564fb035103960661705b33 100644 (file)
@@ -135,9 +135,12 @@ namespace CDMUtilities
     return system(comm.c_str());
   }
 
-  int openTerminal()
+  int openTerminal(const std::string& command)
   {
-    std::string comm = TERMINAL + "&";
+    std::string comm = TERMINAL;
+    if (command != "")
+      comm += + " " + command;
+    comm += " &";
     return system(comm.c_str());
   }
 
index 9bfa1d98a144608e42dc1a78252c19bd9b206840..10509896178dc2cd00e1240313a0b0e612fe9194 100644 (file)
@@ -105,7 +105,7 @@ namespace CDMUtilities
   int openFileWithCommand(const std::string& file, const std::string& command);
   int openBBEditor();
   int openCreaToolsTools();
-  int openTerminal();
+  int openTerminal(const std::string& command = "");
 };
 
 #endif /* CDMUTILITIES_H_ */
index c844798f12aca27205df8eea930e35bc6ad02c4d..00d846edddb9372371639799572bd94b8ae1504f 100644 (file)
@@ -281,7 +281,7 @@ bool modelCDMProject::SetVersion(const std::string& version, std::string*& resul
       else if(line.find("SET(PROJECT_BUILD_VERSION") != std::string::npos)
         line = "SET(PROJECT_BUILD_VERSION " + vers[2] + ")";
       else if(line.find("SET(PROJECT_VERSION_DATE") != std::string::npos)
-              line = "SET(PROJECT_VERSION_DATE \"" + date.str() + "\")";
+        line = "SET(PROJECT_VERSION_DATE \"" + date.str() + "\")";
       out << line << std::endl;
     }
   in.close();
@@ -667,18 +667,103 @@ const bool modelCDMProject::Refresh(std::string*& result)
 
 bool modelCDMProject::ConfigureBuild(std::string*& result)
 {
-  //TODO: implement method
+  //TODO: adjust for windows and mac
+#ifdef _WIN32
+  // ------ Windows
+#elif __APPLE__
+  // ------ Apple
+#else
+  // ------ Linux
+  //open binary folder
+  wxDir dir(crea::std2wx((this->buildPath).c_str()));
+
+  //if folder doesn't exist then create it
+  if (!dir.IsOpened())
+    {
+      //create command line to create folder
+      std::string createComm = "mkdir \"" + this->buildPath + "\"";
+      //execute creation command
+      if (system(createComm.c_str()))
+        {
+          //if there was an error then report it
+          result = new std::string("There was an error creating the build path: \"" + this->buildPath + "\"");
+          return false;
+        }
+    }
+  //create command line to execute ccmake
+  //TODO:: adjust for different Linux distributions
+  std::string confComm = "gnome-terminal --tab --working-directory=\"" + this->buildPath + "\" -e \"ccmake '" + this->path + "'\"";
+  //execute command
+  if(CDMUtilities::openTerminal(confComm))
+    {
+      //if there was an error then report it
+      result = new std::string("There was an error opening the configuration tool in the desired place.");
+      return false;
+    }
+#endif
   return true;
 }
 
 bool modelCDMProject::Build(std::string*& result)
 {
-  //TODO: implement method
+  //TODO: adjust for windows and mac
+#ifdef _WIN32
+  // ------ Windows
+#elif __APPLE__
+  // ------ Apple
+#else
+  // ------ Linux
+  //open binary folder
+  wxDir dir(crea::std2wx((this->buildPath).c_str()));
+
+  //if binary folder can't be opened then return false
+  if (!dir.IsOpened())
+    {
+      result = new std::string("The build path could not be opened. Make sure to configure the project before compiling it");
+      return false;
+    }
+  //create make command
+  std::string makeComm = "make -C \"" + this->buildPath + "\" > \"" + this->buildPath + CDMUtilities::SLASH + "building.log\" 2>&1";
+  std::cout << "executing '" << makeComm << "'" << std::endl;
+  //execute make command
+  if(system(makeComm.c_str()))
+    {
+      //if there was an error then report it
+      result = new std::string("There was an error compiling the project, please check the \"building.log\" file located in the build folder to read more about the problem.");
+      return false;
+    }
+#endif
   return true;
 }
 
 bool modelCDMProject::Connect(std::string*& result)
 {
-  //TODO: implement method
-  return true;
+  //TODO: adjust for windows and mac
+  #ifdef _WIN32
+    // ------ Windows
+  #elif __APPLE__
+    // ------ Apple
+  #else
+    // ------ Linux
+    //open binary folder
+    wxDir dir(crea::std2wx((this->buildPath).c_str()));
+
+    //if binary folder can't be opened then return false
+    if (!dir.IsOpened())
+      {
+        result = new std::string("The build path could not be opened. Make sure to configure the project before compiling it");
+        return false;
+      }
+    //create plug command
+    std::string plugComm = "bbPlugPackage \"" + this->buildPath + "\" > \"" + this->buildPath + CDMUtilities::SLASH + "plugging.log\" 2>&1";
+    std::cout << "executing '" << plugComm << "'" << std::endl;
+    //execute plug command
+    if(system(plugComm.c_str()))
+      {
+        //if there was an error then report it
+        result = new std::string("There was an error plugging the packages of the project, please check the \"plugging.log\" file located in the build folder to read more about the problem.");
+        return false;
+      }
+  #endif
+    return true;
 }
index 7f5fc3afe4b8fda83ee96f92411e9c138b4aa96a..f26d9568dd3992a9852cc46b7c94b4249045d6d9 100755 (executable)
@@ -302,6 +302,7 @@ void wxCDMMainFrame::OnMenuNewProject(wxCommandEvent& event)
 
       panel_ProjectActions = new wxCDMProjectActionsPanel(
           this,
+          this->model->GetProject(),
           ID_WINDOW_PROJ_ACTIONS,
           wxT("Project Actions Panel"),
           wxDefaultPosition,
@@ -392,6 +393,7 @@ void wxCDMMainFrame::OnMenuOpenProject(wxCommandEvent& event)
         }
       panel_ProjectActions = new wxCDMProjectActionsPanel(
           this,
+          this->model->GetProject(),
           ID_WINDOW_PROJ_ACTIONS,
           wxT("Project Actions Panel"),
           wxDefaultPosition,
index 1ad28aa5bdbf1d0e831dd5d33c3b7b06bc2b4265..5c92a7965377ae8960c00136bece7cd22cb0aebb 100755 (executable)
 BEGIN_EVENT_TABLE(wxCDMProjectActionsPanel, wxPanel)
 EVT_BUTTON(ID_BUTTON_BUILD_PROJECT, wxCDMProjectActionsPanel::OnBtnBuildProject)
 EVT_BUTTON(ID_BUTTON_CONFIGURE_BUILD, wxCDMProjectActionsPanel::OnBtnConfigureBuild)
-EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMProjectActionsPanel::OnBtnEditCMakeLists)
 EVT_BUTTON(ID_BUTTON_CONNECT_PROJECT, wxCDMProjectActionsPanel::OnBtnConnectProject)
 END_EVENT_TABLE()
 
 wxCDMProjectActionsPanel::wxCDMProjectActionsPanel(
     wxWindow* parent,
+    modelCDMProject* project,
     wxWindowID id,
     const wxString& caption,
     const wxPoint& pos,
@@ -52,6 +52,7 @@ wxCDMProjectActionsPanel::wxCDMProjectActionsPanel(
 )
 {
   wxCDMProjectActionsPanel::Create(parent,id,caption,pos,size,style);
+  this->project = project;
 }
 
 wxCDMProjectActionsPanel::~wxCDMProjectActionsPanel()
@@ -89,30 +90,38 @@ void wxCDMProjectActionsPanel::CreateControls()
   this->GetSizer()->Add(plugbt, 0, wxALL, 5);
 }
 
-void wxCDMProjectActionsPanel::OnBtnBuildProject(wxCommandEvent& event)
-{
-  //TODO: implement method
-  std::cerr << "Event OnBtnBuildProject not implemented" << std::endl;
-  event.Skip();
-}
-
+//configure project
 void wxCDMProjectActionsPanel::OnBtnConfigureBuild(wxCommandEvent& event)
 {
-  //TODO: implement method
-  std::cerr << "Event OnBtnConfigureBuild not implemented" << std::endl;
-  event.Skip();
+  std::string* result;
+  if(!this->project->ConfigureBuild(result))
+    {
+      wxMessageBox(crea::std2wx(result->c_str()), wxT("Project Configuration - Error!"));
+      return;
+    }
+  wxMessageBox(crea::std2wx("The configuration was executed successfully."), wxT("Project Configuration"));
 }
 
-void wxCDMProjectActionsPanel::OnBtnEditCMakeLists(wxCommandEvent& event)
+//compile project
+void wxCDMProjectActionsPanel::OnBtnBuildProject(wxCommandEvent& event)
 {
-  //TODO: implement method
-  std::cerr << "Event OnBtnEditCMakeLists not implemented" << std::endl;
-  event.Skip();
+  std::string* result;
+  if(!this->project->Build(result))
+    {
+      wxMessageBox(crea::std2wx(result->c_str()), wxT("Project Compilation - Error!"));
+      return;
+    }
+  wxMessageBox(crea::std2wx("The compilation was executed successfully. Please check the \"building.log\" file located in the build folder to check the compilation result."), wxT("Project Compilation"));
 }
 
+//plug packages
 void wxCDMProjectActionsPanel::OnBtnConnectProject(wxCommandEvent& event)
 {
-  //TODO: implement method
-  std::cerr << "Event OnBtnConnectProject not implemented" << std::endl;
-  event.Skip();
+  std::string* result;
+  if(!this->project->Connect(result))
+      {
+        wxMessageBox(crea::std2wx(result->c_str()), wxT("Plug Packages - Error!"));
+        return;
+      }
+    wxMessageBox(crea::std2wx("The connection was executed successfully. Please check the \"plugging.log\" file located in the build folder to check the compilation result."), wxT("Plug Package"));
 }
index 48ce66945d1024b9d1d8c22400f08453c784f562..d01e9e5c0c0f1dd18452f3fae97a1f94c6d273b4 100755 (executable)
 #include <creaWx.h>
 #include <wx/panel.h>
 
+#include "modelCDMProject.h"
+
 class wxCDMProjectActionsPanel : public wxPanel
 {
   DECLARE_EVENT_TABLE()
 public:
   wxCDMProjectActionsPanel(
       wxWindow* parent,
+      modelCDMProject* project,
       wxWindowID id = -1,
       const wxString& caption = _("Description Frame"),
       const wxPoint& pos = wxDefaultPosition,
@@ -64,10 +67,12 @@ public:
 protected:
   void CreateControls();
 
-  void OnBtnBuildProject(wxCommandEvent& event);
   void OnBtnConfigureBuild(wxCommandEvent& event);
-  void OnBtnEditCMakeLists(wxCommandEvent& event);
+  void OnBtnBuildProject(wxCommandEvent& event);
   void OnBtnConnectProject(wxCommandEvent& event);
+
+private:
+  modelCDMProject* project;
 };
 
 #endif /* WXCDMPROJECTACTIONSPANEL_H_ */