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
1 change: 1 addition & 0 deletions .github/.cppcheck_suppressions
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
unusedFunction:libs/xmltree/src/XMLTree.cpp:47
unusedFunction:libs/xmlschemachecker/src/XmlErrorHandler.cpp:27
unusedFunction:libs/xmlschemachecker/src/XmlErrorHandler.cpp:32
unusedFunction:tools/projmgr/src/ProjMgrRpcServer.cpp
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@
path = external/xerces-c
url = https://github.com/apache/xerces-c.git
ignore = dirty
[submodule "external/json-rpc-cxx"]
path = external/json-rpc-cxx
url = https://github.com/jsonrpcx/json-rpc-cxx.git
1 change: 1 addition & 0 deletions external/json-rpc-cxx
Submodule json-rpc-cxx added at a0e195
7 changes: 5 additions & 2 deletions libs/rtemodel/src/RteComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "RteInstance.h"
#include "RteProject.h"
#include "RteGenerator.h"
#include "RteConstants.h"

#include "XMLTree.h"

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

if (m_components.empty()) {
if (c) {
Expand Down Expand Up @@ -1625,8 +1627,9 @@ string RteComponentGroup::GetTaxonomyDescriptionID() const
string id;
if (m_parent)
id = m_parent->GetTaxonomyDescriptionID();
if (!id.empty())
id += ".";
if(!id.empty()) {
id += RteConstants::PREFIX_CGROUP;
}
id += GetName();
return id;
}
Expand Down
2 changes: 2 additions & 0 deletions libs/rtemodel/src/RteProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,8 @@ bool RteProject::Apply()
}
}
ci = AddComponent(c, count, target, ci);
ci->AssignAttribute("layer", *a);

// add API if any
RteApi* api = c->GetApi(target, true);
if (api) {
Expand Down
6 changes: 6 additions & 0 deletions libs/rtemodel/test/src/RteModelTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,12 @@ TEST_F(RteModelPrjTest, LoadCprjM4) {
EXPECT_EQ(allLayerDescriptors.size(), 10);
auto& filteredLayerDescriptors = activeTarget->GetFilteredModel()->GetLayerDescriptors();
EXPECT_EQ(filteredLayerDescriptors.size(), 10);
ca = activeTarget->GetComponentAggregate("ARM::Device:Startup");
ASSERT_NE(ca, nullptr);
EXPECT_EQ(ca->GetAttribute("layer"), "LayerOne");
ci = ca->GetComponentInstance();
EXPECT_EQ(ci->GetAttribute("layer"), "LayerOne");
ASSERT_NE(ci, nullptr);

const string projDir = RteUtils::ExtractFilePath(RteTestM4_cprj, true);
const string rteDir = projDir + "RTE/";
Expand Down
10 changes: 9 additions & 1 deletion libs/xmltree/include/XmlItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,19 @@ class XmlItem

/**
* @brief replace instance attributes with the given ones
* @param attributes given instance of XmlItem
* @param attributes instance of XmlItem containing attributes to assign
* @return true if attributes are set
*/
bool SetAttributes(const XmlItem &attributes);

/**
* @brief assign specified attribute value from supplied object to this one
* @param name attribute name
* @param from instance of XmlItem to get value from
* @return true if attribute is changed
*/
bool AssignAttribute(const std::string& name, const XmlItem &from);

/**
* @brief remove attribute
* @param name attribute name
Expand Down
11 changes: 9 additions & 2 deletions libs/xmltree/src/XmlItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@ bool XmlItem::AddAttribute(const string& name, const string& value, bool insertE
return true;
}
}
if (insertEmpty || !value.empty())

if(insertEmpty || !value.empty()) {
m_attributes[name] = value;
return true;
return true;
}
return false;
}

bool XmlItem::SetAttribute(const char* name, const char* value)
Expand Down Expand Up @@ -104,6 +107,10 @@ bool XmlItem::SetAttributes(const XmlItem& attributes)
return SetAttributes(attributes.GetAttributes());
}

bool XmlItem::AssignAttribute(const std::string& name, const XmlItem& from) {
return AddAttribute(name, from.GetAttribute(name), false);
}

bool XmlItem::RemoveAttribute(const std::string& name)
{
map<string, string>::iterator it = m_attributes.find(name);
Expand Down
13 changes: 13 additions & 0 deletions libs/xmltree/test/src/XmlTreeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ TEST(XmlTreeTest, GetAttribute) {
e.AddAttribute("zeroTen", "010");
e.AddAttribute("minusOne", "-1");

XMLTreeElement another;
EXPECT_FALSE(another.AssignAttribute("unknown",e));
EXPECT_FALSE(another.HasAttribute("unknown"));
EXPECT_TRUE(another.SetAttribute("unknown", "unknown"));
EXPECT_TRUE(another.AssignAttribute("unknown",e));
EXPECT_FALSE(another.HasAttribute("unknown"));

EXPECT_TRUE(another.AssignAttribute("ten",e));
EXPECT_TRUE(another.HasAttribute("ten"));
EXPECT_FALSE(another.AssignAttribute("ten",e)); // already assigned
EXPECT_TRUE(another.SetAttribute("ten","010"));
EXPECT_TRUE(another.AssignAttribute("ten",e));

EXPECT_EQ(e.GetAttribute("unknown").empty(), true);
EXPECT_EQ(e.GetAttribute("string"), "strVal");
EXPECT_EQ(e.GetAttribute("empty").empty(), true);
Expand Down
11 changes: 9 additions & 2 deletions tools/projmgr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ SET(PROJMGR_SOURCE_FILES ProjMgr.cpp ProjMgrKernel.cpp ProjMgrCallback.cpp
ProjMgrCbuildBase.cpp ProjMgrCbuild.cpp ProjMgrCbuildIdx.cpp
ProjMgrCbuildGenIdx.cpp ProjMgrCbuildPack.cpp ProjMgrCbuildSet.cpp
ProjMgrCbuildRun.cpp ProjMgrRunDebug.cpp
ProjMgrRpcServer.cpp ProjMgrRpcServerData.cpp
)
SET(PROJMGR_HEADER_FILES ProjMgr.h ProjMgrKernel.h ProjMgrCallback.h
ProjMgrParser.h ProjMgrWorker.h ProjMgrGenerator.h ProjMgrXmlParser.h
ProjMgrYamlParser.h ProjMgrLogger.h ProjMgrYamlSchemaChecker.h
ProjMgrYamlEmitter.h ProjMgrUtils.h ProjMgrExtGenerator.h
ProjMgrCbuildBase.h ProjMgrRunDebug.h
ProjMgrRpcServer.h ProjMgrRpcServerData.h
RpcInterface.h
)

list(TRANSFORM PROJMGR_SOURCE_FILES PREPEND src/)
Expand All @@ -37,8 +40,12 @@ add_library(projmgrlib OBJECT ${PROJMGR_SOURCE_FILES} ${PROJMGR_HEADER_FILES})
target_link_libraries(projmgrlib
PUBLIC
CrossPlatform RteFsUtils RteUtils XmlTree XmlTreeSlim XmlReader
RteModel cxxopts yaml-cpp YmlSchemaChecker)
target_include_directories(projmgrlib PRIVATE include ${PROJECT_BINARY_DIR})
RteModel cxxopts yaml-cpp YmlSchemaChecker
)
target_include_directories(projmgrlib PUBLIC include ${PROJECT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/external/json
${CMAKE_SOURCE_DIR}/external/json-rpc-cxx/include
)

if(SWIG_LIBS)
# projmgr swig
Expand Down
23 changes: 16 additions & 7 deletions tools/projmgr/include/ProjMgr.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2024 Arm Limited. All rights reserved.
* Copyright (c) 2020-2025 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -12,6 +12,7 @@
#include "ProjMgrGenerator.h"
#include "ProjMgrYamlEmitter.h"
#include "ProjMgrRunDebug.h"
#include "ProjMgrRpcServer.h"

#include <cxxopts.hpp>

Expand Down Expand Up @@ -50,6 +51,18 @@ class ProjMgr {
*/
static int RunProjMgr(int argc, char **argv, char** envp);

/**
* @brief get worker object
* @return reference to m_worker
*/
ProjMgrWorker& GetWorker() { return m_worker; };

/**
* @brief load solution
* @param path to <solution>.csolution.yml file
* @return processing status
*/
bool LoadSolution(const std::string& csolution);

protected:
/**
Expand Down Expand Up @@ -88,12 +101,6 @@ class ProjMgr {
*/
ProjMgrParser& GetParser() { return m_parser; };

/**
* @brief get worker object
* @return reference to m_worker
*/
ProjMgrWorker& GetWorker() { return m_worker; };

/**
* @brief get generator object
* @return reference to m_generator
Expand Down Expand Up @@ -137,6 +144,7 @@ class ProjMgr {
ProjMgrGenerator m_generator;
ProjMgrYamlEmitter m_emitter;
ProjMgrRunDebug m_runDebug;
ProjMgrRpcServer m_rpcServer;

std::string m_csolutionFile;
std::string m_cdefaultFile;
Expand Down Expand Up @@ -193,6 +201,7 @@ class ProjMgr {
bool GenerateYMLConfigurationFiles(bool previousResult);
bool UpdateRte();
bool ParseAndValidateContexts();
bool ProcessContexts();
};

#endif // PROJMGR_H
4 changes: 4 additions & 0 deletions tools/projmgr/include/ProjMgrExtGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ class ProjMgrExtGenerator {
*/
ClayerItem* GetGeneratorImport(const std::string& contextId, bool& success);

void Clear() {
m_usedGenerators.clear();
}

protected:
ProjMgrParser* m_parser = nullptr;
GeneratorContextVecMap m_usedGenerators;
Expand Down
10 changes: 10 additions & 0 deletions tools/projmgr/include/ProjMgrParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ struct MiscItem {
* pack name
* pack path
* type filter
* origin file
*/
struct PackItem {
std::string pack;
std::string path;
TypeFilter type;
std::string origin;
};

/**
Expand Down Expand Up @@ -733,6 +735,14 @@ class ProjMgrParser {
*/
CbuildSetItem& GetCbuildSetItem(void);

void Clear() {
m_cdefault = {};
m_csolution = {};
m_cbuildSet = {};
m_cprojects.clear();
m_clayers.clear();
m_genericClayers.clear();
}
/**
* @brief get debug adapters
* @return debug adapters list
Expand Down
68 changes: 68 additions & 0 deletions tools/projmgr/include/ProjMgrRpcServer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright (c) 2025 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef PROJMGRRPCSERVER_H
#define PROJMGRRPCSERVER_H

#include <map>
#include <string>

/**
* Forward declarations
*/
class ProjMgr;

/**
* @brief projmgr rpc server
*/
class ProjMgrRpcServer {
public:
/**
* @brief class constructor
*/
ProjMgrRpcServer(ProjMgr& manager);

/**
* @brief class destructor
*/
~ProjMgrRpcServer(void);

/**
* @brief run rpc server
* @return true if terminated successfully, otherwise false
*/
bool Run(void);

/**
* @brief get parser object
* @return reference to m_manager
*/
ProjMgr& GetManager() { return m_manager; };

void SetDebug(bool debug) { m_debug = debug; }

/**
* @brief set m_shutdown flag
* @param boolean value
*/
void SetShutdown(bool value) { m_shutdown = value; }

/**
* @brief set m_contextLength flag
* @param boolean value
*/
void SetContentLengthHeader(bool value) { m_contextLength = value; }

protected:
ProjMgr& m_manager;
bool m_debug = false;
bool m_shutdown = false;
bool m_contextLength = false;
const std::string GetRequestFromStdinWithLength(void);
const std::string GetRequestFromStdin(void);
};

#endif // PROJMGRRPCSERVER_H
44 changes: 44 additions & 0 deletions tools/projmgr/include/ProjMgrRpcServerData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2025 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef PROJMGRRPCSERVERDATA_H
#define PROJMGRRPCSERVERDATA_H

#include <RpcInterface.h>

using namespace std;

class RteTarget;
class RteBundle;
class RteComponent;
class RteComponentInstance;
class RteComponentAggregate;
class RteComponentGroup;
class RteItem;
class RpcDataCollector {
public:
RpcDataCollector(RteTarget* t);

RteTarget* GetTarget() const { return m_target; }

void CollectCtClasses(Args::CtRoot& ctRoot) const;
void CollectUsedItems(Args::UsedItems& usedItems) const;

Args::Component FromRteComponent(const RteComponent* rteComponent) const;
Args::ComponentInstance FromComponentInstance(const RteComponentInstance* rteCi) const;
RteItem* GetTaxonomyItem(const RteComponentGroup* rteGroup) const;

protected:

void CollectCtBundles(Args::CtClass& ctClass, RteComponentGroup* rteClass) const;
void CollectCtChildren(Args::CtTreeItem& parent, RteComponentGroup* rteGroup, const string& bundleName) const;
void CollectCtAggregates(Args::CtTreeItem& parent, RteComponentGroup* rteGroup, const string& bundleName) const;
void CollectCtVariants(Args::CtAggregate& ctAggregate, RteComponentAggregate* rteAggregate) const;

private:
RteTarget* m_target;
};

#endif // PROJMGRRPCSERVERDATA_
4 changes: 4 additions & 0 deletions tools/projmgr/include/ProjMgrRunDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ class ProjMgrRunDebug {
*/
bool CollectSettings(const std::vector<ContextItem*>& contexts, const DebugAdaptersItem& adapters);

void Clear() {
m_runDebug = {};
}

protected:
RunDebugType m_runDebug;
void GetDebugSequenceBlock(const RteItem* item, DebugSequencesBlockType& block);
Expand Down
Loading
Loading