Skip to content
Merged
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
3 changes: 2 additions & 1 deletion tools/projmgr/include/ProjMgrWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,8 @@ class ProjMgrWorker {
void AddMiscUniquely(MiscItem& dst, std::vector<MiscItem>& srcVec);
bool AddGroup(const GroupNode& src, std::vector<GroupNode>& dst, ContextItem& context, const std::string root);
bool AddFile(const FileNode& src, std::vector<FileNode>& dst, ContextItem& context, const std::string root);
bool AddComponent(const ComponentItem& src, const std::string& layer, std::vector<std::pair<ComponentItem, std::string>>& dst, TypePair type, ContextItem& context);
bool AddComponent(const ComponentItem& src, const std::string& layer, std::vector<std::pair<ComponentItem,
std::string>>& dst, TypePair type, ContextItem& context, bool ignoreDuplicates = false);
void GetDeviceItem(const std::string& element, DeviceItem& device) const;
void GetBoardItem (const std::string& element, BoardItem& board) const;
bool GetPrecedentValue(std::string& outValue, const std::string& element) const;
Expand Down
9 changes: 7 additions & 2 deletions tools/projmgr/src/ProjMgrWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3525,7 +3525,7 @@
if (!ProcessSequencesRelatives(context, component.build, clayer->directory)) {
return false;
}
if (!AddComponent(component, name, context.componentRequirements, context.type, context)) {
if (!AddComponent(component, name, context.componentRequirements, context.type, context, true)) {
return false;
}
}
Expand Down Expand Up @@ -3795,10 +3795,15 @@
return true;
}

bool ProjMgrWorker::AddComponent(const ComponentItem& src, const string& layer, vector<pair<ComponentItem, string>>& dst, TypePair type, ContextItem& context) {
bool ProjMgrWorker::AddComponent(const ComponentItem& src, const string& layer, vector<pair<ComponentItem, string>>& dst,
TypePair type, ContextItem& context, bool ignoreDuplicates) {

Check notice

Code scanning / CodeQL

Large object passed by value Note

This parameter of type
TypePair
is 96 bytes - consider passing a const pointer/reference instead.
Comment thread
brondani marked this conversation as resolved.
Dismissed
if (CheckContextFilters(src.type, context)) {
for (auto& [dstNode, layer] : dst) {
Comment thread
brondani marked this conversation as resolved.
if (dstNode.component == src.component) {
if (ignoreDuplicates) {
ProjMgrLogger::Get().Warn("ignoring conflict: component '" + dstNode.component + "' is listed multiple times", context.name);
return true;
}
ProjMgrLogger::Get().Error("conflict: component '" + dstNode.component + "' is listed multiple times", context.name);
return false;
}
Expand Down
22 changes: 10 additions & 12 deletions tools/projmgr/test/src/ProjMgrUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7529,19 +7529,17 @@ TEST_F(ProjMgrUnitTests, DuplicateComponents) {
argv[4] = (char*)"-o";
argv[5] = (char*)testoutput_folder.c_str();
argv[6] = (char*)"--context";
argv[7] = (char*)"duplicateComponents_cproject";
argv[8] = (char*)"--no-check-schema";

const char* contexts[] = { "duplicateComponents_cproject", "duplicateComponents_clayer" };
int argCounts[] = { 8, 9 }; // without/with --no-check-schema
for (int argCount : argCounts) {
for (const char* context : contexts) {
argv[7] = (char*)context;
EXPECT_EQ(1, RunProjMgr(argCount, argv, m_envp));
auto errStr = streamRedirect.GetErrorString();
EXPECT_NE(string::npos, errStr.find("error csolution: conflict: component 'RteTest:CORE' is listed multiple times"));
streamRedirect.ClearStringStreams();
}
}
EXPECT_EQ(1, RunProjMgr(9, argv, m_envp));
auto errStr = streamRedirect.GetErrorString();
EXPECT_NE(string::npos, errStr.find("error csolution: conflict: component 'RteTest:CORE' is listed multiple times"));

streamRedirect.ClearStringStreams();
argv[7] = (char*)"duplicateComponents_clayer";
EXPECT_EQ(0, RunProjMgr(9, argv, m_envp));
errStr = streamRedirect.GetErrorString();
EXPECT_NE(string::npos, errStr.find("warning csolution: ignoring conflict: component 'RteTest:CORE' is listed multiple times"));
}

TEST_F(ProjMgrUnitTests, ParseCommandLine_MutualExclusionOptions) {
Expand Down
Loading