]> Creatis software - crea.git/blobdiff - lib/creaDevManagerLib/modelCDMProject.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / modelCDMProject.cpp
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;
 }