Support relative paths in Visual Studio projects properties (#995)

* transform relative paths with the help of the project dir to absolute
paths so the actual checker can resolve include paths defined in
property sheets

* fix coding style (one-line if)

* add existing importproject testfile to visual studio project to appear
when loading solution

* also explicitly export struct from within class to enable linking in
testrunner
This commit is contained in:
BNT 2017-11-11 11:13:18 +01:00 committed by Daniel Marjamäki
parent 24aa6a858a
commit cc4c9032de
4 changed files with 11 additions and 1 deletions

View File

@ -413,8 +413,14 @@ static void importPropertyGroup(const tinyxml2::XMLElement *node, std::map<std::
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)
{
std::string filename(props);
// variables cant be resolved
if (!simplifyPathWithVariables(filename, *variables))
return;
// prepend project dir (if it exists) to transform relative paths into absolute ones
if (!Path::isAbsolute(filename) && variables->count("ProjectDir") > 0)
filename = Path::getAbsoluteFilePath(variables->at("ProjectDir") + filename);
tinyxml2::XMLDocument doc;
if (doc.LoadFile(filename.c_str()) != tinyxml2::XML_SUCCESS)
return;

View File

@ -48,7 +48,7 @@ namespace cppcheck {
class CPPCHECKLIB ImportProject {
public:
/** File settings. Multiple configurations for a file is allowed. */
struct FileSettings {
struct CPPCHECKLIB FileSettings {
FileSettings() : platformType(cppcheck::Platform::Unspecified), msc(false), useMfc(false) {}
std::string cfg;
std::string filename;

View File

@ -45,6 +45,7 @@
<ClCompile Include="testexceptionsafety.cpp" />
<ClCompile Include="testfilelister.cpp" />
<ClCompile Include="testgarbage.cpp" />
<ClCompile Include="testimportproject.cpp" />
<ClCompile Include="testincompletestatement.cpp" />
<ClCompile Include="testinternal.cpp" />
<ClCompile Include="testio.cpp" />

View File

@ -199,6 +199,9 @@
<ClCompile Include="testfunctions.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="testimportproject.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="options.h">