add command line option to select single project configuration of loaded solution (#2523)
* add command line option to select single project configuration of loaded solution * Update cmdlineparser.cpp * Update manual.md * fix initialization
This commit is contained in:
parent
f9074e7b21
commit
095fd2bc62
|
@ -569,6 +569,7 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
||||||
mSettings->checkAllConfigurations = false; // Can be overridden with --max-configs or --force
|
mSettings->checkAllConfigurations = false; // Can be overridden with --max-configs or --force
|
||||||
const std::string projectFile = argv[i]+10;
|
const std::string projectFile = argv[i]+10;
|
||||||
ImportProject::Type projType = mSettings->project.import(projectFile, mSettings);
|
ImportProject::Type projType = mSettings->project.import(projectFile, mSettings);
|
||||||
|
mSettings->project.projectType = projType;
|
||||||
if (projType == ImportProject::Type::CPPCHECK_GUI) {
|
if (projType == ImportProject::Type::CPPCHECK_GUI) {
|
||||||
mPathNames = mSettings->project.guiProject.pathNames;
|
mPathNames = mSettings->project.guiProject.pathNames;
|
||||||
for (const std::string &lib : mSettings->project.guiProject.libraries)
|
for (const std::string &lib : mSettings->project.guiProject.libraries)
|
||||||
|
@ -623,6 +624,13 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --project-configuration
|
||||||
|
else if (std::strncmp(argv[i], "--project-configuration=", 24) == 0) {
|
||||||
|
mVSConfig = argv[i] + 24;
|
||||||
|
if (!mVSConfig.empty() && (mSettings->project.projectType == ImportProject::Type::VS_SLN || mSettings->project.projectType == ImportProject::Type::VS_VCXPROJ))
|
||||||
|
mSettings->project.ignoreOtherConfigs(mVSConfig);
|
||||||
|
}
|
||||||
|
|
||||||
// Report progress
|
// Report progress
|
||||||
else if (std::strcmp(argv[i], "--report-progress") == 0) {
|
else if (std::strcmp(argv[i], "--report-progress") == 0) {
|
||||||
mSettings->reportProgress = true;
|
mSettings->reportProgress = true;
|
||||||
|
@ -1106,6 +1114,11 @@ void CmdLineParser::printHelp()
|
||||||
" or Borland C++ Builder 6 (*.bpr). The files to analyse,\n"
|
" or Borland C++ Builder 6 (*.bpr). The files to analyse,\n"
|
||||||
" include paths, defines, platform and undefines in\n"
|
" include paths, defines, platform and undefines in\n"
|
||||||
" the specified file will be used.\n"
|
" the specified file will be used.\n"
|
||||||
|
" --project-configuration=<config>\n"
|
||||||
|
" If used together with a Visual Studio Solution (*.sln)\n"
|
||||||
|
" or Visual Studio Project (*.vcxproj) you can limit\n"
|
||||||
|
" the configuration cppcheck should check.\n"
|
||||||
|
" For example: ""--project-configuration=Release|Win32"""
|
||||||
" --max-configs=<limit>\n"
|
" --max-configs=<limit>\n"
|
||||||
" Maximum number of configurations to check in a file\n"
|
" Maximum number of configurations to check in a file\n"
|
||||||
" before skipping it. Default is '12'. If used together\n"
|
" before skipping it. Default is '12'. If used together\n"
|
||||||
|
|
|
@ -114,6 +114,7 @@ private:
|
||||||
bool mShowVersion;
|
bool mShowVersion;
|
||||||
bool mShowErrorMessages;
|
bool mShowErrorMessages;
|
||||||
bool mExitAfterPrint;
|
bool mExitAfterPrint;
|
||||||
|
std::string mVSConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
|
@ -34,6 +34,11 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
|
||||||
|
ImportProject::ImportProject()
|
||||||
|
{
|
||||||
|
projectType = Type::UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
void ImportProject::ignorePaths(const std::vector<std::string> &ipaths)
|
void ImportProject::ignorePaths(const std::vector<std::string> &ipaths)
|
||||||
{
|
{
|
||||||
for (std::list<FileSettings>::iterator it = fileSettings.begin(); it != fileSettings.end();) {
|
for (std::list<FileSettings>::iterator it = fileSettings.begin(); it != fileSettings.end();) {
|
||||||
|
|
|
@ -81,6 +81,9 @@ public:
|
||||||
void setIncludePaths(const std::string &basepath, const std::list<std::string> &in, std::map<std::string, std::string, cppcheck::stricmp> &variables);
|
void setIncludePaths(const std::string &basepath, const std::list<std::string> &in, std::map<std::string, std::string, cppcheck::stricmp> &variables);
|
||||||
};
|
};
|
||||||
std::list<FileSettings> fileSettings;
|
std::list<FileSettings> fileSettings;
|
||||||
|
Type projectType;
|
||||||
|
|
||||||
|
ImportProject();
|
||||||
|
|
||||||
void selectOneVsConfig(cppcheck::Platform::PlatformType platform);
|
void selectOneVsConfig(cppcheck::Platform::PlatformType platform);
|
||||||
|
|
||||||
|
|
|
@ -179,6 +179,11 @@ Running Cppcheck on a Visual Studio project:
|
||||||
|
|
||||||
cppcheck --project=foobar.vcxproj
|
cppcheck --project=foobar.vcxproj
|
||||||
|
|
||||||
|
Both options will analyze all available configurations in the project(s).
|
||||||
|
Limiting on a single configuration:
|
||||||
|
|
||||||
|
cppcheck --project=foobar.sln "--project-configuration=Release|Win32"
|
||||||
|
|
||||||
In the `Cppcheck GUI` you have the choice to only analyze a single debug configuration. If you want to use this choice on the command line then create a `Cppcheck GUI` project with this activated and then import the GUI project file on the command line.
|
In the `Cppcheck GUI` you have the choice to only analyze a single debug configuration. If you want to use this choice on the command line then create a `Cppcheck GUI` project with this activated and then import the GUI project file on the command line.
|
||||||
|
|
||||||
To ignore certain folders in the project you can use `-i`. This will skip analysis of source files in the `foo` folder.
|
To ignore certain folders in the project you can use `-i`. This will skip analysis of source files in the `foo` folder.
|
||||||
|
|
Loading…
Reference in New Issue