Skip to content

Commit

Permalink
[projmgr] Rename 'selected-by' to 'selected-by-pack' (Open-CMSIS-Pack…
Browse files Browse the repository at this point in the history
…#1263)

Contributed by STMicroelectronics

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
  • Loading branch information
Torbjorn-Svensson committed Jan 17, 2024
1 parent 024fee4 commit d446476
Show file tree
Hide file tree
Showing 25 changed files with 47 additions and 46 deletions.
4 changes: 2 additions & 2 deletions tools/projmgr/include/ProjMgrParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ struct PackItem {
/**
* @brief resolved pack item containing,
* pack ID,
* list of selected-by expressions (original expressions causing this pack to be added)
* list of selected-by-pack expressions (original expressions causing this pack to be added)
*/
struct ResolvedPackItem {
std::string pack;
std::vector<std::string> selectedBy;
std::vector<std::string> selectedByPack;
};

/**
Expand Down
1 change: 1 addition & 0 deletions tools/projmgr/include/ProjMgrYamlParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ static constexpr const char* YAML_SCOPE = "scope";
static constexpr const char* YAML_SCRIPT = "script";
static constexpr const char* YAML_SOLUTION = "solution";
static constexpr const char* YAML_SELECTED_BY = "selected-by";
static constexpr const char* YAML_SELECTED_BY_PACK = "selected-by-pack";
static constexpr const char* YAML_SETUPS = "setups";
static constexpr const char* YAML_SETUP = "setup";
static constexpr const char* YAML_SET = "set";
Expand Down
2 changes: 1 addition & 1 deletion tools/projmgr/schemas/common.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@
"type": "object",
"properties": {
"resolved-pack": { "$ref": "#/definitions/PackID" },
"selected-by": {
"selected-by-pack": {
"type": "array",
"uniqueItems": true,
"items": { "$ref": "#/definitions/PackID" }
Expand Down
4 changes: 2 additions & 2 deletions tools/projmgr/src/ProjMgrWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,7 @@ vector<string> ProjMgrWorker::FindMatchingPackIdsInCbuildPack(const PackItem& ne
vector<string> matches;
for (const auto& resolvedPack : resolvedPacks) {
// First try exact matching
if (find(resolvedPack.selectedBy.cbegin(), resolvedPack.selectedBy.cend(), needle.pack) != resolvedPack.selectedBy.end()) {
if (find(resolvedPack.selectedByPack.cbegin(), resolvedPack.selectedByPack.cend(), needle.pack) != resolvedPack.selectedByPack.end()) {
if (!needleInfo.name.empty() && !WildCards::IsWildcardPattern(needle.pack)) {
// Exact match means only one result
return {resolvedPack.pack};
Expand Down Expand Up @@ -1411,7 +1411,7 @@ vector<string> ProjMgrWorker::FindMatchingPackIdsInCbuildPack(const PackItem& ne
});

// Non-wildcard returns the pack id with the highest version.
// This should only happen the first time the needle is not included in the selected-by-list.
// This should only happen the first time the needle is not included in the selected-by-pack-list.
return {matches[0]};
}

Expand Down
12 changes: 6 additions & 6 deletions tools/projmgr/src/ProjMgrYamlEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ ProjMgrYamlCbuildPack::ProjMgrYamlCbuildPack(YAML::Node node, const vector<Conte
ModelItem modelItem;
ProjMgrUtils::ConvertToPackInfo(resolvedItem.pack, modelItem.info);
modelItem.resolvedPack.pack = resolvedItem.pack;
modelItem.resolvedPack.selectedBy = resolvedItem.selectedBy;
modelItem.resolvedPack.selectedByPack = resolvedItem.selectedByPack;
model[resolvedItem.pack] = modelItem;
}
}
Expand Down Expand Up @@ -131,12 +131,12 @@ ProjMgrYamlCbuildPack::ProjMgrYamlCbuildPack(YAML::Node node, const vector<Conte
model[resolvedPack] = modelItem;
}

ProjMgrUtils::PushBackUniquely(model[resolvedPack].resolvedPack.selectedBy, userInput);
ProjMgrUtils::PushBackUniquely(model[resolvedPack].resolvedPack.selectedByPack, userInput);
}
}
}

// Stage 4: Process all wildcard patterns from user and add to selected-by list
// Stage 4: Process all wildcard patterns from user and add to selected-by-pack list
for (const auto& context : processedContexts) {
for (const auto& packItem : context->packRequirements) {
// Skip project local packs
Expand All @@ -150,7 +150,7 @@ ProjMgrYamlCbuildPack::ProjMgrYamlCbuildPack(YAML::Node node, const vector<Conte

for (auto& [_, item] : model) {
if (ProjMgrUtils::IsMatchingPackInfo(item.info, reqInfo)) {
ProjMgrUtils::PushBackUniquely(item.resolvedPack.selectedBy, packId);
ProjMgrUtils::PushBackUniquely(item.resolvedPack.selectedByPack, packId);
}
}
}
Expand Down Expand Up @@ -188,8 +188,8 @@ ProjMgrYamlCbuildPack::ProjMgrYamlCbuildPack(YAML::Node node, const vector<Conte

SetNodeValue(resolvedPackNode[YAML_RESOLVED_PACK], packId);

sort(packItem.selectedBy.begin(), packItem.selectedBy.end());
SetNodeValue(resolvedPackNode[YAML_SELECTED_BY], packItem.selectedBy);
sort(packItem.selectedByPack.begin(), packItem.selectedByPack.end());
SetNodeValue(resolvedPackNode[YAML_SELECTED_BY_PACK], packItem.selectedByPack);

node[YAML_RESOLVED_PACKS].push_back(resolvedPackNode);
}
Expand Down
4 changes: 2 additions & 2 deletions tools/projmgr/src/ProjMgrYamlParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ void ProjMgrYamlParser::ParseResolvedPacks(const YAML::Node& parent, vector<Reso
for (const auto& packEntry : packsNode) {
ResolvedPackItem packItem;
ParseString(packEntry, YAML_RESOLVED_PACK, packItem.pack);
ParseVector(packEntry, YAML_SELECTED_BY, packItem.selectedBy);
ParseVector(packEntry, YAML_SELECTED_BY_PACK, packItem.selectedByPack);
packs.push_back(packItem);
}
}
Expand Down Expand Up @@ -1088,7 +1088,7 @@ const set<string> packsKeys = {

const set<string> resolvedPacksKeys = {
YAML_RESOLVED_PACK,
YAML_SELECTED_BY,
YAML_SELECTED_BY_PACK,
};

const set<string> componentsKeys = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cbuild-pack:
resolved-packs:
- resolved-pack: ARM::RteTest_DFP@0.1.1
selected-by:
selected-by-pack:
- ARM::RteTest_DFP
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cbuild-pack:
resolvd-packs:
- resolved-pack: ARM::RteTest_DFP@0.1.1
selected-by:
selected-by-pack:
- ARM::RteTest_DFP
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ misc: 1
cbuild-pack:
resolved-packs:
- resolved-pack: ARM::RteTest_DFP@0.1.1
selected-by:
selected-by-pack:
- ARM::RteTest_DFP
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cbuild-pack:
resolved-packs:
- resolved-pack: SomeVendor::RteTest_DFP@0.1.1
selected-by:
selected-by-pack:
- SomeVendor::RteTest_DFP
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cbuild-pack:
resolved-packs:
- resolved-pack: ARM::RteTest_DFP@0.1.1
selected-by:
selected-by-pack:
- ARM::RteTest_DFP
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cbuild-pack:
resolved-packs:
- resolved-pack: ARM::RteTest_DFP@0.1.1
selected-by:
selected-by-pack:
- ARM::RteTest_DFP
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
cbuild-pack:
resolved-packs:
- resolved-pack: ARM::RteTest@0.1.0
selected-by:
selected-by-pack:
- ARM::RteTest
- resolved-pack: ARM::RteTest_DFP@0.1.1
selected-by:
selected-by-pack:
- ARM::RteTest_DFP@0.1.1
- resolved-pack: ARM::RteTest_DFP@0.2.0
selected-by:
selected-by-pack:
- ARM::RteTest_DFP@0.2.0
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
cbuild-pack:
resolved-packs:
- resolved-pack: ARM::RteTest@0.1.0
selected-by:
selected-by-pack:
- ARM::Rte*st
- resolved-pack: ARM::RteTest_DFP@0.1.1
selected-by:
selected-by-pack:
- ARM::RteTest_DFP@0.1.1
- resolved-pack: ARM::RteTest_DFP@0.2.0
selected-by:
selected-by-pack:
- ARM::RteTest_DFP
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ solution:
- pack: SomeVendor
- pack: SomeVendor::*@0.0.1
projects:
- project: ./project_pack_lock_reselect_selected-by.cproject.yml
- project: ./project_pack_lock_reselect_selected-by-pack.cproject.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cbuild-pack:
resolved-packs:
- resolved-pack: ARM::RteTest_DFP@0.1.1
selected-by:
selected-by-pack:
- ARM::RteTest_DFP
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cbuild-pack:
resolved-packs:
- resolved-pack: ARM::RteTest_DFP@0.2.0
selected-by:
selected-by-pack:
- ARM::RteTest_DFP@0.2.0
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cbuild-pack:
resolved-packs:
- resolved-pack: ARM::RteTest@0.1.0
selected-by:
selected-by-pack:
- ARM::RteTest@>=0.0.1
- resolved-pack: ARM::RteTest_DFP@0.2.0
selected-by:
selected-by-pack:
- ARM::RteTest_DFP
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
cbuild-pack:
resolved-packs:
- resolved-pack: ARM::RteTest@0.1.0
selected-by:
selected-by-pack:
- ARM::Rte*st
- resolved-pack: ARM::RteTest_DFP@0.1.1
selected-by:
selected-by-pack:
- ARM::RteTest_DFP@0.1.1
- resolved-pack: ARM::RteTest_DFP@0.2.0
selected-by:
selected-by-pack:
- ARM::RteTest_DFP
- resolved-pack: SomeVendor::RteTest@0.0.1
selected-by:
selected-by-pack:
- SomeVendor
- SomeVendor::*@0.0.1
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cbuild-pack:
resolved-packs:
- resolved-pack: ARM::RteTest@0.1.0
selected-by:
selected-by-pack:
- ARM::RteTest@>=0.0.1
- resolved-pack: ARM::RteTest_DFP@0.2.0
selected-by:
selected-by-pack:
- ARM::RteTest_DFP
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cbuild-pack:
resolved-packs:
- resolved-pack: ARM::RteTest_DFP@0.2.0
selected-by:
selected-by-pack:
- ARM::RteTest_DFP@0.2.0
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cbuild-pack:
resolved-packs:
- resolved-pack: ARM::RteTestGenerator@0.1.0
selected-by:
selected-by-pack:
- ARM::RteTestGenerator@0.1.0
- resolved-pack: ARM::RteTest_DFP@0.2.0
selected-by:
selected-by-pack:
- ARM::RteTest_DFP@>=0.2.0
8 changes: 4 additions & 4 deletions tools/projmgr/test/src/ProjMgrUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -955,13 +955,13 @@ TEST_F(ProjMgrUnitTests, RunProjMgrSolution_LockPackFrozenNoPackFile) {
EXPECT_NE(0, RunProjMgr(7, argv, 0));
}

TEST_F(ProjMgrUnitTests, RunProjMgrSolution_LockPackReselectSelectedBy) {
TEST_F(ProjMgrUnitTests, RunProjMgrSolution_LockPackReselectSelectedByPack) {
char* argv[6];

// convert --solution solution.yml
const string csolution = testinput_folder + "/TestSolution/PackLocking/project_pack_lock_reselect_selected-by.csolution.yml";
const string cbuildPack = testinput_folder + "/TestSolution/PackLocking/project_pack_lock_reselect_selected-by.cbuild-pack.yml";
const string expectedCbuildPack = testinput_folder + "/TestSolution/PackLocking/ref/project_pack_lock_reselect_selected-by.cbuild-pack.yml";
const string csolution = testinput_folder + "/TestSolution/PackLocking/project_pack_lock_reselect_selected-by-pack.csolution.yml";
const string cbuildPack = testinput_folder + "/TestSolution/PackLocking/project_pack_lock_reselect_selected-by-pack.cbuild-pack.yml";
const string expectedCbuildPack = testinput_folder + "/TestSolution/PackLocking/ref/project_pack_lock_reselect_selected-by-pack.cbuild-pack.yml";
const string output = testoutput_folder + "/testpacklock";

argv[1] = (char*)"convert";
Expand Down
6 changes: 3 additions & 3 deletions tools/projmgr/test/src/ProjMgrWorkerUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@ TEST_F(ProjMgrWorkerUnitTests, FindMatchingPacksInCbuildPack) {
matches = FindMatchingPackIdsInCbuildPack({"ARM::CMSIS", "/path/to/pack"}, resolvedPacks);
EXPECT_EQ(0, matches.size());

// Should match one entry in "selected-by"
// Should match one entry in "selected-by-pack"
matches = FindMatchingPackIdsInCbuildPack({"ARM::CMSIS"}, resolvedPacks);
EXPECT_EQ(1, matches.size());
EXPECT_EQ(matches[0], pack1.pack);
Expand All @@ -1637,13 +1637,13 @@ TEST_F(ProjMgrWorkerUnitTests, FindMatchingPacksInCbuildPack) {
matches = FindMatchingPackIdsInCbuildPack({"Test@>=3.0.0"}, resolvedPacks);
EXPECT_EQ(0, matches.size());

// More than one match on wildcard that is not in selected-by-list
// More than one match on wildcard that is not in selected-by-pack-list
matches = FindMatchingPackIdsInCbuildPack({"SomeVendor"}, resolvedPacks);
EXPECT_EQ(2, matches.size());
EXPECT_EQ(matches[0], pack5.pack);
EXPECT_EQ(matches[1], pack6.pack);

// More than one match on wildcard that is not in selected-by-list
// More than one match on wildcard that is not in selected-by-pack-list
matches = FindMatchingPackIdsInCbuildPack({"SomeVendor::Pack*"}, resolvedPacks);
EXPECT_EQ(2, matches.size());
EXPECT_EQ(matches[0], pack5.pack);
Expand Down

0 comments on commit d446476

Please sign in to comment.