Skip to content

Commit 7720216

Browse files
authored
Rpc protocol enhancements
1 parent 4f02c45 commit 7720216

File tree

12 files changed

+445
-113
lines changed

12 files changed

+445
-113
lines changed

libs/rtemodel/src/RteComponent.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ void RteComponentAggregate::AddComponent(RteComponent* c)
571571
RtePackage* devicePack = GetTarget()->GetEffectiveDevicePackage();
572572
if (insertedPack == devicePack)
573573
return; // component from device pack is already installed
574-
if (insertedPack && devicePack && pack != devicePack) {
574+
if (insertedPack && devicePack && pack && pack != devicePack) {
575575
const string& packVersion = pack->GetVersionString();
576576
const string& insertedPackVersion = insertedPack->GetVersionString();
577577
if (VersionCmp::Compare(packVersion, insertedPackVersion) < 0)
@@ -610,6 +610,8 @@ void RteComponentAggregate::SetComponentInstance(RteComponentInstance* ci, int c
610610
m_selectedVariant = ei->GetCvariantName();
611611
m_selectedVersion = ei->GetVersionString();
612612
AssignAttribute("layer", *ci);
613+
AssignAttribute("explicitVendor", *ci);
614+
AssignAttribute("explicitVersion", *ci);
613615

614616
if (m_components.empty()) {
615617
if (c) {

libs/rtemodel/src/RteItem.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,13 @@ void RteItem::SetAttributesFomComponentId(const std::string& componentId)
250250
if (componentId.find(RteConstants::SUFFIX_CVENDOR) != string::npos) {
251251
string vendor = RteUtils::RemoveSuffixByString(id, RteConstants::SUFFIX_CVENDOR);
252252
AddAttribute("Cvendor", vendor);
253+
SetAttribute("explicitVendor", true);
253254
id = RteUtils::RemovePrefixByString(componentId, RteConstants::SUFFIX_CVENDOR);
254255
}
255-
AddAttribute("Cversion", RteUtils::GetSuffix(id, RteConstants::PREFIX_CVERSION_CHAR));
256+
auto explicitVersion = RteUtils::GetSuffix(id, RteConstants::PREFIX_CVERSION_CHAR, true);
257+
AddAttribute("explicitVersion", explicitVersion);
258+
AddAttribute("Cversion", RteUtils::GetSuffix(explicitVersion, RteConstants::PREFIX_CVERSION_CHAR));
259+
256260
id = RteUtils::GetPrefix(id, RteConstants::PREFIX_CVERSION_CHAR);
257261
list<string> segments;
258262
RteUtils::SplitString(segments, id, RteConstants::COLON_CHAR);

libs/rtemodel/src/RteProject.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "RteProject.h"
1616

1717
#include "RteComponent.h"
18+
#include "RteConstants.h"
1819
#include "RteFile.h"
1920
#include "RteGenerator.h"
2021
#include "RteModel.h"
@@ -366,7 +367,7 @@ RteComponentInstance* RteProject::AddComponent(RteComponent* c, int instanceCoun
366367
if (!ci) {
367368
ci = new RteComponentInstance(this);
368369
AddItem(ci);
369-
m_components[c->GetID()] = ci;
370+
m_components[id] = ci;
370371
ci->Init(c);
371372
// check if we have previous aggregate with Excluded flag for the target
372373
}
@@ -832,7 +833,18 @@ bool RteProject::Apply()
832833
}
833834
}
834835
ci = AddComponent(c, count, target, ci);
835-
ci->AssignAttribute("layer", *a);
836+
// pass aggregate options and create ymlID attribute
837+
if(!ci->IsApi()) {
838+
ci->AssignAttribute("layer", *a);
839+
ci->AssignAttribute("explicitVendor", *a);
840+
ci->AssignAttribute("explicitVersion", *a);
841+
string ymlID = RteUtils::GetPrefix(ci->GetID(), RteConstants::PREFIX_CVERSION_CHAR);
842+
if(!a->GetAttributeAsBool("explicitVendor")) {
843+
ymlID = RteUtils::RemovePrefixByString(ymlID, RteConstants::SUFFIX_CVENDOR);
844+
}
845+
ymlID += a->GetAttribute("explicitVersion");
846+
ci->AddAttribute("ymlID", ymlID);
847+
}
836848

837849
// add API if any
838850
RteApi* api = c->GetApi(target, true);

libs/rtemodel/test/src/RteItemTest.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ TEST(RteItemTest, ComponentAttributesFromId) {
8282
RteItem item("component", nullptr);
8383
item.SetAttributesFomComponentId(id);
8484
EXPECT_EQ(id, item.GetComponentID(true));
85+
EXPECT_EQ(item.GetAttribute("explicitVersion"), "@9.9.9");
86+
EXPECT_TRUE(item.GetAttributeAsBool("explicitVendor"));
8587

8688
id = "Class&Bundle:Group:Sub&[email protected]";
8789
item.SetAttributesFomComponentId(id);
@@ -98,6 +100,18 @@ TEST(RteItemTest, ComponentAttributesFromId) {
98100
id = "Class:Group:&Variant";
99101
item.SetAttributesFomComponentId(id);
100102
EXPECT_EQ("Class:Group&Variant", item.GetComponentID(true));
103+
104+
id = "Group:Sub";
105+
item.SetAttributesFomComponentId(id);
106+
EXPECT_EQ(id, item.GetComponentID(true));
107+
EXPECT_TRUE(item.GetAttribute("explicitVersion").empty());
108+
EXPECT_FALSE(item.GetAttributeAsBool("explicitVendor"));
109+
110+
id = "Group:Sub@^9.0.0";
111+
item.SetAttributesFomComponentId(id);
112+
EXPECT_EQ(id, item.GetComponentID(true));
113+
EXPECT_EQ(item.GetAttribute("explicitVersion"),"@^9.0.0");
114+
EXPECT_EQ(item.GetVersionString(),"^9.0.0");
101115
}
102116

103117
TEST(RteItemTest, SemVer) {

tools/projmgr/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ include(FetchContent)
1717
FetchContent_Declare(
1818
rpc-interface
1919
DOWNLOAD_EXTRACT_TIMESTAMP ON
20-
URL https://github.com/Open-CMSIS-Pack/csolution-rpc/releases/download/v0.0.1/csolution-rpc.zip
21-
URL_HASH SHA256=b86a9e63c5d269c9375fe7c389234a05e7ce59ebb26bde81858b669e5664f3f6
20+
URL https://github.com/Open-CMSIS-Pack/csolution-rpc/releases/download/v0.0.2/csolution-rpc.zip
21+
URL_HASH SHA256=bc00342a240d2fded19981524bb286c91541504d4271e936f68c646a8b62908f
2222
)
2323
FetchContent_MakeAvailable(rpc-interface)
2424

tools/projmgr/include/ProjMgrRpcServerData.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#include "RpcInterface.h"
1010

11+
#include <optional>
12+
1113
using namespace std;
1214

1315
class RteTarget;
@@ -30,8 +32,10 @@ class RpcDataCollector {
3032
RpcArgs::ComponentInstance FromComponentInstance(const RteComponentInstance* rteCi) const;
3133
RteItem* GetTaxonomyItem(const RteComponentGroup* rteGroup) const;
3234

33-
protected:
35+
std::optional<RpcArgs::Options> OptionsFromRteItem(const RteItem* item) const;
36+
std::string ResultStringFromRteItem(const RteItem* item) const;
3437

38+
protected:
3539
void CollectCtBundles(RpcArgs::CtClass& ctClass, RteComponentGroup* rteClass) const;
3640
void CollectCtChildren(RpcArgs::CtTreeItem& parent, RteComponentGroup* rteGroup, const string& bundleName) const;
3741
void CollectCtAggregates(RpcArgs::CtTreeItem& parent, RteComponentGroup* rteGroup, const string& bundleName) const;

tools/projmgr/include/ProjMgrWorker.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -908,10 +908,10 @@ class ProjMgrWorker {
908908
* @param context item
909909
* @return true if there is no error
910910
*/
911-
bool ValidateContext(ContextItem& context);
911+
RteItem::ConditionResult ValidateContext(ContextItem& context);
912912

913913
/**
914-
* @brief populate active target set
914+
* @brief populate active target set
915915
* @param active target set command line option
916916
* @return true if there is no error
917917
*/

0 commit comments

Comments
 (0)