Skip to content

Commit 94c5fe0

Browse files
[projmgr] Collect and report packs-unused for each selected context
1 parent 244fd16 commit 94c5fe0

File tree

12 files changed

+81
-8
lines changed

12 files changed

+81
-8
lines changed

tools/projmgr/include/ProjMgrWorker.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ struct ContextItem {
296296
std::vector<PackageItem> packRequirements;
297297
std::map<std::string, std::pair<std::string, std::string>> pdscFiles;
298298
std::vector<PackInfo> missingPacks;
299+
StrVec unusedPacks;
299300
std::vector<std::pair<ComponentItem, std::string>> componentRequirements;
300301
std::string compiler;
301302
ToolchainItem toolchain;
@@ -724,6 +725,11 @@ class ProjMgrWorker {
724725
*/
725726
bool CheckMissingFiles();
726727

728+
/**
729+
* @brief collect unused packs for each selected context
730+
*/
731+
void CollectUnusedPacks();
732+
727733
protected:
728734
ProjMgrParser* m_parser = nullptr;
729735
ProjMgrKernel* m_kernel = nullptr;

tools/projmgr/include/ProjMgrYamlParser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ static constexpr const char* YAML_OUTPUT_TMPDIR = "tmpdir";
139139
static constexpr const char* YAML_PACK = "pack";
140140
static constexpr const char* YAML_PACKS = "packs";
141141
static constexpr const char* YAML_PACKS_MISSING = "packs-missing";
142+
static constexpr const char* YAML_PACKS_UNUSED = "packs-unused";
142143
static constexpr const char* YAML_PATH = "path";
143144
static constexpr const char* YAML_PROCESSOR = "processor";
144145
static constexpr const char* YAML_PROJECT = "project";

tools/projmgr/schemas/common.schema.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,8 @@
957957
}
958958
},
959959
"errors": { "type": "boolean", "description": "Indicates error(s) during conversion" },
960-
"packs-missing": { "$ref": "#/definitions/BuildPacksMissingType" },
960+
"packs-missing": { "$ref": "#/definitions/BuildPacksInfoType", "description": "Names of the missing packs" },
961+
"packs-unused": { "$ref": "#/definitions/BuildPacksInfoType", "description": "Names of the unused packs" },
961962
"clayers": { "$ref": "#/definitions/BuildLayersType" },
962963
"rebuild": { "type": "boolean", "description": "Flag indicating intermediate files need to be cleaned before the next build" },
963964
"messages": { "$ref": "#/definitions/MessagesType" }
@@ -1090,13 +1091,13 @@
10901091
},
10911092
"additionalProperties": false
10921093
},
1093-
"BuildPacksMissingType": {
1094+
"BuildPacksInfoType": {
10941095
"type": "array",
10951096
"uniqueItems": true,
10961097
"minItems": 1,
1097-
"items": { "$ref": "#/definitions/BuildPackMissingType", "description": "Names of the missing packs" }
1098+
"items": { "$ref": "#/definitions/BuildPackInfoType" }
10981099
},
1099-
"BuildPackMissingType": {
1100+
"BuildPackInfoType": {
11001101
"type": "object",
11011102
"properties": {
11021103
"pack": { "type": "string", "description": "Name of the missing pack" }

tools/projmgr/src/ProjMgr.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,9 @@ bool ProjMgr::Configure() {
612612
error = true;
613613
}
614614

615+
// Collect unused packs
616+
m_worker.CollectUnusedPacks();
617+
615618
// Print warnings for missing filters
616619
m_worker.PrintMissingFilters();
617620
if (m_verbose) {

tools/projmgr/src/ProjMgrWorker.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5156,3 +5156,18 @@ bool ProjMgrWorker::CheckMissingFiles() {
51565156
}
51575157
return !error;
51585158
}
5159+
5160+
void ProjMgrWorker::CollectUnusedPacks() {
5161+
for (const auto& contextName : m_selectedContexts) {
5162+
auto& context = m_contexts[contextName];
5163+
if (context.packRequirements.empty()) {
5164+
continue;
5165+
}
5166+
context.unusedPacks.clear();
5167+
for (const auto& [packId, _] : context.rteFilteredModel->GetPackages()) {
5168+
if (context.packages.find(packId) == context.packages.end()) {
5169+
CollectionUtils::PushBackUniquely(context.unusedPacks, packId);
5170+
}
5171+
}
5172+
}
5173+
}

tools/projmgr/src/ProjMgrYamlEmitter.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,12 @@ ProjMgrYamlCbuildIdx::ProjMgrYamlCbuildIdx(YAML::Node node,
359359
SetNodeValue(packNode[YAML_PACK], pack);
360360
cbuildNode[YAML_PACKS_MISSING].push_back(packNode);
361361
}
362+
363+
for (const auto& pack : context->unusedPacks) {
364+
YAML::Node packNode;
365+
SetNodeValue(packNode[YAML_PACK], pack);
366+
cbuildNode[YAML_PACKS_UNUSED].push_back(packNode);
367+
}
362368
node[YAML_CBUILDS].push_back(cbuildNode);
363369
}
364370
}

tools/projmgr/test/data/TestAccessSequences/pack-access-sequences.csolution.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ solution:
77
add-path:
88
- $Dpack$
99
- $Bpack$
10-
- $Pack(ARM::RteTest)$
10+
- $Pack(ARM::RteTestBoard)$
1111
add-path-asm:
1212
- $Pack(ARM::NotLoaded)$
1313
- $Pack(Wrong.Format)$
@@ -18,7 +18,6 @@ solution:
1818
packs:
1919
- pack: ARM::[email protected]
2020
- pack: ARM::RteTestBoard
21-
- pack: ARM::RteTest
2221

2322
executes:
2423
- execute: fcarm

tools/projmgr/test/data/TestAccessSequences/ref/pack-access-sequences+CM4-Board.cbuild.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ build:
2525
add-path:
2626
- ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.1.1
2727
- ${CMSIS_PACK_ROOT}/ARM/RteTestBoard/0.1.0
28-
- ${CMSIS_PACK_ROOT}/ARM/RteTest/0.1.0
2928
- ../data/TestAccessSequences/RTE/_CM4-Board
3029
- ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.1.1/Device/ARM/ARMCM4/Include
3130
add-path-asm:
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/csolution.schema.json
2+
3+
solution:
4+
target-types:
5+
- type: CM0
6+
device: RteTest_ARMCM0
7+
- type: Board
8+
board: RteTest CM4 board
9+
10+
compiler: AC6
11+
12+
packs:
13+
- pack: ARM::RteTestGenerator
14+
- pack: ARM::RteTest_DFP
15+
- pack: ARM::RteTestBoard
16+
17+
projects:
18+
- project: ./project.cproject.yml
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/cproject.schema.json
2+
3+
project:
4+
components:
5+
- component: Startup
6+
- component: RteTest:[email protected]

0 commit comments

Comments
 (0)