diff --git a/tools/projmgr/schemas/common.schema.json b/tools/projmgr/schemas/common.schema.json index 2ccbab821..e89f28f86 100644 --- a/tools/projmgr/schemas/common.schema.json +++ b/tools/projmgr/schemas/common.schema.json @@ -648,6 +648,7 @@ }, "set": { "type": "string", + "pattern": "^.+\\..+$", "description": "Set configuration option in the format 'config-id.select'" }, "info": { diff --git a/tools/projmgr/src/ProjMgrWorker.cpp b/tools/projmgr/src/ProjMgrWorker.cpp index 138d26c1b..4414dc1a9 100644 --- a/tools/projmgr/src/ProjMgrWorker.cpp +++ b/tools/projmgr/src/ProjMgrWorker.cpp @@ -561,9 +561,8 @@ bool ProjMgrWorker::DiscoverMatchingLayers(ContextItem& context) { const auto& type = m_parser->GetGenericClayers()[*item.filename].type; msg += "\n " + (type.empty() ? "" : type + ": ") + *item.filename; for (const auto& connect : item.connections) { - if (!connect->set.empty()) { - msg += "\n set: " + connect->set + " (" + (connect->info.empty() ? "" : connect->info + " - ") + connect->connect + ")"; - } + msg += "\n " + (connect->set.empty() ? "" : "set: " + connect->set + " ") + "(" + + (connect->info.empty() ? "" : connect->info + " - ") + connect->connect + ")"; } } ProjMgrLogger::Debug(msg); @@ -614,33 +613,24 @@ bool ProjMgrWorker::DiscoverMatchingLayers(ContextItem& context) { // print all valid configuration options if (context.validConnections.size() > 0) { - map>> configurationOptions; - int index = 1; + map>>> configurationOptions; + int index = 0; for (const auto& combination : context.validConnections) { - bool hasConfigOption = false; + index++; for (const auto& item : combination) { - if (!item.type->empty()) { - hasConfigOption = true; - configurationOptions[index][*item.type][*item.filename]; - } for (const auto& connect : item.connections) { - if (!connect->set.empty()) { - hasConfigOption = true; - configurationOptions[index][*item.type][*item.filename].push_back(connect); - } + configurationOptions[index][*item.type][*item.filename].insert(connect); } } - if (hasConfigOption) { - index++; - } } for (const auto& [index, types] : configurationOptions) { string msg = "configuration match #" + to_string(index) + ":"; for (const auto& [type, filenames] : types) { for (const auto& [filename, options] : filenames) { msg += "\n " + (type.empty() ? "" : type + ": ") + filename; - for (const auto& option : options) { - msg += "\n set: " + option->set + " (" + (option->info.empty() ? "" : option->info + " - ") + option->connect + ")"; + for (const auto& connect : options) { + msg += "\n " + (connect->set.empty() ? "" : "set: " + connect->set + " ") + "(" + + (connect->info.empty() ? "" : connect->info + " - ") + connect->connect + ")"; } } } @@ -711,20 +701,19 @@ ConnectionsCollectionMap ProjMgrWorker::ClassifyConnections(const ConnectionsCol // get common connections ConnectPtrVec commonConnections; bool hasMultipleSelect = false; - for (const auto& [configId, connections] : connectionsMap) { - if (connections.size() > 1) { + for (const auto& [configId, connectionsEntry] : connectionsMap) { + if (!configId.empty()) { // 'config-id' has multiple 'select' choices hasMultipleSelect = true; - } - else { + } else { // 'config-id' has only one 'select' - commonConnections.insert(commonConnections.end(), connections.begin(), connections.end()); + commonConnections.insert(commonConnections.end(), connectionsEntry.begin(), connectionsEntry.end()); } } // iterate over 'select' choices if (hasMultipleSelect) { for (const auto& [configId, selectConnections] : connectionsMap) { - if (selectConnections.size() > 1) { + if (!configId.empty()) { for (const auto& connect : selectConnections) { ConnectionsCollection collection = { collectionEntry.filename, collectionEntry.type, commonConnections }; collection.connections.push_back(connect); diff --git a/tools/projmgr/test/data/TestLayers/config.clayer.yml b/tools/projmgr/test/data/TestLayers/config.clayer.yml index da2bea4c8..f6307c097 100644 --- a/tools/projmgr/test/data/TestLayers/config.clayer.yml +++ b/tools/projmgr/test/data/TestLayers/config.clayer.yml @@ -21,3 +21,7 @@ layer: - connect: "test connect common T" provides: - connectT + + - connect: "test connect common U" + provides: + - connectU diff --git a/tools/projmgr/test/src/ProjMgrUnitTests.cpp b/tools/projmgr/test/src/ProjMgrUnitTests.cpp index 7e968d151..39c7a1eee 100644 --- a/tools/projmgr/test/src/ProjMgrUnitTests.cpp +++ b/tools/projmgr/test/src/ProjMgrUnitTests.cpp @@ -642,18 +642,27 @@ TEST_F(ProjMgrUnitTests, ListLayersCompatible) { debug csolution: validating connections for context 'genericlayers.CompatibleLayers\\+AnyBoard'\n\ debug csolution: validating combined connections:\n\ .*/TestLayers/genericlayers.cproject.yml\n\ + \\(Project Connections\\)\n\ .*/ARM/RteTest_DFP/0.2.0/Layers/board1.clayer.yml\n\ + \\(Board1 Connections\\)\n\ .*/ARM/RteTest_DFP/0.2.0/Layers/testvariant.clayer.yml\n\ + \\(Test variant Connections\\)\n\ debug csolution: connections are valid\n\ debug csolution: validating combined connections:\n\ .*/TestLayers/genericlayers.cproject.yml\n\ + \\(Project Connections\\)\n\ .*/ARM/RteTest_DFP/0.2.0/Layers/board2.clayer.yml\n\ + \\(Board2 Connections\\)\n\ .*/ARM/RteTest_DFP/0.2.0/Layers/testvariant.clayer.yml\n\ + \\(Test variant Connections\\)\n\ debug csolution: connections are valid\n\ debug csolution: validating combined connections:\n\ .*/TestLayers/genericlayers.cproject.yml\n\ + \\(Project Connections\\)\n\ .*/ARM/RteTest_DFP/0.2.0/Layers/board3.clayer.yml\n\ + \\(Board3 Connections\\)\n\ .*/ARM/RteTest_DFP/0.2.0/Layers/testvariant.clayer.yml\n\ + \\(Test variant Connections\\)\n\ debug csolution: connections are valid\n\ debug csolution: multiple clayers match type 'Board':\n\ .*/ARM/RteTest_DFP/0.2.0/Layers/board1.clayer.yml\n\ @@ -662,14 +671,26 @@ debug csolution: multiple clayers match type 'Board':\n\ debug csolution: clayer of type 'TestVariant' was uniquely found:\n\ .*/ARM/RteTest_DFP/0.2.0/Layers/testvariant.clayer.yml\n\ debug csolution: configuration match #1:\n\ + .*/TestLayers/genericlayers.cproject.yml\n\ + \\(Project Connections\\)\n\ Board: .*/ARM/RteTest_DFP/0.2.0/Layers/board1.clayer.yml\n\ + \\(Board1 Connections\\)\n\ TestVariant: .*/ARM/RteTest_DFP/0.2.0/Layers/testvariant.clayer.yml\n\ + \\(Test variant Connections\\)\n\ debug csolution: configuration match #2:\n\ + .*/TestLayers/genericlayers.cproject.yml\n\ + \\(Project Connections\\)\n\ Board: .*/ARM/RteTest_DFP/0.2.0/Layers/board2.clayer.yml\n\ + \\(Board2 Connections\\)\n\ TestVariant: .*/ARM/RteTest_DFP/0.2.0/Layers/testvariant.clayer.yml\n\ + \\(Test variant Connections\\)\n\ debug csolution: configuration match #3:\n\ + .*/TestLayers/genericlayers.cproject.yml\n\ + \\(Project Connections\\)\n\ Board: .*/ARM/RteTest_DFP/0.2.0/Layers/board3.clayer.yml\n\ + \\(Board3 Connections\\)\n\ TestVariant: .*/ARM/RteTest_DFP/0.2.0/Layers/testvariant.clayer.yml\n\ + \\(Test variant Connections\\)\n\ "; const string& errStr = streamRedirect.GetErrorString(); @@ -700,23 +721,31 @@ TEST_F(ProjMgrUnitTests, ListLayersConfigurations) { debug csolution: configuration match #1:\n\ .*/TestLayers/config.clayer.yml\n\ set: set1.select1 \\(set 1 select 1 - connect R\\)\n\ + \\(test connect common T\\)\n\ + \\(test connect common U\\)\n\ .*/TestLayers/config.cproject.yml\n\ set: set1.select1 \\(set 1 select 1 - project X\\)\n\ Config1: .*/ARM/RteTest_DFP/0.2.0/Layers/config1.clayer.yml\n\ set: set1.select1 \\(set 1 select 1 - connect A\\)\n\ set: set2.select1 \\(set 2 select 1 - connect C\\)\n\ + \\(test connect common E\\)\n\ Config2: .*/ARM/RteTest_DFP/0.2.0/Layers/config2.clayer.yml\n\ set: set1.select1 \\(set 1 select 1 - connect F\\)\n\ + \\(test connect common H\\)\n\ debug csolution: configuration match #2:\n\ .*/TestLayers/config.clayer.yml\n\ set: set1.select2 \\(set 1 select 2 - connect S\\)\n\ + \\(test connect common T\\)\n\ + \\(test connect common U\\)\n\ .*/TestLayers/config.cproject.yml\n\ set: set1.select2 \\(set 1 select 2 - project Y\\)\n\ Config1: .*/ARM/RteTest_DFP/0.2.0/Layers/config1.clayer.yml\n\ set: set1.select2 \\(set 1 select 2 - connect B\\)\n\ set: set2.select2 \\(set 2 select 2 - connect D\\)\n\ + \\(test connect common E\\)\n\ Config2: .*/ARM/RteTest_DFP/0.2.0/Layers/config2.clayer.yml\n\ set: set1.select2 \\(set 1 select 2 - connect G\\)\n\ + \\(test connect common H\\)\n\ "; const string& errStr = streamRedirect.GetErrorString(); @@ -772,16 +801,23 @@ TEST_F(ProjMgrUnitTests, ListLayersUniquelyCompatibleBoard) { debug csolution: validating connections for context 'genericlayers.CompatibleLayers\\+Board3'\n\ debug csolution: validating combined connections:\n\ .*/TestLayers/genericlayers.cproject.yml\n\ - .*/ARM/RteTest_DFP/0.2.0/Layers/board3.clayer.yml\n\ - .*/ARM/RteTest_DFP/0.2.0/Layers/testvariant.clayer.yml\n\ + \\(Project Connections\\)\n\ + Board: .*/ARM/RteTest_DFP/0.2.0/Layers/board3.clayer.yml\n\ + \\(Board3 Connections\\)\n\ + TestVariant: .*/ARM/RteTest_DFP/0.2.0/Layers/testvariant.clayer.yml\n\ + \\(Test variant Connections\\)\n\ debug csolution: connections are valid\n\ debug csolution: clayer of type 'Board' was uniquely found:\n\ .*/ARM/RteTest_DFP/0.2.0/Layers/board3.clayer.yml\n\ debug csolution: clayer of type 'TestVariant' was uniquely found:\n\ .*/ARM/RteTest_DFP/0.2.0/Layers/testvariant.clayer.yml\n\ debug csolution: configuration match #1:\n\ + .*/TestLayers/genericlayers.cproject.yml\n\ + \\(Project Connections\\)\n\ Board: .*/ARM/RteTest_DFP/0.2.0/Layers/board3.clayer.yml\n\ + \\(Board3 Connections\\)\n\ TestVariant: .*/ARM/RteTest_DFP/0.2.0/Layers/testvariant.clayer.yml\n\ + \\(Test variant Connections\\)\n\ "; const string& errStr = streamRedirect.GetErrorString(); @@ -815,9 +851,12 @@ debug csolution: no clayer matches type 'UnknownType'\n\ debug csolution: clayer type 'DifferentFromDescriptionInPdsc' does not match type 'PdscType' in pack description\n\ debug csolution: validating combined connections:\n\ .*/TestLayers/genericlayers.cproject.yml\n\ - .*/ARM/RteTest_DFP/0.2.0/Layers/board1.clayer.yml\n\ - .*/ARM/RteTest_DFP/0.2.0/Layers/incompatible.clayer.yml\n\ - .*/ARM/RteTest_DFP/0.2.0/Layers/pdsc-type-mismatch.clayer.yml\n\ + \\(Project Connections\\)\n\ + Board: .*/ARM/RteTest_DFP/0.2.0/Layers/board1.clayer.yml\n\ + \\(Board1 Connections\\)\n\ + Incompatible: .*/ARM/RteTest_DFP/0.2.0/Layers/incompatible.clayer.yml\n\ + \\(Incompatible Connections\\)\n\ + DifferentFromDescriptionInPdsc: .*/ARM/RteTest_DFP/0.2.0/Layers/pdsc-type-mismatch.clayer.yml\n\ debug csolution: connections provided with multiple different values:\n\ MultipleProvidedNonIdentical0\n\ MultipleProvidedNonIdentical1\n\ @@ -829,9 +868,12 @@ debug csolution: sum of required values exceed provided:\n\ debug csolution: connections are invalid\n\ debug csolution: validating combined connections:\n\ .*/TestLayers/genericlayers.cproject.yml\n\ - .*/ARM/RteTest_DFP/0.2.0/Layers/board2.clayer.yml\n\ - .*/ARM/RteTest_DFP/0.2.0/Layers/incompatible.clayer.yml\n\ - .*/ARM/RteTest_DFP/0.2.0/Layers/pdsc-type-mismatch.clayer.yml\n\ + \\(Project Connections\\)\n\ + Board: .*/ARM/RteTest_DFP/0.2.0/Layers/board2.clayer.yml\n\ + \\(Board2 Connections\\)\n\ + Incompatible: .*/ARM/RteTest_DFP/0.2.0/Layers/incompatible.clayer.yml\n\ + \\(Incompatible Connections\\)\n\ + DifferentFromDescriptionInPdsc: .*/ARM/RteTest_DFP/0.2.0/Layers/pdsc-type-mismatch.clayer.yml\n\ debug csolution: connections provided with multiple different values:\n\ MultipleProvidedNonIdentical0\n\ MultipleProvidedNonIdentical1\n\ @@ -843,9 +885,12 @@ debug csolution: sum of required values exceed provided:\n\ debug csolution: connections are invalid\n\ debug csolution: validating combined connections:\n\ .*/TestLayers/genericlayers.cproject.yml\n\ - .*/ARM/RteTest_DFP/0.2.0/Layers/board3.clayer.yml\n\ - .*/ARM/RteTest_DFP/0.2.0/Layers/incompatible.clayer.yml\n\ - .*/ARM/RteTest_DFP/0.2.0/Layers/pdsc-type-mismatch.clayer.yml\n\ + \\(Project Connections\\)\n\ + Board: .*/ARM/RteTest_DFP/0.2.0/Layers/board3.clayer.yml\n\ + \\(Board3 Connections\\)\n\ + Incompatible: .*/ARM/RteTest_DFP/0.2.0/Layers/incompatible.clayer.yml\n\ + \\(Incompatible Connections\\)\n\ + DifferentFromDescriptionInPdsc: .*/ARM/RteTest_DFP/0.2.0/Layers/pdsc-type-mismatch.clayer.yml\n\ debug csolution: connections provided with multiple different values:\n\ MultipleProvidedNonIdentical0\n\ MultipleProvidedNonIdentical1\n\