]> Creatis software - crea.git/blob - lib/creaDevManagerLib/modelCDMProject.cpp
Feature #1711
[crea.git] / lib / creaDevManagerLib / modelCDMProject.cpp
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
5 #                        pour la Sant�)
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 #
10 #  This software is governed by the CeCILL-B license under French law and 
11 #  abiding by the rules of distribution of free software. You can  use, 
12 #  modify and/ or redistribute the software under the terms of the CeCILL-B 
13 #  license as circulated by CEA, CNRS and INRIA at the following URL 
14 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
15 #  or in the file LICENSE.txt.
16 #
17 #  As a counterpart to the access to the source code and  rights to copy,
18 #  modify and redistribute granted by the license, users are provided only
19 #  with a limited warranty  and the software's author,  the holder of the
20 #  economic rights,  and the successive licensors  have only  limited
21 #  liability. 
22 #
23 #  The fact that you are presently reading this means that you have had
24 #  knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ 
26  */
27
28 /*
29  * modelCDMProject.cpp
30  *
31  *  Created on: 13/11/2012
32  *      Author: Daniel Felipe Gonzalez Obando
33  */
34
35 #include "modelCDMProject.h"
36
37 #include <iostream>
38 #include <sstream>
39 #include <vector>
40 #include <algorithm>
41 #include <fstream>
42 #include <ctime>
43
44 #include "CDMUtilities.h"
45 #include "creaWx.h"
46 #include "wx/dir.h"
47
48 modelCDMProject::modelCDMProject()
49 {
50   std::cout << "in constructor1" << std::endl;
51   this->appli = NULL;
52   this->lib = NULL;
53   this->CMakeLists = NULL;
54 }
55
56 modelCDMProject::modelCDMProject(
57     modelCDMIProjectTreeNode* parent,
58     const std::string& path,
59     const std::string& name,
60     const std::string& buildPath
61 )
62 {
63   std::cout << "creating project: " + name + " in " + path + "\n";
64   this->parent = parent;
65   this->path = CDMUtilities::fixPath(path);
66   //open makelists file
67   std::string pathFixed(CDMUtilities::fixPath(path));
68
69   std::string pathMakeLists = pathFixed + CDMUtilities::SLASH + "CMakeLists.txt";
70
71   std::ifstream confFile;
72   confFile.open((pathMakeLists).c_str());
73
74   std::string word;
75   while(confFile.is_open() && !confFile.eof())
76     {
77       //std::cout << "leyendo " << word << std::endl;
78       //get project name
79       std::getline(confFile,word,'(');
80       std::vector<std::string> wordBits;
81       CDMUtilities::splitter::split(wordBits,word," (\n",CDMUtilities::splitter::no_empties);
82
83       if(wordBits[wordBits.size()-1] == "PROJECT")
84         {
85           std::getline(confFile,word,')');
86           std::vector<std::string> nameBits;
87           CDMUtilities::splitter::split(nameBits, word, " ", CDMUtilities::splitter::no_empties);
88
89           this->name = this->nameProject = "";
90           for (int i = 0; i < nameBits.size(); i++)
91             {
92               if(i != 0)
93                 this->name += " ";
94               this->name += nameBits[i];
95             }
96           this->nameProject = this->name;
97
98         }
99
100
101       if(wordBits[wordBits.size()-1] == "SET")
102         {
103           //get project version
104           std::getline(confFile,word,')');
105           CDMUtilities::splitter::split(wordBits, word, " ", CDMUtilities::splitter::no_empties);
106           if(wordBits[0] == "PROJECT_MAJOR_VERSION")
107             {
108               version = wordBits[1];
109             }
110           if(wordBits[0] == "PROJECT_MINOR_VERSION")
111             {
112               version += "." + wordBits[1];
113             }
114           if(wordBits[0] == "PROJECT_BUILD_VERSION")
115             {
116               version += "." + wordBits[1];
117             }
118
119           //get project versionDate
120           if(wordBits[0] == "PROJECT_VERSION_DATE")
121             {
122               std::vector<std::string> versionBits;
123               CDMUtilities::splitter::split(versionBits, wordBits[1], "\"", CDMUtilities::splitter::no_empties);
124               versionDate = versionBits[0];
125             }
126           //get project buildPath
127
128           if (buildPath != "")
129             {
130               this->buildPath = buildPath;
131             }
132           else
133             {
134               this->buildPath = this->path + "Bin";
135             }
136         }
137     }
138   confFile.close();
139
140   this->type = wxDIR_DIRS;
141   this->level = 0;
142
143   this->children.clear();
144   this->appli = NULL;
145   this->lib = NULL;
146   this->packages.clear();
147
148
149   //check all folders
150   wxDir dir(crea::std2wx((pathFixed).c_str()));
151   if (dir.IsOpened())
152     {
153       wxString fileName;
154       bool cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_DIRS);
155       while (cont)
156         {
157           std::string stdfileName = crea::wx2std(fileName);
158
159           //if appli, create appli
160           if(stdfileName == "appli")
161             {
162               this->appli = new modelCDMAppli(this, pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
163               this->children.push_back(this->appli);
164             }
165           //if lib, create lib
166           else if(stdfileName == "lib")
167             {
168               this->lib = new modelCDMLib(this, pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
169               this->children.push_back(this->lib);
170             }
171           //if package , create package
172           else if(stdfileName.size() > 9 && stdfileName.substr(0,5) == "bbtk_" && stdfileName.substr(stdfileName.size()-4,4) == "_PKG")
173             {
174               modelCDMPackage* package = new modelCDMPackage(this, pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
175               this->packages.push_back(package);
176               this->children.push_back(package);
177             }
178           //if is an unknown folder, create folder
179           else
180             {
181               this->children.push_back(new modelCDMFolder(this, pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
182             }
183
184           cont = dir.GetNext(&fileName);
185         }
186
187       cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_FILES);
188       while (cont)
189         {
190           std::string stdfileName = crea::wx2std(fileName);
191
192           //if CMakeLists, create CMakeLists
193           if(stdfileName == "CMakeLists.txt")
194             {
195               this->CMakeLists = new modelCDMCMakeListsFile(this, pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
196               this->children.push_back(this->CMakeLists);
197             }
198           else
199             {
200               this->children.push_back(new modelCDMFile(this, pathFixed + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1));
201             }
202           //if is an unknown file, create file
203           cont = dir.GetNext(&fileName);
204         }
205     }
206
207   this->SortChildren();
208   std::sort(this->packages.begin(), this->packages.end(), CompareNodeItem);
209
210 }
211
212 modelCDMProject::~modelCDMProject()
213 {
214 }
215
216 const std::string& modelCDMProject::GetNameProject() const
217 {
218   return this->nameProject;
219 }
220
221 const std::string& modelCDMProject::GetVersion() const
222 {
223   return this->version;
224 }
225
226 const std::string& modelCDMProject::GetVersionDate() const
227 {
228   return this->versionDate;
229 }
230
231 const std::string& modelCDMProject::GetBuildPath() const
232 {
233   return this->buildPath;
234 }
235
236 const std::vector<modelCDMPackage*>& modelCDMProject::GetPackages() const
237 {
238   return this->packages;
239 }
240
241 modelCDMAppli* modelCDMProject::GetAppli() const
242 {
243   return this->appli;
244 }
245
246 modelCDMLib* modelCDMProject::GetLib() const
247 {
248   return this->lib;
249 }
250
251 bool modelCDMProject::SetVersion(const std::string& version, std::string*& result)
252 {
253
254   std::vector<std::string> vers;
255   CDMUtilities::splitter::split(vers, version, " .", CDMUtilities::splitter::no_empties);
256
257   time_t now = time(0);
258   tm* ltm = localtime(&now);
259
260   std::stringstream date;
261   date << ltm->tm_mday << "/" << 1 + ltm->tm_mon << "/" << 1900 + ltm->tm_year;
262
263   //set name of library in CMakeLists inside copied folder
264   std::string line;
265   std::ifstream in((this->path + CDMUtilities::SLASH + "CMakeLists.txt").c_str());
266   if( !in.is_open())
267     {
268       result = new std::string("CMakeLists.txt file failed to open.");
269       return false;
270     }
271   std::ofstream out((this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp").c_str());
272   if( !out.is_open())
273     {
274       result = new std::string("CMakeLists.txt.tmp file failed to open.");
275       return false;
276     }
277   while (getline(in, line))
278     {
279       if(line.find("SET(PROJECT_MAJOR_VERSION") != std::string::npos)
280         line = "SET(PROJECT_MAJOR_VERSION " + vers[0] + ")";
281       else if(line.find("SET(PROJECT_MINOR_VERSION") != std::string::npos)
282         line = "SET(PROJECT_MINOR_VERSION " + vers[1] + ")";
283       else if(line.find("SET(PROJECT_BUILD_VERSION") != std::string::npos)
284         line = "SET(PROJECT_BUILD_VERSION " + vers[2] + ")";
285       else if(line.find("SET(PROJECT_VERSION_DATE") != std::string::npos)
286         line = "SET(PROJECT_VERSION_DATE \"" + date.str() + "\")";
287       out << line << std::endl;
288     }
289   in.close();
290   out.close();
291   //delete old file and rename new file
292   std::string renameCommand = "mv \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt.tmp\" \"" + this->path + CDMUtilities::SLASH + "CMakeLists.txt\"";
293   if(system(renameCommand.c_str()))
294     {
295       result = new std::string("An error occurred while running '" + renameCommand + "'.");
296       return false;
297     }
298
299   this->version = vers[0] + "." + vers[1] + "." + vers[2];
300   this->versionDate = date.str();
301   return true;
302 }
303
304 bool modelCDMProject::SetBuildPath(const std::string& path, std::string*& result)
305 {
306   if(path == "")
307     {
308       result = new std::string("The path cannot be empty");
309       return false;
310     }
311   if(path == this->path)
312     {
313       result = new std::string("The path cannot be same as the project sources");
314       return false;
315     }
316   this->buildPath = path;
317   return true;
318 }
319
320 modelCDMIProjectTreeNode* modelCDMProject::CreatePackage(
321     const std::string& name,
322     std::string*& result,
323     const std::string& authors,
324     const std::string& authorsEmail,
325     const std::string& description,
326     const std::string& version
327 )
328 {
329   //fixing input parameters
330   std::vector<std::string> words;
331
332   CDMUtilities::splitter::split(words,name," ",CDMUtilities::splitter::no_empties);
333   std::string nameFixed = "";
334   for (int i = 0; i < words.size(); i++)
335     {
336       nameFixed += words[i];
337     }
338
339   words.clear();
340   CDMUtilities::splitter::split(words,authors," ",CDMUtilities::splitter::no_empties);
341   std::string authorFixed;
342   for (int i = 0; i < words.size(); i++)
343     {
344       authorFixed += words[i];
345     }
346
347   words.clear();
348   std::string descriptionFixed;
349   CDMUtilities::splitter::split(words,authorsEmail," ",CDMUtilities::splitter::no_empties);
350   for (int i = 0; i < words.size(); i++)
351     {
352       descriptionFixed += words[i];
353     }
354   words.clear();
355   CDMUtilities::splitter::split(words,description," ",CDMUtilities::splitter::no_empties);
356   for (int i = 0; i < words.size(); i++)
357     {
358       descriptionFixed += "_" + words[i];
359     }
360
361   //call project to create package : use bbCreatePackage <path> <name> [author] [description]
362   std::string creationCommand = "bbCreatePackage \"" + this->path + "\" \"" + nameFixed + "\" \"" + authorFixed + "\" \"" + descriptionFixed + "\"";
363   //TODO: bbCreatePackage script always returning 0. It should return 1 or greater if any error
364   if(system(creationCommand.c_str()))
365     {
366       result = new std::string("An error occurred while running '" + creationCommand + "'.");
367       return NULL;
368     }
369
370   //add library to model
371   modelCDMPackage* package = new modelCDMPackage(this, this->path + CDMUtilities::SLASH + "bbtk_" + nameFixed + "_PKG", "bbtk_" + nameFixed + "_PKG", this->level + 1);
372   this->packages.push_back(package);
373   this->children.push_back(package);
374
375   //TODO: set package version
376
377   this->SortChildren();
378
379   result = new std::string(this->path + CDMUtilities::SLASH + name);
380   return package;
381 }
382
383 modelCDMIProjectTreeNode* modelCDMProject::CreateLibrary(
384     const std::string& name,
385     std::string*& result,
386     const std::string& path
387 )
388 {
389   if(this->lib != NULL)
390     {
391       return this->lib->CreateLibrary(name, result);
392     }
393   result = new std::string("there is no lib folder in this project.");
394   return NULL;
395 }
396
397 modelCDMIProjectTreeNode* modelCDMProject::CreateApplication(
398     const std::string& name,
399     std::string*& result,
400     const std::string& path
401 )
402 {
403   if(this->appli != NULL)
404     {
405       return this->appli->CreateApplication(name, result);
406     }
407   result = new std::string("there is no appli folder in this project.");
408   return NULL;
409 }
410
411 modelCDMIProjectTreeNode* modelCDMProject::CreateBlackBox(
412     const std::string& name,
413     const std::string& package,
414     const std::string& authors,
415     const std::string& authorsEmail,
416     const std::string& categories,
417     const std::string& description
418 )
419 {
420   //TODO: implement method
421   return NULL;
422 }
423
424 bool modelCDMProject::OpenCMakeListsFile(std::string*& result)
425 {
426   if (!CDMUtilities::openTextEditor(this->CMakeLists->GetPath()))
427     return true;
428   else
429     {
430       result = new std::string("Couldn't open CMakeLists file.");
431       return false;
432     }
433 }
434
435 const bool modelCDMProject::Refresh(std::string*& result)
436 {
437   std::cout << "refreshing project" << std::endl;
438   //open makelists file
439   std::string pathMakeLists = this->path + CDMUtilities::SLASH + "CMakeLists.txt";
440
441   std::ifstream confFile;
442   confFile.open((pathMakeLists).c_str());
443
444   std::string word;
445   while(confFile.is_open() && !confFile.eof())
446     {
447       //std::cout << "leyendo " << word << std::endl;
448       //get project name
449       std::getline(confFile,word,'(');
450       std::vector<std::string> wordBits;
451       CDMUtilities::splitter::split(wordBits,word," (\n",CDMUtilities::splitter::no_empties);
452
453       if(wordBits[wordBits.size()-1] == "PROJECT")
454         {
455           std::getline(confFile,word,')');
456           std::vector<std::string> nameBits;
457           CDMUtilities::splitter::split(nameBits, word, " ", CDMUtilities::splitter::no_empties);
458
459           this->name = this->nameProject = "";
460           for (int i = 0; i < nameBits.size(); i++)
461             {
462               if(i != 0)
463                 this->name += " ";
464               this->name += nameBits[i];
465             }
466           this->nameProject = this->name;
467
468         }
469
470
471       if(wordBits[wordBits.size()-1] == "SET")
472         {
473           //get project version
474           std::getline(confFile,word,')');
475           CDMUtilities::splitter::split(wordBits, word, " ", CDMUtilities::splitter::no_empties);
476           if(wordBits[0] == "PROJECT_MAJOR_VERSION")
477             {
478               version = wordBits[1];
479             }
480           if(wordBits[0] == "PROJECT_MINOR_VERSION")
481             {
482               version += "." + wordBits[1];
483             }
484           if(wordBits[0] == "PROJECT_BUILD_VERSION")
485             {
486               version += "." + wordBits[1];
487             }
488
489           //get project versionDate
490           if(wordBits[0] == "PROJECT_VERSION_DATE")
491             {
492               std::vector<std::string> versionBits;
493               CDMUtilities::splitter::split(versionBits, wordBits[1], "\"", CDMUtilities::splitter::no_empties);
494               versionDate = versionBits[0];
495             }
496         }
497     }
498   confFile.close();
499
500   this->type = wxDIR_DIRS;
501   this->level = 0;
502
503   std::vector<bool> checked(this->children.size(), false);
504   std::vector<bool> checkedPackages(this->packages.size(), false);
505
506   //check all folders
507   wxDir dir(crea::std2wx((this->path).c_str()));
508   if (dir.IsOpened())
509     {
510       wxString fileName;
511       bool cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_DIRS);
512       while (cont)
513         {
514           std::string stdfileName = crea::wx2std(fileName);
515
516           //if appli, create appli
517           if(stdfileName == "appli")
518             {
519               if (this->appli == NULL)
520                 {
521                   this->appli = new modelCDMAppli(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
522                   this->children.push_back(this->appli);
523                 }
524               else
525                 {
526                   int pos = std::find(this->children.begin(), this->children.end(), this->appli) - this->children.begin();
527                   checked[pos] = true;
528                   if(!this->appli->Refresh(result))
529                     return false;
530                 }
531             }
532           //if lib, create lib
533           else if(stdfileName == "lib")
534             {
535               if (this->lib == NULL)
536                 {
537                   this->lib = new modelCDMLib(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
538                   this->children.push_back(this->lib);
539                 }
540               else
541                 {
542                   int pos = std::find(this->children.begin(), this->children.end(), this->lib) - this->children.begin();
543                   checked[pos] = true;
544                   if(!this->lib->Refresh(result))
545                     return false;
546                 }
547
548             }
549           //if package , create package
550           else if(stdfileName.size() > 9 && stdfileName.substr(0,5) == "bbtk_" && stdfileName.substr(stdfileName.size()-4,4) == "_PKG")
551             {
552               bool found = false;
553               for (int i = 0; !found && i < this->packages.size(); i++)
554                 {
555                   if (this->packages[i]->GetName() == stdfileName)
556                     {
557                       found = true;
558                       int pos = std::find(this->children.begin(), this->children.end(), this->packages[i]) - this->children.begin();
559                       checked[pos] = true;
560                       checkedPackages[i] = true;
561                       if(!this->packages[i]->Refresh(result))
562                         return false;
563                     }
564                 }
565               if(!found)
566                 {
567                   modelCDMPackage* package = new modelCDMPackage(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
568                   this->packages.push_back(package);
569                   this->children.push_back(package);
570                 }
571
572             }
573           //if is an unknown folder, create folder
574           else
575             {
576               bool found = false;
577               for (int i = 0; !found && i < this->children.size(); i++)
578                 {
579                   if (this->children[i]->GetName() == stdfileName)
580                     {
581                       found = true;
582                       checked[i] = true;
583                       if(!this->children[i]->Refresh(result))
584                         return false;
585                     }
586                 }
587
588               if(!found)
589                 {
590                   modelCDMFolder* folder = new modelCDMFolder(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
591                   this->children.push_back(folder);
592                 }
593             }
594
595           cont = dir.GetNext(&fileName);
596         }
597
598       cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_FILES);
599       while (cont)
600         {
601           std::string stdfileName = crea::wx2std(fileName);
602
603           //if CMakeLists, create CMakeLists
604           if(stdfileName == "CMakeLists.txt")
605             {
606               if (this->CMakeLists == NULL)
607                 {
608                   this->CMakeLists = new modelCDMCMakeListsFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
609                   this->children.push_back(this->CMakeLists);
610                 }
611               else
612                 {
613                   int pos = std::find(this->children.begin(), this->children.end(), this->CMakeLists) - this->children.begin();
614                   checked[pos] = true;
615                   if(!this->CMakeLists->Refresh(result))
616                     return false;
617                 }
618             }
619           //if is an unknown file, create file
620           else
621             {
622               bool found = false;
623               for (int i = 0; !found && i < this->children.size(); i++)
624                 {
625                   if (this->children[i]->GetName() == stdfileName)
626                     {
627                       found = true;
628                       checked[i] = true;
629                       if(!this->children[i]->Refresh(result))
630                         return false;
631                     }
632                 }
633
634               if(!found)
635                 {
636                   modelCDMFile* file = new modelCDMFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1);
637                   this->children.push_back(file);
638                 }
639             }
640
641           cont = dir.GetNext(&fileName);
642         }
643     }
644
645   for (int i = 0; i < checkedPackages.size(); i++)
646     {
647       if(!checkedPackages[i])
648         {
649           this->packages.erase(this->packages.begin()+i);
650           checkedPackages.erase(checkedPackages.begin()+i);
651           i--;
652         }
653     }
654   for (int i = 0; i < checked.size(); i++)
655     {
656       if(!checked[i])
657         {
658           delete this->children[i];
659           this->children.erase(this->children.begin()+i);
660           checked.erase(checked.begin()+i);
661           i--;
662         }
663     }
664
665   this->SortChildren();
666   std::sort(this->packages.begin(), this->packages.end(), CompareNodeItem);
667   return true;
668 }
669
670 bool modelCDMProject::ConfigureBuild(std::string*& result)
671 {
672   //TODO: adjust for windows and mac
673 #ifdef _WIN32
674   // ------ Windows
675 #elif __APPLE__
676   // ------ Apple
677 #else
678   // ------ Linux
679   //open binary folder
680   wxDir dir(crea::std2wx((this->buildPath).c_str()));
681
682   //if folder doesn't exist then create it
683   if (!dir.IsOpened())
684     {
685       //create command line to create folder
686       std::string createComm = "mkdir \"" + this->buildPath + "\"";
687       //execute creation command
688       if (system(createComm.c_str()))
689         {
690           //if there was an error then report it
691           result = new std::string("There was an error creating the build path: \"" + this->buildPath + "\"");
692           return false;
693         }
694     }
695   //create command line to execute ccmake
696   //TODO:: adjust for different Linux distributions
697   std::string confComm = "gnome-terminal --tab --working-directory=\"" + this->buildPath + "\" -e \"ccmake '" + this->path + "'\"";
698   //execute command
699   if(CDMUtilities::openTerminal(confComm))
700     {
701       //if there was an error then report it
702       result = new std::string("There was an error opening the configuration tool in the desired place.");
703       return false;
704     }
705 #endif
706   return true;
707 }
708
709 bool modelCDMProject::Build(std::string*& result)
710 {
711   //TODO: adjust for windows and mac
712 #ifdef _WIN32
713   // ------ Windows
714 #elif __APPLE__
715   // ------ Apple
716 #else
717   // ------ Linux
718   //open binary folder
719   wxDir dir(crea::std2wx((this->buildPath).c_str()));
720
721   //if binary folder can't be opened then return false
722   if (!dir.IsOpened())
723     {
724       result = new std::string("The build path could not be opened. Make sure to configure the project before compiling it");
725       return false;
726     }
727   //create make command
728   std::string makeComm = "make -C \"" + this->buildPath + "\" > \"" + this->buildPath + CDMUtilities::SLASH + "building.log\" 2>&1";
729   std::cout << "executing '" << makeComm << "'" << std::endl;
730   //execute make command
731   if(system(makeComm.c_str()))
732     {
733       //if there was an error then report it
734       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.");
735       return false;
736     }
737 #endif
738   return true;
739 }
740
741 bool modelCDMProject::Connect(std::string*& result)
742 {
743   //TODO: adjust for windows and mac
744   #ifdef _WIN32
745     // ------ Windows
746   #elif __APPLE__
747     // ------ Apple
748   #else
749     // ------ Linux
750     //open binary folder
751     wxDir dir(crea::std2wx((this->buildPath).c_str()));
752
753     //if binary folder can't be opened then return false
754     if (!dir.IsOpened())
755       {
756         result = new std::string("The build path could not be opened. Make sure to configure the project before compiling it");
757         return false;
758       }
759     //create plug command
760     std::string plugComm = "bbPlugPackage \"" + this->buildPath + "\" > \"" + this->buildPath + CDMUtilities::SLASH + "plugging.log\" 2>&1";
761     std::cout << "executing '" << plugComm << "'" << std::endl;
762     //execute plug command
763     if(system(plugComm.c_str()))
764       {
765         //if there was an error then report it
766         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.");
767         return false;
768       }
769   #endif
770     return true;
771 }