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