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
4 changes: 2 additions & 2 deletions tools/projmgr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ include(FetchContent)
FetchContent_Declare(
rpc-interface
DOWNLOAD_EXTRACT_TIMESTAMP ON
URL https://github.com/Open-CMSIS-Pack/csolution-rpc/releases/download/v0.0.10/csolution-rpc.zip
URL_HASH SHA256=246e1f6e5c1a6e269aeadf37f6bf62897c5bb9d374b7fbfdf0e19af61449379e
URL https://github.com/Open-CMSIS-Pack/csolution-rpc/releases/download/v0.0.11/csolution-rpc.zip
URL_HASH SHA256=1999e1a158922c319626959384643a8490bac4a716a88fa8868b2fd6701097df
)
FetchContent_MakeAvailable(rpc-interface)

Expand Down
5 changes: 5 additions & 0 deletions tools/projmgr/include/ProjMgrWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,17 @@ struct ToolchainItem {
* pack information pack,
* path to pack path,
* origin file,
* selected-by entry,
* resolved pack identifier,
* missing flag,
*/
struct PackageItem {
PackInfo pack;
std::string path;
std::string origin;
std::string selectedBy;
std::string resolvedTo;
bool missing = false;
};

/**
Expand Down Expand Up @@ -581,6 +585,7 @@ struct ContextItem {
std::set<RteComponentInstance*> unresolvedComponents;
StrMap availablePackVersions;
StrMap absPathSequences;
StrVec lockedPacks;
};

/**
Expand Down
16 changes: 12 additions & 4 deletions tools/projmgr/src/ProjMgrRpcServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,24 +445,32 @@ PackReferenceVector RpcHandler::CollectPackReferences(const string& context) {
PackReferenceVector packRefs;
auto contextItem = GetContext(context);
for(const auto& packItem : contextItem.packRequirements) {
const auto& packId = packItem.resolvedTo;

RpcArgs::PackReference packRef;
packRef.pack = packItem.selectedBy;
if(!packItem.path.empty()) {
packRef.resolvedPack = packItem.selectedBy;
packRef.path = packItem.path;
} else if(!packId.empty()) {
packRef.resolvedPack = packId;
} else if(!packItem.resolvedTo.empty()) {
packRef.resolvedPack = packItem.resolvedTo;
}
packRef.origin = packItem.origin;
packRef.selected = true; // initially pack is selected;
const auto& packId = packItem.pack.vendor + "::" + packItem.pack.name + "@" + packItem.pack.version;
if(packItem.path.empty() && !packId.empty()) {
const auto availableVersionIt = contextItem.availablePackVersions.find(packId);
if(availableVersionIt != contextItem.availablePackVersions.end() && !availableVersionIt->second.empty()) {
packRef.upgrade = availableVersionIt->second;
}
}
// set optional 'locked' pack identifier if pack is not resolved and locked pack identifier is tracked
if (packItem.resolvedTo.empty() && find(contextItem.lockedPacks.begin(),
contextItem.lockedPacks.end(), packId) != contextItem.lockedPacks.end()) {
packRef.locked = packId;
}
// set optional 'missing' if pack is not found
if (packItem.missing) {
packRef.missing = true;
}
packRefs.push_back(packRef);
}
return packRefs;
Expand Down
6 changes: 5 additions & 1 deletion tools/projmgr/src/ProjMgrWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ bool ProjMgrWorker::CollectRequiredPdscFiles(ContextItem& context, const std::st
auto pdsc = m_kernel->GetEffectivePdscFile(attributes);
const string& pdscFile = pdsc.second;
packItem.resolvedTo = pdsc.first; // store resolved ID if any
packItem.missing = pdsc.first.empty();
if (pdscFile.empty()) {
if (!bPackFilter) {
std::string packageName =
Expand Down Expand Up @@ -1861,9 +1862,12 @@ void ProjMgrWorker::ResolvePackRequirement(ContextItem& context, const PackItem&
if (!locked.empty()) {
// TODO: When wildcards will be fully stored in cbuild-pack there may be multiple matches
const auto& lockedId = locked.front();
CollectionUtils::PushBackUniquely(context.lockedPacks, lockedId);
if (lockedId != packId) {
// Save available version if different from locked
context.availablePackVersions[lockedId] = package.pack.version;
if (!packId.empty()) {
context.availablePackVersions[lockedId] = package.pack.version;
}
// Keep the locked pack
packId = lockedId;
package.pack.version = RtePackage::VersionFromId(lockedId);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cbuild-pack:
resolved-packs:
- resolved-pack: ARM::RteTest_DFP@0.1.0
selected-by-pack:
- ARM::RteTest_DFP
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/csolution.schema.json

solution:
target-types:
- type: CM0
device: RteTest_ARMCM0
packs:
- pack: ARM::RteTest_DFP
projects:
- project: ./project_with_dfp_components.cproject.yml
32 changes: 32 additions & 0 deletions tools/projmgr/test/src/ProjMgrRpcTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,38 @@ TEST_F(ProjMgrRpcTests, RpcGetUsedItemsLocked) {
EXPECT_EQ(packs[0]["upgrade"], "0.2.0");
}

TEST_F(ProjMgrRpcTests, PackReferenceLocked) {
string context = "project_with_dfp_components+CM0";
vector<string> contextList = { context };
auto requests = CreateLoadRequests("/TestSolution/PackLocking/pack_reference_locked.csolution.yml", "", contextList);
requests += FormatRequest(3, "GetUsedItems", json({ { "context", context } }));
const auto& responses = RunRpcMethods(requests);
EXPECT_TRUE(responses[2]["result"]["success"]);
auto packs = responses[2]["result"]["packs"];
EXPECT_EQ(packs.size(), 1);
// Locked field should be present as string containing locked packId
EXPECT_TRUE(packs[0].contains("locked"));
EXPECT_EQ(packs[0]["locked"], "ARM::RteTest_DFP@0.1.0");
}

TEST_F(ProjMgrRpcTests, PackReferenceMissing) {
string context = "project+Miss";
vector<string> contextList = { context };
auto requests = CreateLoadRequests("/TestSolution/PackMissing/missing_pack.csolution.yml", "", contextList);
requests += FormatRequest(3, "GetUsedItems", json({{ "context", context }}));
const auto& responses = RunRpcMethods(requests);
EXPECT_TRUE(responses[2]["result"]["success"]);
auto packs = responses[2]["result"]["packs"];
// Verify missing field for unresolved packs
for(const auto& pack : packs) {
if(!pack.contains("resolvedPack")) {
EXPECT_TRUE(pack.contains("missing"));
EXPECT_TRUE(pack["missing"].is_boolean());
EXPECT_TRUE(pack["missing"].get<bool>());
}
}
}

TEST_F(ProjMgrRpcTests, RpcGetPacksInfoSimple) {
string context = "selectable+CM0";
vector<string> contextList = {
Expand Down
Loading