Skip to content

Commit 8c37dec

Browse files
grasci-armedrioukbrondani
authored
Rpc development (#1200) (#2098)
* [projmgr] Introduce JSON-RPC server mode * Add `GetComponentsInfo` request * Add `GetPacksInfo` and `ValidateComponents` requests * Add `GetLogMessages` requests * Add `bundles` to `GetComponentsInfo` request * GetComponentsTree request added * Make more RPC data optional * Taxonomy * Fix for cclass level Initial unit tests preparation * Only report aggregates belonging to the bundle * report selected components in the tree * Fix adding api and taxonomy to group * Select methods and use of individual contexts * Check if component exists for variant change * add flag to list components from all packs * Components from all/solution packs * Extend jrpc commands and structures. Always write active bundle * Correct GetUsedData * Add layer information consistent use of selectedCount * Add layer filed to CtAggregate Ensure value is set and propagated. Remove Component Instance from CtAggregate structure Add helper method in XmlItem class to assign an attribute from one object to another * [json-rpc] Add `RpcInterface.h` --------- Co-authored-by: Daniel Brondani <daniel.brondani@arm.com> Co-authored-by: Evgueni Driouk <edriouk@arm.com> Co-authored-by: Daniel Brondani <daniel.brondani@arm.com>
1 parent b4ab6b8 commit 8c37dec

40 files changed

Lines changed: 1950 additions & 83 deletions

.github/.cppcheck_suppressions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
unusedFunction:libs/xmltree/src/XMLTree.cpp:47
44
unusedFunction:libs/xmlschemachecker/src/XmlErrorHandler.cpp:27
55
unusedFunction:libs/xmlschemachecker/src/XmlErrorHandler.cpp:32
6+
unusedFunction:tools/projmgr/src/ProjMgrRpcServer.cpp

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@
2929
path = external/xerces-c
3030
url = https://github.com/apache/xerces-c.git
3131
ignore = dirty
32+
[submodule "external/json-rpc-cxx"]
33+
path = external/json-rpc-cxx
34+
url = https://github.com/jsonrpcx/json-rpc-cxx.git

external/json-rpc-cxx

Submodule json-rpc-cxx added at a0e195b

libs/rtemodel/src/RteComponent.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "RteInstance.h"
2121
#include "RteProject.h"
2222
#include "RteGenerator.h"
23+
#include "RteConstants.h"
2324

2425
#include "XMLTree.h"
2526

@@ -608,6 +609,7 @@ void RteComponentAggregate::SetComponentInstance(RteComponentInstance* ci, int c
608609
RteItem* ei = ci->GetEffectiveItem(targetName);
609610
m_selectedVariant = ei->GetCvariantName();
610611
m_selectedVersion = ei->GetVersionString();
612+
AssignAttribute("layer", *ci);
611613

612614
if (m_components.empty()) {
613615
if (c) {
@@ -1625,8 +1627,9 @@ string RteComponentGroup::GetTaxonomyDescriptionID() const
16251627
string id;
16261628
if (m_parent)
16271629
id = m_parent->GetTaxonomyDescriptionID();
1628-
if (!id.empty())
1629-
id += ".";
1630+
if(!id.empty()) {
1631+
id += RteConstants::PREFIX_CGROUP;
1632+
}
16301633
id += GetName();
16311634
return id;
16321635
}

libs/rtemodel/src/RteProject.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,8 @@ bool RteProject::Apply()
832832
}
833833
}
834834
ci = AddComponent(c, count, target, ci);
835+
ci->AssignAttribute("layer", *a);
836+
835837
// add API if any
836838
RteApi* api = c->GetApi(target, true);
837839
if (api) {

libs/rtemodel/test/src/RteModelTest.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,12 @@ TEST_F(RteModelPrjTest, LoadCprjM4) {
11271127
EXPECT_EQ(allLayerDescriptors.size(), 10);
11281128
auto& filteredLayerDescriptors = activeTarget->GetFilteredModel()->GetLayerDescriptors();
11291129
EXPECT_EQ(filteredLayerDescriptors.size(), 10);
1130+
ca = activeTarget->GetComponentAggregate("ARM::Device:Startup");
1131+
ASSERT_NE(ca, nullptr);
1132+
EXPECT_EQ(ca->GetAttribute("layer"), "LayerOne");
1133+
ci = ca->GetComponentInstance();
1134+
EXPECT_EQ(ci->GetAttribute("layer"), "LayerOne");
1135+
ASSERT_NE(ci, nullptr);
11301136

11311137
const string projDir = RteUtils::ExtractFilePath(RteTestM4_cprj, true);
11321138
const string rteDir = projDir + "RTE/";

libs/xmltree/include/XmlItem.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,19 @@ class XmlItem
160160

161161
/**
162162
* @brief replace instance attributes with the given ones
163-
* @param attributes given instance of XmlItem
163+
* @param attributes instance of XmlItem containing attributes to assign
164164
* @return true if attributes are set
165165
*/
166166
bool SetAttributes(const XmlItem &attributes);
167167

168+
/**
169+
* @brief assign specified attribute value from supplied object to this one
170+
* @param name attribute name
171+
* @param from instance of XmlItem to get value from
172+
* @return true if attribute is changed
173+
*/
174+
bool AssignAttribute(const std::string& name, const XmlItem &from);
175+
168176
/**
169177
* @brief remove attribute
170178
* @param name attribute name

libs/xmltree/src/XmlItem.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,12 @@ bool XmlItem::AddAttribute(const string& name, const string& value, bool insertE
6262
return true;
6363
}
6464
}
65-
if (insertEmpty || !value.empty())
65+
66+
if(insertEmpty || !value.empty()) {
6667
m_attributes[name] = value;
67-
return true;
68+
return true;
69+
}
70+
return false;
6871
}
6972

7073
bool XmlItem::SetAttribute(const char* name, const char* value)
@@ -104,6 +107,10 @@ bool XmlItem::SetAttributes(const XmlItem& attributes)
104107
return SetAttributes(attributes.GetAttributes());
105108
}
106109

110+
bool XmlItem::AssignAttribute(const std::string& name, const XmlItem& from) {
111+
return AddAttribute(name, from.GetAttribute(name), false);
112+
}
113+
107114
bool XmlItem::RemoveAttribute(const std::string& name)
108115
{
109116
map<string, string>::iterator it = m_attributes.find(name);

libs/xmltree/test/src/XmlTreeTest.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@ TEST(XmlTreeTest, GetAttribute) {
2626
e.AddAttribute("zeroTen", "010");
2727
e.AddAttribute("minusOne", "-1");
2828

29+
XMLTreeElement another;
30+
EXPECT_FALSE(another.AssignAttribute("unknown",e));
31+
EXPECT_FALSE(another.HasAttribute("unknown"));
32+
EXPECT_TRUE(another.SetAttribute("unknown", "unknown"));
33+
EXPECT_TRUE(another.AssignAttribute("unknown",e));
34+
EXPECT_FALSE(another.HasAttribute("unknown"));
35+
36+
EXPECT_TRUE(another.AssignAttribute("ten",e));
37+
EXPECT_TRUE(another.HasAttribute("ten"));
38+
EXPECT_FALSE(another.AssignAttribute("ten",e)); // already assigned
39+
EXPECT_TRUE(another.SetAttribute("ten","010"));
40+
EXPECT_TRUE(another.AssignAttribute("ten",e));
41+
2942
EXPECT_EQ(e.GetAttribute("unknown").empty(), true);
3043
EXPECT_EQ(e.GetAttribute("string"), "strVal");
3144
EXPECT_EQ(e.GetAttribute("empty").empty(), true);

tools/projmgr/CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ SET(PROJMGR_SOURCE_FILES ProjMgr.cpp ProjMgrKernel.cpp ProjMgrCallback.cpp
2222
ProjMgrCbuildBase.cpp ProjMgrCbuild.cpp ProjMgrCbuildIdx.cpp
2323
ProjMgrCbuildGenIdx.cpp ProjMgrCbuildPack.cpp ProjMgrCbuildSet.cpp
2424
ProjMgrCbuildRun.cpp ProjMgrRunDebug.cpp
25+
ProjMgrRpcServer.cpp ProjMgrRpcServerData.cpp
2526
)
2627
SET(PROJMGR_HEADER_FILES ProjMgr.h ProjMgrKernel.h ProjMgrCallback.h
2728
ProjMgrParser.h ProjMgrWorker.h ProjMgrGenerator.h ProjMgrXmlParser.h
2829
ProjMgrYamlParser.h ProjMgrLogger.h ProjMgrYamlSchemaChecker.h
2930
ProjMgrYamlEmitter.h ProjMgrUtils.h ProjMgrExtGenerator.h
3031
ProjMgrCbuildBase.h ProjMgrRunDebug.h
32+
ProjMgrRpcServer.h ProjMgrRpcServerData.h
33+
RpcInterface.h
3134
)
3235

3336
list(TRANSFORM PROJMGR_SOURCE_FILES PREPEND src/)
@@ -37,8 +40,12 @@ add_library(projmgrlib OBJECT ${PROJMGR_SOURCE_FILES} ${PROJMGR_HEADER_FILES})
3740
target_link_libraries(projmgrlib
3841
PUBLIC
3942
CrossPlatform RteFsUtils RteUtils XmlTree XmlTreeSlim XmlReader
40-
RteModel cxxopts yaml-cpp YmlSchemaChecker)
41-
target_include_directories(projmgrlib PRIVATE include ${PROJECT_BINARY_DIR})
43+
RteModel cxxopts yaml-cpp YmlSchemaChecker
44+
)
45+
target_include_directories(projmgrlib PUBLIC include ${PROJECT_BINARY_DIR}
46+
${CMAKE_SOURCE_DIR}/external/json
47+
${CMAKE_SOURCE_DIR}/external/json-rpc-cxx/include
48+
)
4249

4350
if(SWIG_LIBS)
4451
# projmgr swig

0 commit comments

Comments
 (0)