X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaDevManagerLib%2FmodelCDMProject.cpp;fp=lib%2FcreaDevManagerLib%2FmodelCDMProject.cpp;h=51f642a0b097068da7d779cccbb84a6e561620dc;hb=2fb5dd9262993efaf56bfc731f4297fdb96bf63e;hp=501d059d9892e0bbc0742f8cfe82ccba3426263c;hpb=40c574d86b82c2afc5a351f1ad96cc0254008306;p=crea.git diff --git a/lib/creaDevManagerLib/modelCDMProject.cpp b/lib/creaDevManagerLib/modelCDMProject.cpp index 501d059..51f642a 100644 --- a/lib/creaDevManagerLib/modelCDMProject.cpp +++ b/lib/creaDevManagerLib/modelCDMProject.cpp @@ -765,31 +765,166 @@ bool modelCDMProject::Build(std::string*& result, const std::string& line) bool modelCDMProject::Connect(std::string*& result) { //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 console to read more about the problem."); - return false; - } - #endif - return true; +#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 console to read more about the problem."); + return false; + } +#endif + return true; +} + +void modelCDMProject::CheckStructure(std::map& properties) +{ + //check cmake exist + if(this->CMakeLists != NULL) + { + //set properties parameters based on model + properties["project add appli"] = this->appli != NULL; + properties["project add lib"] = this->lib != NULL; + for (int i = 0; i < this->packages.size(); i++) + properties["project add " + packages[i]->GetName()] = false; + + //open cmakelists + std::ifstream confFile; + confFile.open((this->CMakeLists->GetPath()).c_str()); + + //take everything that is not commented + std::string fileContent; + + std::string word; + std::vector words; + while(confFile.is_open() && !confFile.eof()) + { + std::getline(confFile,word, '\n'); + if(word[0] != '#') + { + CDMUtilities::splitter::split(words, word, "#", CDMUtilities::splitter::empties_ok); + if (words.size() > 0) + { + word = words[0]; + CDMUtilities::splitter::split(words, word, " ", CDMUtilities::splitter::empties_ok); + for (int i = 0; i < words.size(); i++) + { + if(words[i].substr(0,2) == "//") + break; + fileContent += words[i] + " "; + } + } + + } + } + + //check every instruction + std::stringstream ss(fileContent); + while(!ss.eof()) + { + std::getline(ss,word, '('); + + //check instruction name + CDMUtilities::splitter::split(words, word, " ", CDMUtilities::splitter::no_empties); + + //set instructions + if (words.size() > 0 && words[words.size()-1] == "SET") + { + std::getline(ss,word, ')'); + + CDMUtilities::splitter::split(words, word, " ", CDMUtilities::splitter::no_empties); + if (words.size() > 1) + { + if (words[0] == "USE_CREA" && words[1] == "ON") + { + properties["project set USE_CREA"] = true; + } + else if (words[0] == "USE_GDCM" && words[1] == "ON") + { + properties["project set USE_GDCM"] = true; + } + else if (words[0] == "USE_GDCM_VTK" && words[1] == "ON") + { + properties["project set USE_GDCM_VTK"] = true; + } + else if (words[0] == "USE_GDCM2" && words[1] == "ON") + { + properties["project set USE_GDCM2"] = true; + } + else if (words[0] == "USE_WXWIDGETS" && words[1] == "ON") + { + properties["project set USE_WXWIDGETS"] = true; + } + else if (words[0] == "USE_KWWIDGETS" && words[1] == "ON") + { + properties["project set USE_KWWIDGETS"] = true; + } + else if (words[0] == "USE_VTK" && words[1] == "ON") + { + properties["project set USE_VTK"] = true; + } + else if (words[0] == "USE_ITK" && words[1] == "ON") + { + properties["project set USE_ITK"] = true; + } + else if (words[0] == "USE_BOOST" && words[1] == "ON") + { + properties["project set USE_BOOST"] = true; + } + } + } + //add instructions + else if (words.size() > 0 && words[words.size()-1] == "ADD_SUBDIRECTORY") + { + std::getline(ss,word, ')'); + //std::cout << word << std::endl; + CDMUtilities::splitter::split(words, word, " ", CDMUtilities::splitter::no_empties); + + if (words.size() > 0) + { + if(words[0] == "appli") + { + properties["project add "+words[0]] = this->appli != NULL; + } + else if(words[0] == "lib") + { + properties["project add "+words[0]] = this->lib != NULL; + } + else + { + properties["project add "+words[0]] = true; + } + } + } + } + + } + + //check appli's structure + this->appli->CheckStructure(properties); + //check lib's structure + this->lib->CheckStructure(properties); + //check packages' structure + for (int i = 0; i < this->packages.size(); i++) + { + properties["package " + this->packages[i]->GetName()] = true; + this->packages[i]->CheckStructure(properties); + } }