Skip to content

Commit 6a066cd

Browse files
author
Felix Faber
committed
rebasing...
1 parent 56d57bd commit 6a066cd

2 files changed

Lines changed: 8 additions & 130 deletions

File tree

lib/importproject.cpp

Lines changed: 7 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -706,126 +706,7 @@ static void loadVisualStudioProperties(const std::string &props, std::map<std::s
706706
}
707707
}
708708

709-
bool ImportProject::importVcxproj(const std::string &filename, std::map<std::string, std::string, cppcheck::stricmp> &variables, const std::string &additionalIncludeDirectories, const std::vector<std::string> &fileFilters)
710-
{
711-
variables["ProjectDir"] = Path::simplifyPath(Path::getPathFromFilename(filename));
712-
713-
std::list<ProjectConfiguration> projectConfigurationList;
714-
std::list<std::string> compileList;
715-
std::list<ItemDefinitionGroup> itemDefinitionGroupList;
716-
std::string includePath;
717-
718-
bool useOfMfc = false;
719-
720-
tinyxml2::XMLDocument doc;
721-
const tinyxml2::XMLError error = doc.LoadFile(filename.c_str());
722-
if (error != tinyxml2::XML_SUCCESS) {
723-
printError(std::string("Visual Studio project file is not a valid XML - ") + tinyxml2::XMLDocument::ErrorIDToName(error));
724-
return false;
725-
}
726-
const tinyxml2::XMLElement * const rootnode = doc.FirstChildElement();
727-
if (rootnode == nullptr) {
728-
printError("Visual Studio project file has no XML root node");
729-
return false;
730-
}
731-
for (const tinyxml2::XMLElement *node = rootnode->FirstChildElement(); node; node = node->NextSiblingElement()) {
732-
if (std::strcmp(node->Name(), "ItemGroup") == 0) {
733-
const char *labelAttribute = node->Attribute("Label");
734-
if (labelAttribute && std::strcmp(labelAttribute, "ProjectConfigurations") == 0) {
735-
for (const tinyxml2::XMLElement *cfg = node->FirstChildElement(); cfg; cfg = cfg->NextSiblingElement()) {
736-
if (std::strcmp(cfg->Name(), "ProjectConfiguration") == 0) {
737-
const ProjectConfiguration p(cfg);
738-
if (p.platform != ProjectConfiguration::Unknown) {
739-
projectConfigurationList.emplace_back(cfg);
740-
mAllVSConfigs.insert(p.configuration);
741-
}
742-
}
743-
}
744-
} else {
745-
for (const tinyxml2::XMLElement *e = node->FirstChildElement(); e; e = e->NextSiblingElement()) {
746-
if (std::strcmp(e->Name(), "ClCompile") == 0) {
747-
const char *include = e->Attribute("Include");
748-
if (include && Path::acceptFile(include))
749-
compileList.emplace_back(include);
750-
}
751-
}
752-
}
753-
} else if (std::strcmp(node->Name(), "ItemDefinitionGroup") == 0) {
754-
itemDefinitionGroupList.emplace_back(node, additionalIncludeDirectories);
755-
} else if (std::strcmp(node->Name(), "PropertyGroup") == 0) {
756-
importPropertyGroup(node, variables, includePath, &useOfMfc);
757-
} else if (std::strcmp(node->Name(), "ImportGroup") == 0) {
758-
const char *labelAttribute = node->Attribute("Label");
759-
if (labelAttribute && std::strcmp(labelAttribute, "PropertySheets") == 0) {
760-
for (const tinyxml2::XMLElement *e = node->FirstChildElement(); e; e = e->NextSiblingElement()) {
761-
if (std::strcmp(e->Name(), "Import") == 0) {
762-
const char *projectAttribute = e->Attribute("Project");
763-
if (projectAttribute)
764-
loadVisualStudioProperties(projectAttribute, variables, includePath, additionalIncludeDirectories, itemDefinitionGroupList);
765-
}
766-
}
767-
}
768-
}
769-
}
770-
// # TODO: support signedness of char via /J (and potential XML option for it)?
771-
// we can only set it globally but in this context it needs to be treated per file
772-
773-
for (const std::string &c : compileList) {
774-
const std::string cfilename = Path::simplifyPath(Path::isAbsolute(c) ? c : Path::getPathFromFilename(filename) + c);
775-
if (!fileFilters.empty() && !matchglobs(fileFilters, cfilename))
776-
continue;
777-
778-
for (const ProjectConfiguration &p : projectConfigurationList) {
779-
780-
if (!guiProject.checkVsConfigs.empty()) {
781-
const bool doChecking = std::any_of(guiProject.checkVsConfigs.cbegin(), guiProject.checkVsConfigs.cend(), [&](const std::string& c) {
782-
return c == p.configuration;
783-
});
784-
if (!doChecking)
785-
continue;
786-
}
787-
788-
FileSettings fs;
789-
fs.filename = cfilename;
790-
fs.cfg = p.name;
791-
// TODO: detect actual MSC version
792-
fs.msc = true;
793-
fs.useMfc = useOfMfc;
794-
fs.defines = "_WIN32=1";
795-
if (p.platform == ProjectConfiguration::Win32)
796-
fs.platformType = Platform::Type::Win32W;
797-
else if (p.platform == ProjectConfiguration::x64) {
798-
fs.platformType = Platform::Type::Win64;
799-
fs.defines += ";_WIN64=1";
800-
}
801-
std::string additionalIncludePaths;
802-
for (const ItemDefinitionGroup &i : itemDefinitionGroupList) {
803-
if (!i.conditionIsTrue(p))
804-
continue;
805-
fs.standard = Standards::getCPP(i.cppstd);
806-
fs.defines += ';' + i.preprocessorDefinitions;
807-
if (i.enhancedInstructionSet == "StreamingSIMDExtensions")
808-
fs.defines += ";__SSE__";
809-
else if (i.enhancedInstructionSet == "StreamingSIMDExtensions2")
810-
fs.defines += ";__SSE2__";
811-
else if (i.enhancedInstructionSet == "AdvancedVectorExtensions")
812-
fs.defines += ";__AVX__";
813-
else if (i.enhancedInstructionSet == "AdvancedVectorExtensions2")
814-
fs.defines += ";__AVX2__";
815-
else if (i.enhancedInstructionSet == "AdvancedVectorExtensions512")
816-
fs.defines += ";__AVX512__";
817-
additionalIncludePaths += ';' + i.additionalIncludePaths;
818-
}
819-
fsSetDefines(fs, fs.defines);
820-
fsSetIncludePaths(fs, Path::getPathFromFilename(filename), toStringList(includePath + ';' + additionalIncludePaths), variables);
821-
fileSettings.push_back(std::move(fs));
822-
}
823-
}
824-
825-
return true;
826-
}
827-
828-
bool ImportProject::importVcxproj(const std::string& filename, std::map<std::string, std::string, cppcheck::stricmp>& variables, const std::string& additionalIncludeDirectories, const std::vector<std::string>& fileFilters, std::vector<SharedItemsProject>& cache)
709+
bool ImportProject::importVcxproj(const std::string &filename, std::map<std::string, std::string, cppcheck::stricmp> &variables, const std::string &additionalIncludeDirectories, const std::vector<std::string> &fileFilters, std::vector<SharedItemsProject> &cache)
829710
{
830711
variables["ProjectDir"] = Path::simplifyPath(Path::getPathFromFilename(filename));
831712

@@ -873,19 +754,16 @@ bool ImportProject::importVcxproj(const std::string& filename, std::map<std::str
873754
}
874755
}
875756
}
876-
}
877-
else if (std::strcmp(node->Name(), "ItemDefinitionGroup") == 0) {
757+
} else if (std::strcmp(node->Name(), "ItemDefinitionGroup") == 0) {
878758
itemDefinitionGroupList.emplace_back(node, additionalIncludeDirectories);
879-
}
880-
else if (std::strcmp(node->Name(), "PropertyGroup") == 0) {
759+
} else if (std::strcmp(node->Name(), "PropertyGroup") == 0) {
881760
importPropertyGroup(node, variables, includePath, &useOfMfc);
882-
}
883-
else if (std::strcmp(node->Name(), "ImportGroup") == 0) {
884-
const char* labelAttribute = node->Attribute("Label");
761+
} else if (std::strcmp(node->Name(), "ImportGroup") == 0) {
762+
const char *labelAttribute = node->Attribute("Label");
885763
if (labelAttribute && std::strcmp(labelAttribute, "PropertySheets") == 0) {
886-
for (const tinyxml2::XMLElement* e = node->FirstChildElement(); e; e = e->NextSiblingElement()) {
764+
for (const tinyxml2::XMLElement *e = node->FirstChildElement(); e; e = e->NextSiblingElement()) {
887765
if (std::strcmp(e->Name(), "Import") == 0) {
888-
const char* projectAttribute = e->Attribute("Project");
766+
const char *projectAttribute = e->Attribute("Project");
889767
if (projectAttribute)
890768
loadVisualStudioProperties(projectAttribute, variables, includePath, additionalIncludeDirectories, itemDefinitionGroupList);
891769
}

lib/importproject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class CPPCHECKLIB WARN_UNUSED ImportProject {
109109
};
110110

111111
bool importSln(std::istream &istr, const std::string &path, const std::vector<std::string> &fileFilters);
112-
static SharedItemsProject importVcxitems(const std::string& filename, const std::vector<std::string>& fileFilters, std::vector<SharedItemsProject> &cache);
112+
static SharedItemsProject importVcxitems(const std::string &filename, const std::vector<std::string> &fileFilters, std::vector<SharedItemsProject> &cache);
113113
bool importVcxproj(const std::string &filename, std::map<std::string, std::string, cppcheck::stricmp> &variables, const std::string &additionalIncludeDirectories, const std::vector<std::string> &fileFilters, std::vector<SharedItemsProject> &cache);
114114
bool importBcb6Prj(const std::string &projectFilename);
115115

0 commit comments

Comments
 (0)