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/test/src/RteChkTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ Generic: 4\n\
DFP: 3\n\
BSP: 1\n\
\n\
Components: 60\n\
Components: 61\n\
From generic packs: 36\n\
From DFP: 24\n\
From DFP: 25\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(), 8);
EXPECT_EQ(rteChk.GetComponentCount(), 60);
EXPECT_EQ(rteChk.GetComponentCount(), 61);
EXPECT_EQ(rteChk.GetDeviceCount(), 10);
EXPECT_EQ(rteChk.GetBoardCount(), 15);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,17 @@
<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>
<description>Component addressing external generator</description>
<files>
<file category="header" name="Include/RteTestInc.h" version ="1.0.0"/>
<file category="genAsset" name="Templates/RteTest.gpdsc.template" version ="1.0.0"/>
<file category="genHeader" name="Templates/RteTestGen.h.template" version ="1.0.0"/>
<file category="genSource" name="Templates/RteTestGen.c.template" version ="1.0.0"/>
<file category="genParams" name="Generator with spaces/RteTestGen.params" version ="0.9.0" attr="config"/>
</files>
</component>
<component generator="RteTestExternalGeneratorNoUrl" Cclass="RteTestGeneratorNoUrl" Cgroup="Check Global Generator" Cversion="0.9.0">
<description>Component addressing external generator without URL</description>
</component>
<component generator="RteTestGeneratorIdentifier" Cvendor="ARM" Cclass="Device" Cgroup="RteTest Generated Component" Csub="RteTestOverlap" Cversion="1.1.0">
<description>Component with overlaping file lists</description>
Expand Down
7 changes: 7 additions & 0 deletions tools/projmgr/include/ProjMgrExtGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ class ProjMgrExtGenerator {
*/
const std::string& GetGlobalGenRunCmd(const std::string& generatorId);

/**
* @brief get URL for generator download
* @param generatorId generator identifier
* @return string with URL for generator download
*/
const std::string& GetGlobalGenUrl(const std::string& generatorId);

/**
* @brief get generator description
* @param generatorId generator identifier
Expand Down
5 changes: 5 additions & 0 deletions tools/projmgr/src/ProjMgrExtGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ const string& ProjMgrExtGenerator::GetGlobalGenRunCmd(const string& generatorId)
return g ? g->GetRunAttribute() : RteUtils::EMPTY_STRING;
}

const string& ProjMgrExtGenerator::GetGlobalGenUrl(const string& generatorId) {
RteGenerator* g = ProjMgrKernel::Get()->GetExternalGenerator(generatorId);
return g ? g->GetURL() : RteUtils::EMPTY_STRING;
}

const string& ProjMgrExtGenerator::GetGlobalDescription(const string& generatorId) {
RteGenerator* g = ProjMgrKernel::Get()->GetExternalGenerator(generatorId);
return g ? g->GetDescription() : RteUtils::EMPTY_STRING;
Expand Down
15 changes: 13 additions & 2 deletions tools/projmgr/src/ProjMgrWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5650,11 +5650,22 @@ bool ProjMgrWorker::ExecuteExtGenerator(std::string& generatorId) {
fs::current_path(genDir, ec);
StrIntPair result = CrossPlatformUtils::ExecCommand(runCmd);
fs::current_path(workingDir, ec);
ProjMgrLogger::Get().Info("generator '" + generatorId + "' for context '" + selectedContextId + "' reported:\n" + result.first);
if (result.second) {
ProjMgrLogger::Get().Error("executing generator '" + generatorId + "' for context '" + selectedContextId + "' failed");
string errMsg = "executing generator '" + generatorId + "' for context '" + selectedContextId + "' failed:\n";
errMsg += " " + result.first;

const string downloadUrl = m_extGenerator->GetGlobalGenUrl(generatorId);
if (!downloadUrl.empty()) {
errMsg += " check the URL for downloading the generator: " + downloadUrl;
} else {
errMsg += " download URL is not available for generator '" + generatorId + "' in generator.yml";
}
ProjMgrLogger::Get().Error(errMsg);
return false;
} else {
ProjMgrLogger::Get().Info("generator '" + generatorId + "' for context '" + selectedContextId + "' reported:\n " + result.first);
}

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ solution:
for-context: +CM0
- project: tz_ns/ns.cproject.yml
for-context: +CM0
- project: test-url/test-url.cproject.yml
for-context: +CM0
- project: multi_0/core0.cproject.yml
for-context: +MultiCore
- project: multi_1/core1.cproject.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ generator:
download-url: https://raw.githubusercontent.com/Open-CMSIS-Pack
run: ../bin/bridge tool.sh
path: $SolutionDir()$/generated/$TargetType$
- id: RteTestExternalGeneratorNoUrl
description: Global Registered Generator Without Url
run: ../bin/bridge tool.sh
path: $SolutionDir()$/generated/$TargetType$
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/cproject.schema.json

project:
components:
- component: RteTestGeneratorNoUrl:Check Global Generator

generators:
options:
- generator: RteTestExternalGeneratorNoUrl
path: $ProjectDir()$/generated/
35 changes: 34 additions & 1 deletion tools/projmgr/test/src/ProjMgrUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4025,7 +4025,8 @@ TEST_F(ProjMgrUnitTests, ListComponents_MultiplePackSelection) {
"ARM::Device:RteTest Generated Component:RteTestWithKey@1.1.0 (ARM::RteTestGenerator@0.1.0)",
"ARM::Device:RteTest Generated Component:RteTestNoExe@1.1.0 (ARM::RteTestGenerator@0.1.0)",
"ARM::Device:RteTest Generated Component:RteTestOverlap@1.1.0 (ARM::RteTestGenerator@0.1.0)",
"ARM::RteTestGenerator:Check Global Generator@0.9.0 (ARM::RteTestGenerator@0.1.0)"
"ARM::RteTestGenerator:Check Global Generator@0.9.0 (ARM::RteTestGenerator@0.1.0)",
"ARM::RteTestGeneratorNoUrl:Check Global Generator@0.9.0 (ARM::RteTestGenerator@0.1.0)"
};
vector<string> components;
m_csolutionFile = testinput_folder + "/TestSolution/pack_contexts.csolution.yml";
Expand Down Expand Up @@ -5704,6 +5705,38 @@ TEST_F(ProjMgrUnitTests, ExternalGenerator_NoCgenFile) {
RteFsUtils::RemoveFile(dstGlobalGenerator);
}

TEST_F(ProjMgrUnitTests, ExternalGenerator_PrintUrl) {
const string& srcGlobalGenerator = testinput_folder + "/ExternalGenerator/global.generator.yml";
const string& dstGlobalGenerator = etc_folder + "/global.generator.yml";
RteFsUtils::CopyCheckFile(srcGlobalGenerator, dstGlobalGenerator, false);

StdStreamRedirect streamRedirect;
// test case where the URL returns an exit code of 1 (simulated by not copying the 'bridge tool.sh' script)
char* argv[7];
const string& csolution = testinput_folder + "/ExternalGenerator/extgen.csolution.yml";
argv[1] = (char*)csolution.c_str();
argv[2] = (char*)"run";
argv[3] = (char*)"-g";
argv[4] = (char*)"RteTestExternalGenerator";
argv[5] = (char*)"-c";
argv[6] = (char*)"single-core.Debug+CM0";
EXPECT_EQ(1, RunProjMgr(7, argv, m_envp));
string errStr = streamRedirect.GetErrorString();
string errExpected = " check the URL for downloading the generator: https://raw.githubusercontent.com/Open-CMSIS-Pack";
EXPECT_NE(string::npos, errStr.find(errExpected));

streamRedirect.ClearStringStreams();
// test case where the download-url is missing of a generator
argv[4] = (char*)"RteTestExternalGeneratorNoUrl";
argv[6] = (char*)"test-url.Debug+CM0";
EXPECT_EQ(1, RunProjMgr(7, argv, m_envp));
errStr = streamRedirect.GetErrorString();
errExpected = " download URL is not available for generator '" + string(argv[4]) + "' in generator.yml";
EXPECT_NE(string::npos, errStr.find(errExpected));

RteFsUtils::RemoveFile(dstGlobalGenerator);
}

TEST_F(ProjMgrUnitTests, ExternalGeneratorBoard) {
const string& srcGlobalGenerator = testinput_folder + "/ExternalGenerator/global.generator.yml";
const string& dstGlobalGenerator = etc_folder + "/global.generator.yml";
Expand Down
Loading