Skip to content

fixed #13623 - reworked handling of options in GUI projects #7293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 6 additions & 23 deletions cli/cmdlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1184,31 +1184,17 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a

mSettings.checkAllConfigurations = false; // Can be overridden with --max-configs or --force
std::string projectFile = argv[i]+10;
projectType = project.import(projectFile, &mSettings, &mSuppressions);
projectType = project.import(projectFile, mSettings.fileFilters);
if (projectType == ImportProject::Type::CPPCHECK_GUI) {
for (const std::string &lib : project.guiProject.libraries)
mSettings.libraries.emplace_back(lib);

const auto& excludedPaths = project.guiProject.excludedPaths;
std::copy(excludedPaths.cbegin(), excludedPaths.cend(), std::back_inserter(mIgnoredPaths));

std::string platform(project.guiProject.platform);

// keep existing platform from command-line intact
if (!platform.empty()) {
std::string errstr;
const std::vector<std::string> paths = {projectFile, argv[0]};
if (!mSettings.platform.set(platform, errstr, paths, mSettings.debuglookup || mSettings.debuglookupPlatform)) {
mLogger.printError(errstr);
return Result::Fail;
}
}
if (mSettings.debugnormal && !project.guiProject.args.empty()) // TODO: add separate debug option
std::cout << project.guiProject.args << std::endl;
// TODO: inject arguments

const auto& projectFileGui = project.guiProject.projectFile;
if (!projectFileGui.empty()) {
// read underlying project
projectFile = projectFileGui;
projectType = project.import(projectFileGui, &mSettings, &mSuppressions);
projectType = project.import(projectFileGui, mSettings.fileFilters);
if (projectType == ImportProject::Type::CPPCHECK_GUI) {
mLogger.printError("nested Cppcheck GUI projects are not supported.");
return Result::Fail;
Expand Down Expand Up @@ -1639,7 +1625,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
}

// Print error only if we have "real" command and expect files
if (mPathNames.empty() && project.guiProject.pathNames.empty() && project.fileSettings.empty()) {
if (mPathNames.empty() && project.fileSettings.empty()) {
// TODO: this message differs from the one reported in fillSettingsFromArgs()
mLogger.printError("no C or C++ source files found.");
return Result::Fail;
Expand All @@ -1663,9 +1649,6 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
}
}

if (!project.guiProject.pathNames.empty())
mPathNames = project.guiProject.pathNames;

if (!project.fileSettings.empty()) {
project.ignorePaths(mIgnoredPaths, mSettings.debugignore);
if (project.fileSettings.empty()) {
Expand Down
Loading