Skip to content

Commit 9526dd8

Browse files
committed
refactor ExcludedFromBuild to use Conditional
1 parent dfcec18 commit 9526dd8

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

lib/importproject.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -818,10 +818,14 @@ namespace {
818818
bool useUnicode = false;
819819
};
820820

821+
struct ExcludedFromBuild : Conditional {
822+
explicit ExcludedFromBuild(const tinyxml2::XMLElement *efb) : Conditional(efb) {}
823+
};
824+
821825
struct ItemGroupClCompile {
822826
explicit ItemGroupClCompile(std::string filename) : mFilename(std::move(filename)) {}
823827
ItemGroupClCompile(const tinyxml2::XMLElement *element, std::string file) : mFilename(std::move(file)) {
824-
for (const tinyxml2::XMLElement* childElement = element->FirstChildElement(); childElement; childElement = childElement->NextSiblingElement()) {
828+
for (const tinyxml2::XMLElement *childElement = element->FirstChildElement(); childElement; childElement = childElement->NextSiblingElement()) {
825829
const char *name = childElement->Name();
826830
if (!name)
827831
continue;
@@ -830,23 +834,22 @@ namespace {
830834
const char *text = childElement->GetText();
831835
if (!condition || !text || std::strcmp(text, "true") != 0)
832836
continue;
833-
mConditions.emplace_back(condition);
837+
mExcludedFromBuild.emplace_back(childElement);
834838
}
835-
// TODO: ForcedIncludeFiles and PrecompiledHeaderFile
839+
// TODO: ForcedIncludeFiles and AdditionalIncludeDirectories
836840
}
837841
}
838-
bool exclude(const ProjectConfiguration& p, std::vector<std::string>& errors) const {
839-
if (mConditions.empty())
842+
bool excludedfromBuild(const ProjectConfiguration &pc, std::vector<std::string> &errors) const {
843+
if (mExcludedFromBuild.empty())
840844
return false;
841-
for (const std::string& condition : mConditions) {
842-
Conditional conditional(condition);
843-
if (conditional.conditionIsTrue(p, mFilename, errors))
845+
for (const ExcludedFromBuild &excluded : mExcludedFromBuild) {
846+
if (excluded.conditionIsTrue(pc, mFilename, errors))
844847
return true;
845848
}
846849
return false;
847850
}
848851
std::string mFilename;
849-
std::list<std::string> mConditions;
852+
std::list<ExcludedFromBuild> mExcludedFromBuild;
850853
};
851854
}
852855

@@ -1074,7 +1077,7 @@ bool ImportProject::importVcxproj(const std::string &filename, const tinyxml2::X
10741077
}
10751078

10761079
// check if the file should be excluded for this configuration
1077-
if (compile.exclude(p, errors))
1080+
if (compile.excludedfromBuild(p, errors))
10781081
continue;
10791082

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

0 commit comments

Comments
 (0)