Skip to content
Open
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
28 changes: 13 additions & 15 deletions lib/importproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,6 @@ namespace {
if (condAttr)
mCondition = condAttr;
}
explicit Conditional(std::string condition) : mCondition(std::move(condition)) {}

static void replaceAll(std::string &c, const std::string &from, const std::string &to) {
std::string::size_type pos;
Expand Down Expand Up @@ -818,10 +817,14 @@ namespace {
bool useUnicode = false;
};

struct ExcludedFromBuild : Conditional {
explicit ExcludedFromBuild(const tinyxml2::XMLElement *efb) : Conditional(efb) {}
};

struct ItemGroupClCompile {
explicit ItemGroupClCompile(std::string filename) : mFilename(std::move(filename)) {}
ItemGroupClCompile(const tinyxml2::XMLElement *element, std::string file) : mFilename(std::move(file)) {
for (const tinyxml2::XMLElement* childElement = element->FirstChildElement(); childElement; childElement = childElement->NextSiblingElement()) {
for (const tinyxml2::XMLElement *childElement = element->FirstChildElement(); childElement; childElement = childElement->NextSiblingElement()) {
const char *name = childElement->Name();
if (!name)
continue;
Expand All @@ -830,23 +833,18 @@ namespace {
const char *text = childElement->GetText();
if (!condition || !text || std::strcmp(text, "true") != 0)
continue;
mConditions.emplace_back(condition);
mExcludedFromBuild.emplace_back(childElement);
}
// TODO: ForcedIncludeFiles and PrecompiledHeaderFile
// TODO: ForcedIncludeFiles and AdditionalIncludeDirectories
}
}
bool exclude(const ProjectConfiguration& p, std::vector<std::string>& errors) const {
if (mConditions.empty())
return false;
for (const std::string& condition : mConditions) {
Conditional conditional(condition);
if (conditional.conditionIsTrue(p, mFilename, errors))
return true;
}
return false;
bool excludedfromBuild(const ProjectConfiguration &pc, std::vector<std::string> &errors) const {
return std::any_of(mExcludedFromBuild.cbegin(), mExcludedFromBuild.cend(), [&](const ExcludedFromBuild &excluded) {
return excluded.conditionIsTrue(pc, mFilename, errors);
});
}
std::string mFilename;
std::list<std::string> mConditions;
std::list<ExcludedFromBuild> mExcludedFromBuild;
};
}

Expand Down Expand Up @@ -1074,7 +1072,7 @@ bool ImportProject::importVcxproj(const std::string &filename, const tinyxml2::X
}

// check if the file should be excluded for this configuration
if (compile.exclude(p, errors))
if (compile.excludedfromBuild(p, errors))
continue;

FileSettings fs{ compile.mFilename, Standards::Language::None, 0}; // file will be identified later on
Expand Down
Loading