From cd4ae62285af30451b264ceb3202e1e912740fc7 Mon Sep 17 00:00:00 2001 From: Daniel Gonzalez Date: Wed, 2 Jan 2013 14:09:04 +0100 Subject: [PATCH] Feature #1711 CreaDevManager application implementation -Project configuration implemented for Linux -Project compilation implemented for Linux -Plugging Packages implemented for Linux --- lib/creaDevManagerLib/CDMUtilities.cpp | 7 +- lib/creaDevManagerLib/CDMUtilities.h | 2 +- lib/creaDevManagerLib/modelCDMProject.cpp | 95 ++++++++++++++++++- lib/creaDevManagerLib/wxCDMMainFrame.cpp | 2 + .../wxCDMProjectActionsPanel.cpp | 45 +++++---- .../wxCDMProjectActionsPanel.h | 9 +- 6 files changed, 132 insertions(+), 28 deletions(-) diff --git a/lib/creaDevManagerLib/CDMUtilities.cpp b/lib/creaDevManagerLib/CDMUtilities.cpp index f0a538e..431ebef 100644 --- a/lib/creaDevManagerLib/CDMUtilities.cpp +++ b/lib/creaDevManagerLib/CDMUtilities.cpp @@ -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()); } diff --git a/lib/creaDevManagerLib/CDMUtilities.h b/lib/creaDevManagerLib/CDMUtilities.h index 9bfa1d9..1050989 100644 --- a/lib/creaDevManagerLib/CDMUtilities.h +++ b/lib/creaDevManagerLib/CDMUtilities.h @@ -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_ */ diff --git a/lib/creaDevManagerLib/modelCDMProject.cpp b/lib/creaDevManagerLib/modelCDMProject.cpp index c844798..00d846e 100644 --- a/lib/creaDevManagerLib/modelCDMProject.cpp +++ b/lib/creaDevManagerLib/modelCDMProject.cpp @@ -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; } diff --git a/lib/creaDevManagerLib/wxCDMMainFrame.cpp b/lib/creaDevManagerLib/wxCDMMainFrame.cpp index 7f5fc3a..f26d956 100755 --- a/lib/creaDevManagerLib/wxCDMMainFrame.cpp +++ b/lib/creaDevManagerLib/wxCDMMainFrame.cpp @@ -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, diff --git a/lib/creaDevManagerLib/wxCDMProjectActionsPanel.cpp b/lib/creaDevManagerLib/wxCDMProjectActionsPanel.cpp index 1ad28aa..5c92a79 100755 --- a/lib/creaDevManagerLib/wxCDMProjectActionsPanel.cpp +++ b/lib/creaDevManagerLib/wxCDMProjectActionsPanel.cpp @@ -38,12 +38,12 @@ 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")); } diff --git a/lib/creaDevManagerLib/wxCDMProjectActionsPanel.h b/lib/creaDevManagerLib/wxCDMProjectActionsPanel.h index 48ce669..d01e9e5 100755 --- a/lib/creaDevManagerLib/wxCDMProjectActionsPanel.h +++ b/lib/creaDevManagerLib/wxCDMProjectActionsPanel.h @@ -39,12 +39,15 @@ #include #include +#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_ */ -- 2.45.1