Skip to content

Commit

Permalink
[rtemodel, projmgr] Recreate constructed files unconditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
spcaipers-arm authored Feb 18, 2025
1 parent d55a79e commit b5277bf
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 29 deletions.
5 changes: 1 addition & 4 deletions libs/rtemodel/src/RteProject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
/******************************************************************************/
/*
* 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 Down Expand Up @@ -1090,9 +1090,6 @@ void RteProject::UpdateRte() {
}

void RteProject::GenerateRteHeaders() {
if (!ShouldUpdateRte())
return;

// generate header files for all targets
for (auto itt : m_targets) {
RteTarget* target = itt.second;
Expand Down
17 changes: 9 additions & 8 deletions libs/rtemodel/src/RteTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
/******************************************************************************/
/*
* 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 Down Expand Up @@ -1991,12 +1991,11 @@ bool RteTarget::GenerateRteHeaderFile(const string& headerName, const string& co
}
// construct head comment
ostringstream oss;
RteCallback* callback = GetCallback();
if (!callback) {
return false;
}
if (!bRegionsHeader) {
RteCallback* callback = GetCallback();
if (!callback) {
return false;
}

bool foundToolInfo = false;
auto kernel = callback->GetRteKernel();
if (kernel) {
Expand Down Expand Up @@ -2050,8 +2049,10 @@ bool RteTarget::GenerateRteHeaderFile(const string& headerName, const string& co
}

// file does not exist or its content is different
RteFsUtils::CopyBufferToFile(headerFile, oss.str(), false); // write file

if (RteFsUtils::CopyBufferToFile(headerFile, oss.str(), false) // write file
&& !GetProject()->ShouldUpdateRte() && !bRegionsHeader) {
callback->OutputMessage("Constructed file " + headerFile + " was recreated");
}
return true;
}
// End of RteTarget.cpp
9 changes: 7 additions & 2 deletions tools/projmgr/include/ProjMgrWorker.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 Down Expand Up @@ -782,6 +782,12 @@ class ProjMgrWorker {
*/
void CollectUnusedPacks();

/**
* @brief check rte errors
* @return true if there is no error
*/
bool CheckRteErrors(void);

protected:
ProjMgrParser* m_parser = nullptr;
ProjMgrKernel* m_kernel = nullptr;
Expand Down Expand Up @@ -824,7 +830,6 @@ class ProjMgrWorker {
bool LoadPacks(ContextItem& context);
bool CheckMissingPackRequirements(const std::string& contextName);
bool CollectRequiredPdscFiles(ContextItem& context, const std::string& packRoot);
bool CheckRteErrors(void);
bool CheckBoardDeviceInLayer(const ContextItem& context, const ClayerItem& clayer);
bool CheckCompiler(const std::vector<std::string>& forCompiler, const std::string& selectedCompiler);
bool CheckType(const TypeFilter& typeFilter, const std::vector<TypePair>& typeVec);
Expand Down
12 changes: 8 additions & 4 deletions tools/projmgr/src/ProjMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,15 +655,19 @@ bool ProjMgr::Configure() {

bool ProjMgr::UpdateRte() {
// Update the RTE files
if (m_updateRteFiles) {
for (auto& contextItem : m_processedContexts) {
if (contextItem->rteActiveProject != nullptr) {
for (auto& contextItem : m_processedContexts) {
if (contextItem->rteActiveProject != nullptr) {
if (m_updateRteFiles) {
contextItem->rteActiveProject->SetAttribute("update-rte-files", "1");
contextItem->rteActiveProject->UpdateRte();
} else {
contextItem->rteActiveProject->GenerateRteHeaders();
}
}
}
bool result = true;

bool result = m_worker.CheckRteErrors();

for (auto& contextItem : m_processedContexts) {
// Check PLM files
if (!m_worker.CheckConfigPLMFiles(*contextItem)) {
Expand Down
4 changes: 2 additions & 2 deletions tools/projmgr/test/src/ProjMgrGeneratorUnitTests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021 Arm Limited. All rights reserved.
* Copyright (c) 2020-2025 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -200,7 +200,7 @@ TEST_F(ProjMgrGeneratorUnitTests, DryRun) {
ProjMgrTestEnv::CompareFile(testinput_folder + "/TestSolution/ref/TestProject3_1.Debug+TypeA.cbuild-gen.yml", generatorInputFile, stripAbsoluteFunc);

EXPECT_EQ(true, std::filesystem::exists(generatorInputFile));
EXPECT_EQ(false, std::filesystem::exists(rteDir));
EXPECT_EQ(false, std::filesystem::exists(rteDir + "/Device"));
EXPECT_EQ(false, std::filesystem::exists(targetGPDSC));
EXPECT_EQ(false, std::filesystem::exists(generatorDestination));

Expand Down
21 changes: 12 additions & 9 deletions tools/projmgr/test/src/ProjMgrUnitTests.cpp
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 Down Expand Up @@ -1057,21 +1057,21 @@ TEST_F(ProjMgrUnitTests, RunProjMgrSolution_LockPackFrozen) {
EXPECT_NE(0, RunProjMgr(8, argv, m_envp));
EXPECT_NE(streamRedirect.GetErrorString().find(cbuildPack + " - error csolution: file not allowed to be updated"), string::npos);
ProjMgrTestEnv::CompareFile(expectedCbuildPack, cbuildPack);
EXPECT_FALSE(RteFsUtils::Exists(rtePath));
EXPECT_FALSE(RteFsUtils::Exists(rtePath + "/Device"));

// 2nd run to verify that the cbuild-pack.yml content is stable
streamRedirect.ClearStringStreams();
EXPECT_NE(0, RunProjMgr(8, argv, m_envp));
EXPECT_NE(streamRedirect.GetErrorString().find(cbuildPack + " - error csolution: file not allowed to be updated"), string::npos);
ProjMgrTestEnv::CompareFile(expectedCbuildPack, cbuildPack);
EXPECT_FALSE(RteFsUtils::Exists(rtePath));
EXPECT_FALSE(RteFsUtils::Exists(rtePath + "/Device"));

// 3rd run without --frozen-packs to verify that the list can be updated
streamRedirect.ClearStringStreams();
EXPECT_EQ(0, RunProjMgr(7, argv, m_envp));
EXPECT_NE(streamRedirect.GetOutString().find(cbuildPack + " - info csolution: file generated successfully"), string::npos);
ProjMgrTestEnv::CompareFile(expectedCbuildPackRef, cbuildPack);
EXPECT_TRUE(RteFsUtils::Exists(rtePath));
EXPECT_TRUE(RteFsUtils::Exists(rtePath + "/Device"));

EXPECT_TRUE(RteFsUtils::Exists(testinput_folder + "/TestSolution/PackLocking/RTE/_CM3/RTE_Components.h"));
EXPECT_TRUE(RteFsUtils::Exists(testinput_folder + "/TestSolution/PackLocking/RTE/Device/RteTest_ARMCM3/gcc_arm.ld"));
Expand Down Expand Up @@ -3812,9 +3812,9 @@ TEST_F(ProjMgrUnitTests, RunProjMgr_NoUpdateRTEFiles) {
char* argv[8];
const string csolutionFile = UpdateTestSolutionFile("./TestProject4/test.cproject.yml");
const string rteFolder = RteFsUtils::ParentPath(csolutionFile) + "/TestProject4/RTE";
set<string> rteFilesBefore, rteFilesAfter;
set<string> rteFiles;
RteFsUtils::RemoveDir(rteFolder);
GetFilesInTree(rteFolder, rteFilesBefore);
StdStreamRedirect streamRedirect;

argv[1] = (char*)"convert";
argv[2] = (char*)"--solution";
Expand All @@ -3825,9 +3825,12 @@ TEST_F(ProjMgrUnitTests, RunProjMgr_NoUpdateRTEFiles) {
argv[7] = (char*)"--cbuildgen";
EXPECT_EQ(1, RunProjMgr(8, argv, m_envp));

// The RTE folder should be left untouched
GetFilesInTree(rteFolder, rteFilesAfter);
EXPECT_EQ(rteFilesBefore, rteFilesAfter);
EXPECT_NE(streamRedirect.GetErrorString().find("RTE/_TEST_TARGET/RTE_Components.h was recreated"), string::npos);

// Only constructed files are created in the RTE folder
GetFilesInTree(rteFolder, rteFiles);
const set<string> expected = { "RTE_Components.h", "_TEST_TARGET" };
EXPECT_EQ(expected, rteFiles);

// CPRJ should still be generated
ProjMgrTestEnv:: CompareFile(testoutput_folder + "/test+TEST_TARGET.cprj",
Expand Down

0 comments on commit b5277bf

Please sign in to comment.