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());
}
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_ */
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();
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;
}
panel_ProjectActions = new wxCDMProjectActionsPanel(
this,
+ this->model->GetProject(),
ID_WINDOW_PROJ_ACTIONS,
wxT("Project Actions Panel"),
wxDefaultPosition,
}
panel_ProjectActions = new wxCDMProjectActionsPanel(
this,
+ this->model->GetProject(),
ID_WINDOW_PROJ_ACTIONS,
wxT("Project Actions Panel"),
wxDefaultPosition,
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,
)
{
wxCDMProjectActionsPanel::Create(parent,id,caption,pos,size,style);
+ this->project = project;
}
wxCDMProjectActionsPanel::~wxCDMProjectActionsPanel()
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"));
}
#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,
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_ */