Merge pull request #849 from bug22/master

Fixed #7791 (Cppcheck does not expand Visual Studio macros):
This commit is contained in:
Daniel Marjamäki 2016-12-08 00:48:15 +01:00 committed by GitHub
commit d120fdc9a7
1 changed files with 20 additions and 15 deletions

View File

@ -290,6 +290,8 @@ namespace {
} }
bool conditionIsTrue(const ProjectConfiguration &p) const { bool conditionIsTrue(const ProjectConfiguration &p) const {
if (condition.empty())
return true;
std::string c = '(' + condition + ");"; std::string c = '(' + condition + ");";
replaceAll(c, "$(Configuration)", p.configuration); replaceAll(c, "$(Configuration)", p.configuration);
replaceAll(c, "$(Platform)", p.platform); replaceAll(c, "$(Platform)", p.platform);
@ -443,13 +445,10 @@ void ImportProject::importVcxproj(const std::string &filename, std::map<std::str
for (std::list<std::string>::const_iterator c = compileList.begin(); c != compileList.end(); ++c) { for (std::list<std::string>::const_iterator c = compileList.begin(); c != compileList.end(); ++c) {
for (std::list<ProjectConfiguration>::const_iterator p = projectConfigurationList.begin(); p != projectConfigurationList.end(); ++p) { for (std::list<ProjectConfiguration>::const_iterator p = projectConfigurationList.begin(); p != projectConfigurationList.end(); ++p) {
for (std::list<ItemDefinitionGroup>::const_iterator i = itemDefinitionGroupList.begin(); i != itemDefinitionGroupList.end(); ++i) {
if (!i->conditionIsTrue(*p))
continue;
FileSettings fs; FileSettings fs;
fs.filename = Path::simplifyPath(Path::getPathFromFilename(filename) + *c); fs.filename = Path::simplifyPath(Path::getPathFromFilename(filename) + *c);
fs.cfg = p->name; fs.cfg = p->name;
fs.defines = "_MSC_VER=1900;_WIN32=1;" + i->preprocessorDefinitions; fs.defines = "_MSC_VER=1900;_WIN32=1";
if (p->platform == "Win32") if (p->platform == "Win32")
fs.platformType = cppcheck::Platform::Win32W; fs.platformType = cppcheck::Platform::Win32W;
else if (p->platform == "x64") { else if (p->platform == "x64") {
@ -458,10 +457,16 @@ void ImportProject::importVcxproj(const std::string &filename, std::map<std::str
} }
if (useOfMfc) if (useOfMfc)
fs.defines += ";__AFXWIN_H__"; fs.defines += ";__AFXWIN_H__";
std::string additionalIncludePaths;
for (std::list<ItemDefinitionGroup>::const_iterator i = itemDefinitionGroupList.begin(); i != itemDefinitionGroupList.end(); ++i) {
if (!i->conditionIsTrue(*p))
continue;
fs.defines += ';' + i->preprocessorDefinitions;
additionalIncludePaths += ';' + i->additionalIncludePaths;
}
fs.setDefines(fs.defines); fs.setDefines(fs.defines);
fs.setIncludePaths(Path::getPathFromFilename(filename), toStringList(includePath + ';' + i->additionalIncludePaths), variables); fs.setIncludePaths(Path::getPathFromFilename(filename), toStringList(includePath + ';' + additionalIncludePaths), variables);
fileSettings.push_back(fs); fileSettings.push_back(fs);
} }
} }
} }
}