Skip to content

Commit 741d013

Browse files
authored
[projmgr] Accept listing same component multiple times in clayers
1 parent 2b74841 commit 741d013

3 files changed

Lines changed: 19 additions & 15 deletions

File tree

tools/projmgr/include/ProjMgrWorker.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,8 @@ class ProjMgrWorker {
12351235
void AddMiscUniquely(MiscItem& dst, std::vector<MiscItem>& srcVec);
12361236
bool AddGroup(const GroupNode& src, std::vector<GroupNode>& dst, ContextItem& context, const std::string root);
12371237
bool AddFile(const FileNode& src, std::vector<FileNode>& dst, ContextItem& context, const std::string root);
1238-
bool AddComponent(const ComponentItem& src, const std::string& layer, std::vector<std::pair<ComponentItem, std::string>>& dst, TypePair type, ContextItem& context);
1238+
bool AddComponent(const ComponentItem& src, const std::string& layer, std::vector<std::pair<ComponentItem,
1239+
std::string>>& dst, TypePair type, ContextItem& context, bool ignoreDuplicates = false);
12391240
void GetDeviceItem(const std::string& element, DeviceItem& device) const;
12401241
void GetBoardItem (const std::string& element, BoardItem& board) const;
12411242
bool GetPrecedentValue(std::string& outValue, const std::string& element) const;

tools/projmgr/src/ProjMgrWorker.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3525,7 +3525,7 @@ bool ProjMgrWorker::ProcessSequencesRelatives(ContextItem & context, bool rerun)
35253525
if (!ProcessSequencesRelatives(context, component.build, clayer->directory)) {
35263526
return false;
35273527
}
3528-
if (!AddComponent(component, name, context.componentRequirements, context.type, context)) {
3528+
if (!AddComponent(component, name, context.componentRequirements, context.type, context, true)) {
35293529
return false;
35303530
}
35313531
}
@@ -3795,10 +3795,15 @@ bool ProjMgrWorker::AddFile(const FileNode& src, vector<FileNode>& dst, ContextI
37953795
return true;
37963796
}
37973797

3798-
bool ProjMgrWorker::AddComponent(const ComponentItem& src, const string& layer, vector<pair<ComponentItem, string>>& dst, TypePair type, ContextItem& context) {
3798+
bool ProjMgrWorker::AddComponent(const ComponentItem& src, const string& layer, vector<pair<ComponentItem, string>>& dst,
3799+
TypePair type, ContextItem& context, bool ignoreDuplicates) {
37993800
if (CheckContextFilters(src.type, context)) {
38003801
for (auto& [dstNode, layer] : dst) {
38013802
if (dstNode.component == src.component) {
3803+
if (ignoreDuplicates) {
3804+
ProjMgrLogger::Get().Warn("ignoring conflict: component '" + dstNode.component + "' is listed multiple times", context.name);
3805+
return true;
3806+
}
38023807
ProjMgrLogger::Get().Error("conflict: component '" + dstNode.component + "' is listed multiple times", context.name);
38033808
return false;
38043809
}

tools/projmgr/test/src/ProjMgrUnitTests.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7529,19 +7529,17 @@ TEST_F(ProjMgrUnitTests, DuplicateComponents) {
75297529
argv[4] = (char*)"-o";
75307530
argv[5] = (char*)testoutput_folder.c_str();
75317531
argv[6] = (char*)"--context";
7532+
argv[7] = (char*)"duplicateComponents_cproject";
75327533
argv[8] = (char*)"--no-check-schema";
7533-
7534-
const char* contexts[] = { "duplicateComponents_cproject", "duplicateComponents_clayer" };
7535-
int argCounts[] = { 8, 9 }; // without/with --no-check-schema
7536-
for (int argCount : argCounts) {
7537-
for (const char* context : contexts) {
7538-
argv[7] = (char*)context;
7539-
EXPECT_EQ(1, RunProjMgr(argCount, argv, m_envp));
7540-
auto errStr = streamRedirect.GetErrorString();
7541-
EXPECT_NE(string::npos, errStr.find("error csolution: conflict: component 'RteTest:CORE' is listed multiple times"));
7542-
streamRedirect.ClearStringStreams();
7543-
}
7544-
}
7534+
EXPECT_EQ(1, RunProjMgr(9, argv, m_envp));
7535+
auto errStr = streamRedirect.GetErrorString();
7536+
EXPECT_NE(string::npos, errStr.find("error csolution: conflict: component 'RteTest:CORE' is listed multiple times"));
7537+
7538+
streamRedirect.ClearStringStreams();
7539+
argv[7] = (char*)"duplicateComponents_clayer";
7540+
EXPECT_EQ(0, RunProjMgr(9, argv, m_envp));
7541+
errStr = streamRedirect.GetErrorString();
7542+
EXPECT_NE(string::npos, errStr.find("warning csolution: ignoring conflict: component 'RteTest:CORE' is listed multiple times"));
75457543
}
75467544

75477545
TEST_F(ProjMgrUnitTests, ParseCommandLine_MutualExclusionOptions) {

0 commit comments

Comments
 (0)