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:
parent
24aa6a858a
commit
cc4c9032de
|
@ -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)
|
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);
|
std::string filename(props);
|
||||||
|
// variables cant be resolved
|
||||||
if (!simplifyPathWithVariables(filename, *variables))
|
if (!simplifyPathWithVariables(filename, *variables))
|
||||||
return;
|
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;
|
tinyxml2::XMLDocument doc;
|
||||||
if (doc.LoadFile(filename.c_str()) != tinyxml2::XML_SUCCESS)
|
if (doc.LoadFile(filename.c_str()) != tinyxml2::XML_SUCCESS)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace cppcheck {
|
||||||
class CPPCHECKLIB ImportProject {
|
class CPPCHECKLIB ImportProject {
|
||||||
public:
|
public:
|
||||||
/** File settings. Multiple configurations for a file is allowed. */
|
/** File settings. Multiple configurations for a file is allowed. */
|
||||||
struct FileSettings {
|
struct CPPCHECKLIB FileSettings {
|
||||||
FileSettings() : platformType(cppcheck::Platform::Unspecified), msc(false), useMfc(false) {}
|
FileSettings() : platformType(cppcheck::Platform::Unspecified), msc(false), useMfc(false) {}
|
||||||
std::string cfg;
|
std::string cfg;
|
||||||
std::string filename;
|
std::string filename;
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
<ClCompile Include="testexceptionsafety.cpp" />
|
<ClCompile Include="testexceptionsafety.cpp" />
|
||||||
<ClCompile Include="testfilelister.cpp" />
|
<ClCompile Include="testfilelister.cpp" />
|
||||||
<ClCompile Include="testgarbage.cpp" />
|
<ClCompile Include="testgarbage.cpp" />
|
||||||
|
<ClCompile Include="testimportproject.cpp" />
|
||||||
<ClCompile Include="testincompletestatement.cpp" />
|
<ClCompile Include="testincompletestatement.cpp" />
|
||||||
<ClCompile Include="testinternal.cpp" />
|
<ClCompile Include="testinternal.cpp" />
|
||||||
<ClCompile Include="testio.cpp" />
|
<ClCompile Include="testio.cpp" />
|
||||||
|
|
|
@ -199,6 +199,9 @@
|
||||||
<ClCompile Include="testfunctions.cpp">
|
<ClCompile Include="testfunctions.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="testimportproject.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="options.h">
|
<ClInclude Include="options.h">
|
||||||
|
|
Loading…
Reference in New Issue