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
6 changes: 3 additions & 3 deletions libs/rtemodel/include/RteInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ class RteItemInstance : public RteItem
* @param attr attributes to set as XmlItem reference
* @return true if changed
*/
virtual bool SetPackageAttributes(const XmlItem& attr) { return m_packageAttributes.SetAttributes(attr); }
virtual bool SetPackageAttributes(const XmlItem& attr) { return m_packageAttributes.CopyAttributes(attr); }

/**
* @brief get pointer to resolved RtePackage
Expand Down Expand Up @@ -594,7 +594,7 @@ class RtePackageInstanceInfo : public RteItemInstance
* @param attr pack attributes to set
* @return true if attribute values have changed
*/
bool SetPackageAttributes(const XmlItem& attr) override { return SetAttributes(attr); }
bool SetPackageAttributes(const XmlItem& attr) override { return CopyAttributes(attr); }

/**
* @brief check if this object contains pack attributes directly rather than in a dedicated child
Expand Down Expand Up @@ -714,7 +714,7 @@ class RteGpdscInfo : public RteItemInstance
* @param attr pack attributes
* @return true if changed
*/
bool SetPackageAttributes(const XmlItem& attr) override { return SetAttributes(attr); }
bool SetPackageAttributes(const XmlItem& attr) override { return CopyAttributes(attr); }

/**
* @brief check if this object contains pack attributes directly rather than in a dedicated child
Expand Down
2 changes: 1 addition & 1 deletion libs/rtemodel/include/RteModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ class RteModel : public RteItem
* @param books collection of file path mapped to book title to fill
* @param deviceAttributes device attributes
*/
void GetBoardBooks(std::map<std::string, std::string>& books, const std::map<std::string, std::string>& deviceAttributes) const;
void GetBoardBooks(std::map<std::string, std::string>& books, const XmlItem& deviceAttributes) const;

public:
/**
Expand Down
8 changes: 4 additions & 4 deletions libs/rtemodel/src/RteInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ void RteInstanceTargetInfo::CopySettings(const RteInstanceTargetInfo& other)
SetVersionMatchMode(other.GetVersionMatchMode());
SetExcluded(other.IsExcluded());
SetIncludeInLib(other.IsIncludeInLib());
m_memOpt.SetAttributes(other.GetMemOpt());
m_cOpt.SetAttributes(other.GetCOpt());
m_asmOpt.SetAttributes(other.GetAsmOpt());
m_memOpt.CopyAttributes(other.GetMemOpt());
m_cOpt.CopyAttributes(other.GetCOpt());
m_asmOpt.CopyAttributes(other.GetAsmOpt());
}


Expand Down Expand Up @@ -700,7 +700,7 @@ void RteFileInstance::Update(RteItem* f, bool bUpdateComponent)
for (auto [targetName, ti] : m_targetInfos) {
RteComponentInstance* ci = GetComponentInstance(targetName);
if (ci) {
ci->SetAttributes(m_componentAttributes);
ci->CopyAttributes(m_componentAttributes);
ci->SetPackageAttributes(m_packageAttributes);
}
}
Expand Down
7 changes: 4 additions & 3 deletions libs/rtemodel/src/RteModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,13 +800,14 @@ void RteModel::GetBoardBooks(map<string, string>& books, const string& device, c
return;
XmlItem ea;
d->GetEffectiveAttributes(ea);
GetBoardBooks(books, ea.GetAttributes());
GetBoardBooks(books, ea);
}

void RteModel::GetBoardBooks(map<string, string>& books, const map<string, string>& deviceAttributes) const
void RteModel::GetBoardBooks(map<string, string>& books, const XmlItem& deviceAttributes) const
{
if (m_boards.empty())
if(m_boards.empty()) {
return;
}
for (auto [_, b] : m_boards) {
if (b->HasCompatibleDevice(deviceAttributes)) {
b->GetBooks(books);
Expand Down
12 changes: 6 additions & 6 deletions libs/rtemodel/src/RteProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ RteLicenseInfo* RteLicenseInfoCollection::EnsureLicenseInfo(RteItem* item, RteIt
m_LicensInfos[licId] = info;
string licFile;
if (license) {
info->SetAttributes(*license);
info->CopyAttributes(*license);
if(!info->HasAttribute("spdx")) {
licFile = license->GetName();
}
Expand Down Expand Up @@ -399,7 +399,7 @@ RteComponentInstance* RteProject::AddComponent(RteComponent* c, int instanceCoun
if (c->IsGenerated() && c->HasAttribute("selectable") ) {
RteItem* packInfo = c->GetFirstChild("package");
if (packInfo) {
ci->SetPackageAttributes(packInfo->GetAttributes());
ci->SetPackageAttributes(*packInfo);
}
}

Expand Down Expand Up @@ -1460,18 +1460,18 @@ RteItem::ConditionResult RteProject::ResolveComponents(bool bFindReplacementForA
}

// first try to find a component from the same vendor
t->GetComponentAggregates(componentAttributes.GetAttributes(), aggregates);
t->GetComponentAggregates(componentAttributes, aggregates);

// try to find a component from any vendor
if (aggregates.empty()) {
componentAttributes.RemoveAttribute("Cvendor");
t->GetComponentAggregates(componentAttributes.GetAttributes(), aggregates);
t->GetComponentAggregates(componentAttributes, aggregates);
}

// try to find a component with any variant
if (aggregates.empty() && !componentAttributes.GetCvariantName().empty()) {
componentAttributes.RemoveAttribute("Cvariant");
t->GetComponentAggregates(componentAttributes.GetAttributes(), aggregates);
t->GetComponentAggregates(componentAttributes, aggregates);
}

}
Expand Down Expand Up @@ -1601,7 +1601,7 @@ bool RteProject::AddTarget(const string& name, const map<string, string>& attrib
targetAttributes.RemoveAttribute("Bversion");
}

bool changed = target->SetAttributes(targetAttributes);
bool changed = target->CopyAttributes(targetAttributes);
if (supported) {
if (bNewTarget) {
AddTargetInfo(name);
Expand Down
7 changes: 7 additions & 0 deletions libs/rtemodel/src/RteTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,13 @@ void RteTarget::ProcessAttributes() // called from SetAttributes(), AddAttribute
{
if (m_bDestroy)
return;

// set empty board name to filter-out board-specific items if device is selected
if(HasAttribute("Dname") &&
!HasAttribute("Bname")) {
AddAttribute("Bname", "");
}

m_device = 0;
RteModel *model = GetFilteredModel();
if (!model)
Expand Down
4 changes: 2 additions & 2 deletions libs/rtemodel/test/src/RteChkTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ From DFP: 24\n\
From BSP: 0\n\
\n\
Devices: 10\n\
Boards: 14\n\
Boards: 15\n\
\n\
completed\n";

Expand All @@ -53,7 +53,7 @@ completed\n";
EXPECT_EQ(rteChk.GetPackCount(), 8);
EXPECT_EQ(rteChk.GetComponentCount(), 60);
EXPECT_EQ(rteChk.GetDeviceCount(), 10);
EXPECT_EQ(rteChk.GetBoardCount(), 14);
EXPECT_EQ(rteChk.GetBoardCount(), 15);

string s = RteUtils::EnsureLf(ss.str());
EXPECT_EQ(s, summary);
Expand Down
29 changes: 29 additions & 0 deletions libs/rtemodel/test/src/RteItemTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,33 @@ TEST(RteItemTest, GetInstancePathName) {
EXPECT_EQ(instanceFile, "MySolDir/.cmsis/MySolName+MyTarget.dbgconf");
}

TEST(RteTargetTest, ProcessAttributes_Bname) {
RteTarget target(nullptr, nullptr, "test", {});

// Bname is not set by default
EXPECT_FALSE(target.HasAttribute("Bname"));

// Bname is not set when no Dname
target.SetAttributes({{"Dfpu", "NO_FPU"}});
EXPECT_FALSE(target.HasAttribute("Bname"));
target.ClearAttributes();

// Bname is set to empty if Dname and no Bname
target.SetAttributes({{"Dname", "MyDevice"}});
EXPECT_TRUE(target.HasAttribute("Bname"));
EXPECT_EQ(target.GetAttribute("Bname"), "");
target.ClearAttributes();

// Bname only
target.SetAttributes({{"Bname", "MyBoard"}});
EXPECT_TRUE(target.HasAttribute("Bname"));
EXPECT_EQ(target.GetAttribute("Bname"), "MyBoard");
target.ClearAttributes();

// Bname with Dname
target.SetAttributes({{"Bname", "MyBoard"}, {"Dname", "MyDevice"}});
EXPECT_TRUE(target.HasAttribute("Bname"));
EXPECT_EQ(target.GetAttribute("Bname"), "MyBoard");
}

// end of RteItemTest.cpp
6 changes: 3 additions & 3 deletions libs/rtemodel/test/src/RteModelTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ TEST_F(RteModelPrjTest, LoadCprj) {
EXPECT_EQ(boardName, "RteTest Test board");
// get layers
auto& allLayerDescriptors = rteKernel.GetGlobalModel()->GetLayerDescriptors();
EXPECT_EQ(allLayerDescriptors.size(), 10);
EXPECT_EQ(allLayerDescriptors.size(), 13);
auto& filteredLayerDescriptors = activeTarget->GetFilteredModel()->GetLayerDescriptors();
EXPECT_EQ(filteredLayerDescriptors.size(), 8);

Expand Down Expand Up @@ -1077,7 +1077,7 @@ TEST_F(RteModelPrjTest, LoadCprjM4) {
EXPECT_TRUE(boardName.empty());
// get layers
auto& allLayerDescriptors = rteKernel.GetGlobalModel()->GetLayerDescriptors();
EXPECT_EQ(allLayerDescriptors.size(), 10);
EXPECT_EQ(allLayerDescriptors.size(), 13);
auto& filteredLayerDescriptors = activeTarget->GetFilteredModel()->GetLayerDescriptors();
EXPECT_EQ(filteredLayerDescriptors.size(), 7);
ca = activeTarget->GetComponentAggregate("ARM::Device:Startup");
Expand Down Expand Up @@ -1160,7 +1160,7 @@ TEST_F(RteModelPrjTest, LoadCprjM4_Board) {
EXPECT_EQ(boardName, "RteTest CM4 board");
// get layers
auto& allLayerDescriptors = rteKernel.GetGlobalModel()->GetLayerDescriptors();
EXPECT_EQ(allLayerDescriptors.size(), 10);
EXPECT_EQ(allLayerDescriptors.size(), 13);
auto& filteredLayerDescriptors = activeTarget->GetFilteredModel()->GetLayerDescriptors();
EXPECT_EQ(filteredLayerDescriptors.size(), 7);

Expand Down
6 changes: 3 additions & 3 deletions libs/xmltree/include/XmlItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ class XmlItem
* @brief parametrized constructor
* @param tag XML tag
*/
XmlItem(const std::string& tag) : m_tag(tag), m_lineNumber(0) {};
explicit XmlItem(const std::string& tag) : m_tag(tag), m_lineNumber(0) {};

/**
* @brief parametrized constructor to instantiate with given attributes
* @param attributes collection as key to value pairs
*/
XmlItem(const std::map<std::string, std::string>& attributes) : m_attributes(attributes), m_lineNumber(0) {};
explicit XmlItem(const std::map<std::string, std::string>& attributes) : m_attributes(attributes), m_lineNumber(0) {};

/**
* @brief virtual destructor
Expand Down Expand Up @@ -163,7 +163,7 @@ class XmlItem
* @param attributes instance of XmlItem containing attributes to assign
* @return true if attributes are set
*/
bool SetAttributes(const XmlItem &attributes);
bool CopyAttributes(const XmlItem &attributes);

/**
* @brief assign specified attribute value from supplied object to this one
Expand Down
2 changes: 1 addition & 1 deletion libs/xmltree/src/XmlItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ bool XmlItem::SetAttributes(const map<string, string>& attributes)
}


bool XmlItem::SetAttributes(const XmlItem& attributes)
bool XmlItem::CopyAttributes(const XmlItem& attributes)
{
return SetAttributes(attributes.GetAttributes());
}
Expand Down
21 changes: 21 additions & 0 deletions test/packs/ARM/RteTest_DFP/0.2.0/ARM.RteTest_DFP.pdsc
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,13 @@
<require Bname="RteTest Dummy board" Bvendor="Keil" Brevision="1.2.3"/>
</condition>

<condition id="AnyBoard">
<description>Test component filtering on Dummy any Board</description>
<require Dvendor="ARM:82" Dname="*ARMCM*"/>
<require Bname="Any Board" Bvendor="Keil" Brevision="1.2.3"/>
</condition>


<condition id="BoardDependent">
<description>Checks board dependency</description>
<accept condition="BoardTest1"/>
Expand Down Expand Up @@ -549,6 +556,11 @@
<mountedDevice deviceIndex="0" Dvendor="ARM:82" Dname="RteTest_ARMCM0_Dual"/>
<compatibleDevice deviceIndex="0" Dvendor="ARM:82" Dname="RteTest_ARMCM4_NOFP"/>
</board>
<board name="Any Board" vendor="Keil" revision="1.2.3">
<description>Board for AnyBoard Tests</description>
<mountedDevice deviceIndex="0" Dvendor="ARM:82" Dname="RteTest_ARMCM3"/>
<compatibleDevice deviceIndex="0" Dvendor="ARM:82" Dname="RteTest_ARMCM3"/>
</board>
</boards>

<csolution>
Expand All @@ -561,6 +573,15 @@
<clayer name="Board3" type="Board" file="Layers/board3.clayer.yml" condition="BoardTest3">
<description>"Test board layer three"</description>
</clayer>
<clayer name="AnyBoard1" type="Board" file="Layers/board1.clayer.yml" condition="AnyBoard">
<description>"Test any board layer 1"</description>
</clayer>
<clayer name="AnyBoard2" type="Board" file="Layers/board2.clayer.yml" condition="AnyBoard">
<description>"Test any board layer 2"</description>
</clayer>
<clayer name="AnyBoard3" type="Board" file="Layers/board3.clayer.yml" condition="AnyBoard">
<description>"Test any board layer 3"</description>
</clayer>
<template name="Board1Template" file="Templates/board1.csolution.yml" condition="BoardTest1">
<description>"Test board Template one"</description>
</template>
Expand Down
6 changes: 3 additions & 3 deletions tools/projmgr/src/ProjMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ bool ProjMgr::RunConvert(const std::string& csolution, const std::string& active
if (!csolution.empty()) {
InitSolution(csolution, activeTargetSet, updateRte);
}

// Configure
bool Success = Configure();

Expand Down Expand Up @@ -1090,8 +1090,8 @@ bool ProjMgr::RunListLayers(void) {

// Step3: Detect layers and list them
vector<string> layers;
error = !m_worker.ListLayers(layers, m_clayerSearchPath, m_failedContext);
if (error) {
if (!m_worker.ListLayers(layers, m_clayerSearchPath, m_failedContext)) {
error = true;
for (const string& context : m_failedContext) {
ProjMgrLogger::Get().Error("no compatible software layer found. Review required connections of the project", context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ solution:
device: :cm0_core0
- type: AnyBoard
device: RteTest_ARMCM3
board: Any Board
- type: BoardSpecific
board: RteTest board listing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ solution:
target-types:
- type: TargetType
device: RteTest_ARMCM0
board: RteTest Dummy board

projects:
- project: variables-notdefined.cproject.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

project:
device: RteTest_ARMCM0
board: RteTest Test board
compiler: AC6
components:
- component: Board:Test:Rev1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ layer:

components:
- component: Board:Test:Rev1
not-for-context: +RteTest_ARMCM3
- component: Device:Startup&RteTest Startup
for-context: [.PriorityRegions, .PriorityDefines, .Debug_GCC]
- component: RteTest:CORE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
build:
generated-by: csolution version 0.0.0+gab7ac463
generated-by: csolution version 0.0.0+ga8747d9a
solution: ../data/TestSolution/LinkerOptions/linker.csolution.yml
project: ../data/TestSolution/LinkerOptions/linker.cproject.yml
context: linker.AutoGen+RteTest_ARMCM3
Expand All @@ -26,11 +26,9 @@ build:
- _RTE_
add-path:
- ../data/TestSolution/LinkerOptions/RTE/_AutoGen_RteTest_ARMCM3
- ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Device/ARM/ARMCM0/Include
- ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Device/ARM/ARMCM3/Include
add-path-asm:
- ../data/TestSolution/LinkerOptions/RTE/_AutoGen_RteTest_ARMCM3
- ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Device/ARM/ARMCM0/Include
- ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Device/ARM/ARMCM3/Include
output-dirs:
intdir: tmp/linker/RteTest_ARMCM3/AutoGen
Expand All @@ -40,14 +38,6 @@ build:
- type: elf
file: linker.axf
components:
- component: ARM::Board:Test:Rev1@1.1.1
condition: BoardTest1
from-pack: ARM::RteTest_DFP@0.2.0
selected-by: Board:Test:Rev1
files:
- file: ${CMSIS_PACK_ROOT}/ARM/RteTest_DFP/0.2.0/Device/ARM/ARMCM0/Include/ARMCM0.h
category: header
version: 1.1.1
- component: ARM::Device:Startup&RteTest Startup@2.0.3
condition: ARMCM3 RteTest
from-pack: ARM::RteTest_DFP@0.2.0
Expand Down Expand Up @@ -83,5 +73,4 @@ build:
packs:
- pack: ARM::RteTest_DFP@0.2.0
components:
- component: ARM::Board:Test:Rev1@1.1.1
- component: ARM::Device:Startup&RteTest Startup@2.0.3
Loading
Loading