| 832 | } |
| 833 | |
| 834 | static void loadVisualStudioProperties(const std::string &props, std::map<std::string,std::string,cppcheck::stricmp> &variables, std::string &includePath, const std::string &additionalIncludeDirectories, std::list<ItemDefinitionGroup> &itemDefinitionGroupList) |
| 835 | { |
| 836 | std::string filename(props); |
| 837 | // variables can't be resolved |
| 838 | if (!simplifyPathWithVariables(filename, variables)) |
| 839 | return; |
| 840 | |
| 841 | // prepend project dir (if it exists) to transform relative paths into absolute ones |
| 842 | if (!Path::isAbsolute(filename) && variables.count("ProjectDir") > 0) |
| 843 | filename = Path::getAbsoluteFilePath(variables.at("ProjectDir") + filename); |
| 844 | |
| 845 | tinyxml2::XMLDocument doc; |
| 846 | if (doc.LoadFile(filename.c_str()) != tinyxml2::XML_SUCCESS) |
| 847 | return; |
| 848 | const tinyxml2::XMLElement * const rootnode = doc.FirstChildElement(); |
| 849 | if (rootnode == nullptr) |
| 850 | return; |
| 851 | for (const tinyxml2::XMLElement *node = rootnode->FirstChildElement(); node; node = node->NextSiblingElement()) { |
| 852 | const char* name = node->Name(); |
| 853 | if (std::strcmp(name, "ImportGroup") == 0) { |
| 854 | const char *labelAttribute = node->Attribute("Label"); |
| 855 | if (labelAttribute == nullptr || std::strcmp(labelAttribute, "PropertySheets") != 0) |
| 856 | continue; |
| 857 | for (const tinyxml2::XMLElement *importGroup = node->FirstChildElement(); importGroup; importGroup = importGroup->NextSiblingElement()) { |
| 858 | if (std::strcmp(importGroup->Name(), "Import") == 0) { |
| 859 | const char *projectAttribute = importGroup->Attribute("Project"); |
| 860 | if (projectAttribute == nullptr) |
| 861 | continue; |
| 862 | std::string loadprj(projectAttribute); |
| 863 | if (loadprj.find('$') == std::string::npos) { |
| 864 | loadprj = Path::getPathFromFilename(filename) + loadprj; |
| 865 | } |
| 866 | loadVisualStudioProperties(loadprj, variables, includePath, additionalIncludeDirectories, itemDefinitionGroupList); |
| 867 | } |
| 868 | } |
| 869 | } else if (std::strcmp(name,"PropertyGroup")==0) { |
| 870 | importPropertyGroup(node, variables, includePath); |
| 871 | } else if (std::strcmp(name,"ItemDefinitionGroup")==0) { |
| 872 | itemDefinitionGroupList.emplace_back(node, additionalIncludeDirectories); |
| 873 | } |
| 874 | } |
| 875 | } |
| 876 | |
| 877 | bool ImportProject::importVcxproj(const std::string &filename, |
| 878 | std::map<std::string, std::string, cppcheck::stricmp> &variables, |
no test coverage detected