Skip to content

Commit

Permalink
RTE Model fixes and enhancements (#1240)
Browse files Browse the repository at this point in the history
bugfix in getting component bundle
added RteModel parameter to RteKernel::LoadPacks()
removed unused NULL_RTE_KERNEL

Co-authored-by: Evgueni Driouk <edriouk@arm.com>
  • Loading branch information
grasci-arm and edriouk authored Dec 6, 2023
1 parent db75139 commit 252b6c4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
14 changes: 3 additions & 11 deletions libs/rtemodel/include/RteKernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,6 @@ class RteKernel
*/
virtual CprjFile* GetActiveCprjFile() const;

/**
* @brief getter for "empty" RteKernel object
* @return RteKernel::NULL_RTE_KERNEL
*/
static RteKernel* GetNullKernel() { return &NULL_RTE_KERNEL; }

/**
* @brief get installed packs
* @param pdscFiles list of installed packs
Expand Down Expand Up @@ -254,9 +248,11 @@ class RteKernel
* @brief load specified pdsc files, but does not insert them in the model
* @param pdscFiles list of pathnames to load
* @param packs list to receive loaded packs
* @param model RteModel to get state and serve as parent
* @return true if successful
*/
bool LoadPacks(const std::list<std::string>& pdscFiles, std::list<RtePackage*>& packs) const;
bool LoadPacks(const std::list<std::string>& pdscFiles, std::list<RtePackage*>& packs,
RteModel* model = nullptr) const;

/**
* @brief getter for caller information (name & version)
Expand Down Expand Up @@ -291,9 +287,5 @@ class RteKernel
RteCallback* m_rteCallback;
XmlItem m_toolInfo;
std::string m_cmsisPackRoot;

// null object to avoid crashes
static RteKernel NULL_RTE_KERNEL;

};
#endif // RteKernel_H
2 changes: 0 additions & 2 deletions libs/rtemodel/src/RteComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1824,8 +1824,6 @@ RteBundle* RteComponentClass::GetSelectedBundle() const
{
if (!m_selectedBundleName.empty()) {
string bundleId = GetSelectedBundleShortID();
bundleId += "::";
bundleId += GetName();
return GetTarget()->GetFilteredModel()->GetLatestBundle(bundleId);
}
return nullptr;
Expand Down
9 changes: 5 additions & 4 deletions libs/rtemodel/src/RteKernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ static constexpr const char* R822 = "Pack 'path' was not found";
static constexpr const char* R823 = "No PDSC file was found";
static constexpr const char* R824 = "Multiple PDSC files were found";

RteKernel RteKernel::NULL_RTE_KERNEL;

RteKernel::RteKernel(RteCallback* rteCallback, RteGlobalModel* globalModel) :
m_globalModel(globalModel),
m_bOwnModel(false),
Expand Down Expand Up @@ -265,10 +263,13 @@ RtePackage* RteKernel::LoadPack(const string& pdscFile, PackageState packState)
return pack;
}

bool RteKernel::LoadPacks(const std::list<std::string>& pdscFiles, std::list<RtePackage*>& packs) const
bool RteKernel::LoadPacks(const std::list<std::string>& pdscFiles, std::list<RtePackage*>& packs, RteModel* model) const
{
if (!pdscFiles.empty()) {
RteItemBuilder rteItemBuilder(GetGlobalModel(), GetGlobalModel()->GetPackageState());
if(!model) {
model = GetGlobalModel();
}
RteItemBuilder rteItemBuilder(model, model->GetPackageState());
unique_ptr<XMLTree> xmlTree = CreateUniqueXmlTree(&rteItemBuilder);
bool success = xmlTree->SetFileNames(pdscFiles, true);
if (success) {
Expand Down
7 changes: 7 additions & 0 deletions libs/rtemodel/test/src/RteModelTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,13 @@ TEST_F(RteModelPrjTest, LoadCprj) {

RteTarget* activeTarget = activeCprjProject->GetActiveTarget();
ASSERT_NE(activeTarget, nullptr);

auto componentClass = activeTarget->GetComponentClass("RteTestBundle");
ASSERT_NE(componentClass, nullptr);
RteBundle* bundle = componentClass->GetSelectedBundle();
ASSERT_NE(bundle, nullptr);
EXPECT_EQ(bundle->GetCbundleName(), componentClass->GetSelectedBundleName());

map<const RteItem*, RteDependencyResult> depResults;
RteItem::ConditionResult res = activeTarget->GetDepsResult(depResults, activeTarget);
EXPECT_EQ(res, RteItem::FULFILLED);
Expand Down

0 comments on commit 252b6c4

Please sign in to comment.