Skip to content

Commit e7b5d81

Browse files
grasci-armedrioukCopilot
authored
Rpc pack management (#1368) (#2296)
* Support for SelectPack RPC interface * Adjusted to changes in RPC protocol * Enhanced unit tests and fixes * increment csolution-rpc version dependency * Fix Compiler errors * Fix Compiler errors * Update tools/projmgr/include/ProjMgrRpcServerData.h Co-authored-by: Copilot <[email protected]> * Update tools/projmgr/src/ProjMgrRpcServer.cpp Co-authored-by: Copilot <[email protected]> * Update tools/projmgr/src/ProjMgrRpcServer.cpp Co-authored-by: Copilot <[email protected]> * Spell corrections * Update tools/projmgr/src/ProjMgrRpcServer.cpp Co-authored-by: Copilot <[email protected]> * Update tools/projmgr/test/src/ProjMgrRpcTests.cpp Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Evgueni Driouk <[email protected]> Co-authored-by: Copilot <[email protected]>
1 parent d8943b6 commit e7b5d81

File tree

11 files changed

+542
-200
lines changed

11 files changed

+542
-200
lines changed

libs/rtemodel/include/RtePackage.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ class RtePackage : public RteRootItem
8585
*/
8686
const std::string& GetPackageFileName() const override { return GetRootFileName(); }
8787

88+
89+
/**
90+
* @brief get path to overview document
91+
* @return file path
92+
*/
93+
const std::string& GetDocValue() const override;
94+
95+
8896
/**
8997
* @brief get pack common ID, also known as 'pack family ID', does not contain version
9098
* @return ID string in the form PackVendor.PackName

libs/rtemodel/src/RtePackage.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ void RtePackage::Clear()
115115
RteItem::Clear();
116116
}
117117

118+
const std::string& RtePackage::GetDocValue() const
119+
{
120+
return GetChildAttribute("description", "overview");
121+
}
122+
118123
bool RtePackage::IsDeprecated() const
119124
{
120125
if (m_nDeprecated >= 0)

libs/rteutils/include/CollectionUtils.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,21 @@ bool contains_key(const M& m, const typename M::key_type& k) {
7272
return m.find(k) != m.end();
7373
}
7474

75+
/**
76+
* @brief Returns set of key in the map
77+
* @tparam M template parameter representing a map
78+
* @param m a key-value map
79+
* @return std::set of keys
80+
*/
81+
template <typename M>
82+
auto key_set(const M& m) {
83+
using Key = typename M::key_type;
84+
std::set<Key> ks;
85+
for (const auto& kv : m)
86+
ks.insert(kv.first);
87+
return ks;
88+
}
89+
7590
/**
7691
* @brief string pair
7792
*/

tools/projmgr/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ include(FetchContent)
2424
FetchContent_Declare(
2525
rpc-interface
2626
DOWNLOAD_EXTRACT_TIMESTAMP ON
27-
URL https://github.com/Open-CMSIS-Pack/csolution-rpc/releases/download/v0.0.5/csolution-rpc.zip
28-
URL_HASH SHA256=94bd65ec0f8054dc7685a60812f00bc32cc7f9227bec5abdbaa7215fb6b6bd27
27+
URL https://github.com/Open-CMSIS-Pack/csolution-rpc/releases/download/v0.0.6/csolution-rpc.zip
28+
URL_HASH SHA256=86bce42eaef998cb37f3623931068056625d471e80032695946081531359ba5f
2929
)
3030
FetchContent_MakeAvailable(rpc-interface)
3131

tools/projmgr/include/ProjMgrRpcServerData.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010

1111
#include <optional>
1212
#include <list>
13+
#include <set>
1314

1415
using namespace std;
1516

17+
using PackReferenceVector = std::vector<RpcArgs::PackReference>;
18+
1619
class RteTarget;
1720
class RteBundle;
1821
class RteComponent;
@@ -30,7 +33,9 @@ class RpcDataCollector {
3033
RteTarget* GetTarget() const { return m_target; }
3134

3235
void CollectCtClasses(RpcArgs::CtRoot& ctRoot) const;
33-
void CollectUsedItems(RpcArgs::UsedItems& usedItems) const;
36+
void CollectUsedComponents(vector< RpcArgs::ComponentInstance>& usedComponents) const;
37+
38+
std::set<std::string> GetUsedPacks() const;
3439

3540
void CollectDeviceList(RpcArgs::DeviceList& deviceList, const std::string& namePattern, const std::string& vendor) const;
3641
void CollectDeviceInfo(RpcArgs::DeviceInfo& deviceInfo, const std::string& id) const;

tools/projmgr/include/ProjMgrWorker.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ struct PackageItem {
101101
PackInfo pack;
102102
std::string path;
103103
std::string origin;
104+
std::string selectedBy;
104105
};
105106

106107
/**
@@ -522,7 +523,7 @@ struct ContextItem {
522523
RtePackage* devicePack = nullptr;
523524
RtePackage* boardPack = nullptr;
524525
bool precedences;
525-
std::map<std::string, std::set<std::string>> userInputToResolvedPackIdMap;
526+
std::map<std::string, std::map<std::string, PackageItem> > userInputToResolvedPackIdMap;
526527
StrSet localPackPaths;
527528
StrVec dependsOn;
528529
std::map<std::string, RteItem*> packLayers;
@@ -1070,7 +1071,7 @@ class ProjMgrWorker {
10701071
/**
10711072
* @brief collect examples
10721073
* @param context item
1073-
* @param environments filter
1074+
* @param environments filter
10741075
* @return vector of example items
10751076
*/
10761077
std::vector<ExampleItem> CollectExamples(const ContextItem& context, const StrVec& filter);
@@ -1081,7 +1082,7 @@ class ProjMgrWorker {
10811082
* @return vector of template items
10821083
*/
10831084
std::vector<TemplateItem> CollectTemplates(const ContextItem& context);
1084-
1085+
10851086
/**
10861087
* @brief check if all selected contexts have lib output
10871088
* @param reference to processed contexts

tools/projmgr/src/ProjMgrCbuildPack.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ ProjMgrCbuildPack::ProjMgrCbuildPack(YAML::Node node, const vector<ContextItem*>
6363
// Stage 3: Add all user input expression on the matching resolved pack
6464
for (const auto& context : processedContexts) {
6565
for (const auto& [userInput, resolvedPacks] : context->userInputToResolvedPackIdMap) {
66-
for (const auto& resolvedPack : resolvedPacks) {
66+
for (const auto& [resolvedPack, _] : resolvedPacks) {
6767
if (model.find(resolvedPack) == model.end()) {
6868
ModelItem modelItem;
6969
ProjMgrUtils::ConvertToPackInfo(resolvedPack, modelItem.info);

0 commit comments

Comments
 (0)