Skip to content

Commit

Permalink
Revised Generator Workflow Proposal #1112 (#689) (#1120)
Browse files Browse the repository at this point in the history
* Revised Generator Workflow Proposal #1112
support in RteModel

Co-authored-by: Evgueni Driouk <[email protected]>
Co-authored-by: Daniel Brondani <[email protected]>
  • Loading branch information
3 people authored Sep 12, 2023
1 parent 684aaa8 commit 54b2e70
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 7 deletions.
7 changes: 7 additions & 0 deletions libs/rtemodel/include/RteCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ static const unsigned int RTE_MB_ICONEXCLAMATION = 0x00000030;
static const unsigned int RTE_MB_ICONASTERISK = 0x00000040;

class RteKernel;
class RteGenerator;
/**
* @brief Class to allow RTE to call application or API functions, defaults do nothing
*/
Expand Down Expand Up @@ -179,6 +180,12 @@ class RteCallback : public XMLTreeCallback
MergeFiles(curFile, newFile);
};

/**
* @brief obtains globally defined generator
* @param id generator id
* @return pointer to RteGenerator if found, nullptr otherwise
*/
virtual RteGenerator* GetGenerator(const std::string& id) const { return nullptr; }

/**
* @brief get global RteCallback object
Expand Down
11 changes: 8 additions & 3 deletions libs/rtemodel/src/RteComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,18 @@ RteApi* RteComponent::GetApi(RteTarget* target, bool matchVersion) const

RteGenerator* RteComponent::GetGenerator() const
{
RteGenerator* generator = nullptr;
const string& generatorName = GetGeneratorName();
if (!generatorName.empty()) {
RtePackage* pack = GetPackage();
if (pack)
return pack->GetGenerator(generatorName);
if (pack) {
generator = pack->GetGenerator(generatorName);
}
if (!generator && GetCallback()) {
generator = GetCallback()->GetGenerator(generatorName);
}
}
return nullptr;
return generator;
}

string RteComponent::GetGpdscFile(RteTarget* target) const
Expand Down
6 changes: 3 additions & 3 deletions libs/rtemodel/test/src/RteChkTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ Generic: 3\n\
DFP: 3\n\
BSP: 1\n\
\n\
Components: 52\n\
Components: 53\n\
From generic packs: 31\n\
From DFP: 21\n\
From DFP: 22\n\
From BSP: 0\n\
\n\
Devices: 10\n\
Expand All @@ -51,7 +51,7 @@ completed\n";
int res = rteChk.RunCheckRte();
EXPECT_EQ(res, 0);
EXPECT_EQ(rteChk.GetPackCount(), 7);
EXPECT_EQ(rteChk.GetComponentCount(), 52);
EXPECT_EQ(rteChk.GetComponentCount(), 53);
EXPECT_EQ(rteChk.GetDeviceCount(), 10);
EXPECT_EQ(rteChk.GetBoardCount(), 13);

Expand Down
41 changes: 41 additions & 0 deletions libs/rtemodel/test/src/RteModelTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,30 @@

using namespace std;


class ExtGenRteCallback : public RteCallback
{

public:
ExtGenRteCallback() :m_pExtGenerator(nullptr) {
m_pExtGenerator = new RteGenerator(nullptr);
m_pExtGenerator->SetTag("generator");
m_pExtGenerator->AddAttribute("id", "RteTestExternalGenerator");
m_pExtGenerator->Construct();
}
~ExtGenRteCallback() override{
delete m_pExtGenerator;
}
RteGenerator* GetGenerator(const std::string& id) const override {
if (m_pExtGenerator->GetID() == "RteTestExternalGenerator") {
return m_pExtGenerator;
}
return nullptr;
}

RteGenerator* m_pExtGenerator;
};

TEST(RteModelTest, LoadPacks) {

RteKernelSlim rteKernel; // here just to instantiate XMLTree parser
Expand Down Expand Up @@ -156,6 +180,23 @@ TEST(RteModelTest, LoadPacks) {
c = rteModel->FindComponents(item, components);
EXPECT_EQ(components.size(), 0);
EXPECT_FALSE(c != nullptr);

item.SetAttributes({ {"Cclass","RteTestGenerator" },
{"Cgroup", "Check Global Generator" },
{"Cversion","0.9.0"}});
packInfo.SetPackId("ARM::RteTestGenerator");
item.SetPackageAttributes(packInfo);
components.clear();
c = rteModel->FindComponents(item, components);
ASSERT_TRUE(c != nullptr);
RteGenerator* gen = c->GetGenerator();
EXPECT_FALSE(gen != nullptr);

ExtGenRteCallback extGenRteCallback;
rteKernel.SetRteCallback(&extGenRteCallback);
gen = c->GetGenerator();
EXPECT_TRUE(gen != nullptr);
EXPECT_TRUE(gen == extGenRteCallback.m_pExtGenerator);
}

class RteModelPrjTest : public RteModelTestConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@
<component generator="RteTestGeneratorNoDryRun" Cclass="Device" Cgroup="RteTest Generated Component" Csub="RteTestNoDryRun" Cversion="1.1.0">
<description>Configuration via RteTest script</description>
</component>
<component generator="RteTestExternalGenerator" Cclass="RteTestGenerator" Cgroup="Check Global Generator" Cversion="0.9.0">
<description>Component addressing external</description>
</component>

<bundle Cbundle="RteTestBundle" Cclass="Device" Cversion="1.0.0">
<component generator="RteTestGeneratorIdentifier" Cgroup="RteTest Generated Component" Cversion="1.1.0">
<description>Configuration via RteTest script</description>
Expand Down
3 changes: 2 additions & 1 deletion tools/projmgr/test/src/ProjMgrUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2779,7 +2779,8 @@ TEST_F(ProjMgrUnitTests, ListComponents_MultiplePackSelection) {
"ARM::Device:RteTest Generated Component:[email protected] (ARM::[email protected])",
"ARM::Device:RteTest Generated Component:[email protected] (ARM::[email protected])",
"ARM::Device:RteTest Generated Component:[email protected] (ARM::[email protected])",
"ARM::Device:RteTest Generated Component:[email protected] (ARM::[email protected])"
"ARM::Device:RteTest Generated Component:[email protected] (ARM::[email protected])",
"ARM::RteTestGenerator:Check Global [email protected] (ARM::[email protected])"
};
vector<string> components;
m_csolutionFile = testinput_folder + "/TestSolution/pack_contexts.csolution.yml";
Expand Down

0 comments on commit 54b2e70

Please sign in to comment.