From 6dcf591b325e3ed142d97cd9501b37197579910e Mon Sep 17 00:00:00 2001 From: slhultgren Date: Tue, 18 Jan 2022 15:09:31 +0100 Subject: [PATCH] Allow the "RTE" folder name to be configurable (#65) Adds optional rtedir attribute to /cprj/target/output element Modified RteTestM3 project to use rtedir="CONFIG_FOLDER". Renamed RTE to CONFIG_FOLDER in the test structure to reflect this Contributed by STMicroelectronics Signed-off-by: Samuel HULTGREN --- libs/rtemodel/include/CprjFile.h | 2 ++ libs/rtemodel/include/RteFile.h | 3 +- libs/rtemodel/include/RteInstance.h | 12 ++++--- libs/rtemodel/include/RteProject.h | 12 +++++-- libs/rtemodel/include/RteTarget.h | 12 ++++--- libs/rtemodel/src/CprjFile.cpp | 14 +++++++++ libs/rtemodel/src/RteCprjProject.cpp | 1 + libs/rtemodel/src/RteFile.cpp | 4 +-- libs/rtemodel/src/RteInstance.cpp | 16 +++++----- libs/rtemodel/src/RteProject.cpp | 31 ++++++++++++------- libs/rtemodel/src/RteTarget.cpp | 18 +++++------ libs/rtemodel/test/src/RteModelTest.cpp | 7 +++-- .../Device/RteTest_ARMCM3/ARMCM3_ac6.sct | 0 .../Device/RteTest_ARMCM3/startup_ARMCM3.c | 0 .../Device/RteTest_ARMCM3/system_ARMCM3.c | 0 .../RteTest/ComponentLevelConfig_0.h | 0 .../RteTest/ComponentLevelConfig_1.h | 0 .../RteTest/Config/ConfigInclude.h | 0 .../RteTest/ConfigInclude.h | 0 .../RteTest/GlobalLevelConfig.h | 0 .../MyDir/RelativeComponentLevelConfig_0.h | 0 .../MyDir/RelativeComponentLevelConfig_1.h | 0 .../RteTest/RelativeComponentLevelConfig_0.h | 0 .../RteTest/RelativeComponentLevelConfig_1.h | 0 .../_RteTestM3/Pre_Include_Global.h | 0 .../Pre_Include__RteTest_ComponentLevel.h | 0 .../_RteTestM3/RTE_Components.h | 0 test/projects/RteTestM3/RteTestM3.cprj | 2 +- tools/buildmgr/cbuild/include/CbuildModel.h | 2 +- tools/buildmgr/cbuild/src/CbuildModel.cpp | 18 +++++------ .../src/CBuildGenTestFixture.cpp | 12 +++---- .../src/CBuildGenTestFixture.h | 4 +-- .../integrationtests/src/CBuildGenTests.cpp | 8 ++--- tools/packchk/include/ValidateSemantic.h | 2 +- tools/packchk/src/ValidateSemantic.cpp | 11 ++++--- 35 files changed, 118 insertions(+), 73 deletions(-) rename test/projects/RteTestM3/{RTE => CONFIG_FOLDER}/Device/RteTest_ARMCM3/ARMCM3_ac6.sct (100%) rename test/projects/RteTestM3/{RTE => CONFIG_FOLDER}/Device/RteTest_ARMCM3/startup_ARMCM3.c (100%) rename test/projects/RteTestM3/{RTE => CONFIG_FOLDER}/Device/RteTest_ARMCM3/system_ARMCM3.c (100%) rename test/projects/RteTestM3/{RTE => CONFIG_FOLDER}/RteTest/ComponentLevelConfig_0.h (100%) rename test/projects/RteTestM3/{RTE => CONFIG_FOLDER}/RteTest/ComponentLevelConfig_1.h (100%) rename test/projects/RteTestM3/{RTE => CONFIG_FOLDER}/RteTest/Config/ConfigInclude.h (100%) rename test/projects/RteTestM3/{RTE => CONFIG_FOLDER}/RteTest/ConfigInclude.h (100%) rename test/projects/RteTestM3/{RTE => CONFIG_FOLDER}/RteTest/GlobalLevelConfig.h (100%) rename test/projects/RteTestM3/{RTE => CONFIG_FOLDER}/RteTest/MyDir/RelativeComponentLevelConfig_0.h (100%) rename test/projects/RteTestM3/{RTE => CONFIG_FOLDER}/RteTest/MyDir/RelativeComponentLevelConfig_1.h (100%) rename test/projects/RteTestM3/{RTE => CONFIG_FOLDER}/RteTest/RelativeComponentLevelConfig_0.h (100%) rename test/projects/RteTestM3/{RTE => CONFIG_FOLDER}/RteTest/RelativeComponentLevelConfig_1.h (100%) rename test/projects/RteTestM3/{RTE => CONFIG_FOLDER}/_RteTestM3/Pre_Include_Global.h (100%) rename test/projects/RteTestM3/{RTE => CONFIG_FOLDER}/_RteTestM3/Pre_Include__RteTest_ComponentLevel.h (100%) rename test/projects/RteTestM3/{RTE => CONFIG_FOLDER}/_RteTestM3/RTE_Components.h (100%) diff --git a/libs/rtemodel/include/CprjFile.h b/libs/rtemodel/include/CprjFile.h index 7ea9f9e14..cbc112ce1 100644 --- a/libs/rtemodel/include/CprjFile.h +++ b/libs/rtemodel/include/CprjFile.h @@ -13,6 +13,7 @@ * SPDX-License-Identifier: Apache-2.0 */ /******************************************************************************/ +#include #include "RteGenerator.h" #include "RtePackage.h" @@ -319,6 +320,7 @@ class CprjFile : public RtePackage */ RteItem* GetProjectInfo() const; + const std::optional GetRteFolder() const; /** * @brief getter for list of components specified for the project * @return list of RteItem pointer diff --git a/libs/rtemodel/include/RteFile.h b/libs/rtemodel/include/RteFile.h index 94bd41dc3..b0768f761 100644 --- a/libs/rtemodel/include/RteFile.h +++ b/libs/rtemodel/include/RteFile.h @@ -149,9 +149,10 @@ class RteFile : public RteItem * @param instanceIndex file index for components with multiple instantiation. * Gets appended as a string to the base filename before extension it its value >=0. * Value of < 0 indicates that parent component can have only one instance + * @param rteFolder the "RTE" folder path used for placing files * @return full project-relative path including filename and extension */ - std::string GetInstancePathName(const std::string& deviceName, int instanceIndex) const; + std::string GetInstancePathName(const std::string& deviceName, int instanceIndex, const std::string& rteFolder) const; /** * @brief construct absolute include path string that can be used in'-I' compiler option. diff --git a/libs/rtemodel/include/RteInstance.h b/libs/rtemodel/include/RteInstance.h index 975609db9..c88d197a5 100644 --- a/libs/rtemodel/include/RteInstance.h +++ b/libs/rtemodel/include/RteInstance.h @@ -1368,8 +1368,9 @@ class RteFileInstance : public RteItemInstance * @param f pointer to the original RteFile * @param deviceName device name used in the target * @param instanceIndex instance index, can be > 0 for multi-instance components + * @param rteFolder the "RTE" folder path used for placing files */ - void Init(RteFile* f, const std::string& deviceName, int instanceIndex); + void Init(RteFile* f, const std::string& deviceName, int instanceIndex, const std::string& rteFolder); /** * @brief update file instance @@ -1387,15 +1388,17 @@ class RteFileInstance : public RteItemInstance /** * @brief check if a new version of a config file is available (for specified target) * @param targetName target name + * @param rteFolder the "RTE" folder path used for placing files * @return true if newer version of config file is available */ - int HasNewVersion(const std::string& targetName) const; + int HasNewVersion(const std::string& targetName, const std::string& rteFolder) const; /** * @brief check if a new version of a config file is available (for any target) + * @param rteFolder the "RTE" folder path used for placing files * @return true if newer version of config file is available */ - int HasNewVersion() const; + int HasNewVersion(const std::string& rteFolder) const; /** * @brief get file category @@ -1472,9 +1475,10 @@ class RteFileInstance : public RteItemInstance /** * @brief get the original file resolved to this instance for specified target * @param targetName target name to resolve file + * @param rteFolder the "RTE" folder path used for placing files * @return pointer to RteFile if resolved, nullptr otherwise */ - RteFile* GetFile(const std::string& targetName) const; + RteFile* GetFile(const std::string& targetName, const std::string& rteFolder) const; /** * @brief copy a config file from pack location to the designated project directory diff --git a/libs/rtemodel/include/RteProject.h b/libs/rtemodel/include/RteProject.h index ca7324297..2bb54fcbd 100644 --- a/libs/rtemodel/include/RteProject.h +++ b/libs/rtemodel/include/RteProject.h @@ -18,6 +18,7 @@ #include "RteInstance.h" #include "RteModel.h" +#include #include class RteModel; @@ -149,6 +150,10 @@ class RteProject : public RteItem */ void SetName(const std::string& name) { m_ID = name; } + + void SetRteFolder(std::optional rteFolder) { m_rteFolder = rteFolder; } + const std::string& GetRteFolder() const; + /** * @brief get RteCallback object * @return RteCallback pointer @@ -685,18 +690,20 @@ class RteProject : public RteItem * @brief get file name and path of "RTE_Components.h" determined by the specified target and prefix * @param targetName given target name * @param prefix given prefix to be added at beginning of the file path + * @param rteFolder the "RTE" folder path used for placing files * @return string containing file name and path */ - static std::string GetRteComponentsH(const std::string& targetName, const std::string& prefix); + static std::string GetRteComponentsH(const std::string& targetName, const std::string& prefix, const std::string& rteFolder); /** * @brief get file name and path locating in folder "RTE" determined by the specified name, target and prefix * @param name given file name * @param targetName given target name * @param prefix given prefix to be added at beginning of the file path + * @param rteFolder the "RTE" folder path used for placing files * @return string containing file name and path */ - static std::string GetRteHeader(const std::string& name, const std::string & targetName, const std::string& prefix); + static std::string GetRteHeader(const std::string& name, const std::string & targetName, const std::string& prefix, const std::string& rteFolder); protected: virtual RteTarget* CreateTarget(RteModel* filteredModel, const std::string& name, const std::map& attributes); @@ -760,6 +767,7 @@ class RteProject : public RteItem std::map m_targetModels; // filtered models for each target std::map m_targetIDs; std::string m_sActiveTarget; + std::optional m_rteFolder; }; #endif // RteProject_H diff --git a/libs/rtemodel/include/RteTarget.h b/libs/rtemodel/include/RteTarget.h index 13ee2f3ee..85ae5ae42 100644 --- a/libs/rtemodel/include/RteTarget.h +++ b/libs/rtemodel/include/RteTarget.h @@ -46,15 +46,17 @@ struct RteFileInfo /** * @brief compare file version of the given target and the instance * @param targetName target name + * @param rteFolder the "RTE" folder path used for placing files * @return 0 if both file versions are same, > 0 if file version of the given target is newer, otherwise < 0 */ - int HasNewVersion(const std::string& targetName) const; + int HasNewVersion(const std::string& targetName, const std::string& rteFolder) const; /** * @brief compare file version of this instance with the ones of other targets + * @param rteFolder the "RTE" folder path used for placing files * @return 0 if equal to all others target, > 0 if file version of any other target is newer, otherwise < 0 */ - int HasNewVersion() const; + int HasNewVersion(const std::string& rteFolder) const; RteFile::Category m_cat; //file category RteComponentInstance* m_ci; // pointer to an object of type RteComponentInstance @@ -219,9 +221,10 @@ class RteTarget : public RteItem * @brief determine file given by instances of type RteFileInstance and RteComponent * @param fi given pointer of type RteFileInstance * @param c given pointer of type RteComponent + * @param rteFolder the "RTE" folder path used for placing files * @return pointer of type RteFile */ - RteFile* GetFile(const RteFileInstance* fi, RteComponent* c) const; + RteFile* GetFile(const RteFileInstance* fi, RteComponent* c, const std::string& rteFolder) const; /** * @brief evaluate dependencies of selected components of the target @@ -540,9 +543,10 @@ class RteTarget : public RteItem /** * @brief collect settings of given component instance + * @param rteFolder the "RTE" folder path used for placing files * @param ci pointer to RteComponentInstance object */ - void CollectComponentSettings(RteComponentInstance* ci); + void CollectComponentSettings(RteComponentInstance* ci, const std::string& rteFolder); /** * @brief collect documentation files from component groups diff --git a/libs/rtemodel/src/CprjFile.cpp b/libs/rtemodel/src/CprjFile.cpp index 7a41d190a..d9e7f8c78 100644 --- a/libs/rtemodel/src/CprjFile.cpp +++ b/libs/rtemodel/src/CprjFile.cpp @@ -368,6 +368,20 @@ RteItem* CprjFile::GetProjectInfo() const return GetItemByTag("info"); } +const std::optional CprjFile::GetRteFolder() const +{ + if (m_cprjTargetElement) { + const auto buildOption = m_cprjTargetElement->GetBuildOption(); + if (buildOption) { + const auto folder = buildOption->GetAttribute("rtedir"); + if (!folder.empty()) { + return folder; + } + } + } + return {}; +} + const list& CprjFile::GetProjectComponents() const { return GetGrandChildren("components"); diff --git a/libs/rtemodel/src/RteCprjProject.cpp b/libs/rtemodel/src/RteCprjProject.cpp index 26bca850b..b2ab72d3c 100644 --- a/libs/rtemodel/src/RteCprjProject.cpp +++ b/libs/rtemodel/src/RteCprjProject.cpp @@ -29,6 +29,7 @@ RteCprjProject::RteCprjProject(RteCprjModel* cprjModel) : // set project name based on filename SetName(RteUtils::ExtractFileBaseName(GetCprjFile()->GetPackageFileName())); SetProjectPath(RteUtils::ExtractFilePath(GetCprjFile()->GetPackageFileName(), true)); + SetRteFolder(GetCprjFile()->GetRteFolder()); } RteCprjProject::~RteCprjProject() diff --git a/libs/rtemodel/src/RteFile.cpp b/libs/rtemodel/src/RteFile.cpp index 21e67583f..5fa86d906 100644 --- a/libs/rtemodel/src/RteFile.cpp +++ b/libs/rtemodel/src/RteFile.cpp @@ -190,7 +190,7 @@ void RteFile::GetAbsoluteSourcePaths(set& paths) const } -string RteFile::GetInstancePathName(const string& deviceName, int instanceIndex) const +string RteFile::GetInstancePathName(const string& deviceName, int instanceIndex, const string& rteFolder) const { string pathName; RteComponent* c = GetComponent(); @@ -200,7 +200,7 @@ string RteFile::GetInstancePathName(const string& deviceName, int instanceIndex) bool bForcedCopy = IsForcedCopy(); if (bConfig || bTemplate || bForcedCopy) { if (bConfig || bForcedCopy) { - pathName = "RTE/"; + pathName = rteFolder + "/"; const string& className = c->GetCclassName(); pathName += className; pathName += "/"; diff --git a/libs/rtemodel/src/RteInstance.cpp b/libs/rtemodel/src/RteInstance.cpp index 14bc23ccd..2fa7f0168 100644 --- a/libs/rtemodel/src/RteInstance.cpp +++ b/libs/rtemodel/src/RteInstance.cpp @@ -640,9 +640,9 @@ RteFileInstance::RteFileInstance(RteItem* parent) : m_tag = "file"; } -void RteFileInstance::Init(RteFile* f, const string& deviceName, int instanceIndex) +void RteFileInstance::Init(RteFile* f, const string& deviceName, int instanceIndex, const string& rteFolder) { - m_instanceName = f->GetInstancePathName(deviceName, instanceIndex); + m_instanceName = f->GetInstancePathName(deviceName, instanceIndex, rteFolder); m_instanceIndex = instanceIndex; m_fileName = RteUtils::ExtractFileName(m_instanceName); m_bRemoved = false; @@ -719,20 +719,20 @@ RteFile::Category RteFileInstance::GetCategory() const return RteFile::CategoryFromString(GetAttribute("category")); } -int RteFileInstance::HasNewVersion(const string& targetName) const +int RteFileInstance::HasNewVersion(const string& targetName, const string& rteFolder) const { - RteFile* f = GetFile(targetName); + RteFile* f = GetFile(targetName, rteFolder); if (!f) return 0; int res = VersionCmp::Compare(f->GetVersionString(), GetVersionString()); return res; } -int RteFileInstance::HasNewVersion() const +int RteFileInstance::HasNewVersion(const string& rteFolder) const { int newVersion = 0; for (auto it = m_targetInfos.begin(); it != m_targetInfos.end(); it++) { - int newVer = HasNewVersion(it->first); + int newVer = HasNewVersion(it->first, rteFolder); if (newVer > newVersion) { newVersion = newVer; if (newVersion > 2) @@ -838,12 +838,12 @@ string RteFileInstance::GetAbsolutePath() const return s; } -RteFile* RteFileInstance::GetFile(const string& targetName) const +RteFile* RteFileInstance::GetFile(const string& targetName, const string& rteFolder) const { RteTarget* t = GetTarget(targetName); if (t) { RteComponent* c = GetComponent(targetName); - return t->GetFile(this, c); + return t->GetFile(this, c, rteFolder); } return NULL; } diff --git a/libs/rtemodel/src/RteProject.cpp b/libs/rtemodel/src/RteProject.cpp index b380b467a..4b0dfea8b 100644 --- a/libs/rtemodel/src/RteProject.cpp +++ b/libs/rtemodel/src/RteProject.cpp @@ -15,6 +15,7 @@ #include "RteProject.h" #include "RteComponent.h" +#include "RteFile.h" #include "RteGenerator.h" #include "RteModel.h" #include "CprjFile.h" @@ -24,6 +25,8 @@ using namespace std; +const std::string DEFAULT_RTE_FOLDER = "RTE"; + //////////////////////////// RteProject::RteProject() : RteItem(NULL), @@ -103,6 +106,13 @@ RteProject* RteProject::GetProject() const return const_cast(this); } +const std::string& RteProject::GetRteFolder() const { + if (m_rteFolder.has_value()) { + return m_rteFolder.value(); + } + return DEFAULT_RTE_FOLDER; +} + void RteProject::ClearClasses() { delete m_classes; @@ -398,7 +408,7 @@ RteFileInstance* RteProject::AddFileInstance(RteComponentInstance* ci, RteFile* return NULL; string deviceName = target->GetFullDeviceName(); - string id = f->GetInstancePathName(deviceName, index); + string id = f->GetInstancePathName(deviceName, index, GetRteFolder()); string absPath = GetProjectPath() + id; target->AddComponentInstanceForFile(id, ci); @@ -425,13 +435,12 @@ bool RteProject::UpdateFileToNewVersion(RteFileInstance* fi, RteFile* f, bool bM return UpdateFileInstance(fi, f, bMerge, true); } - void RteProject::InitFileInstance(RteFileInstance* fi, RteFile* f, int index, RteTarget* target, const string& oldVersion, bool bCopy) { string deviceName = target->GetFullDeviceName(); const string& targetName = target->GetName(); - fi->Init(f, deviceName, index); + fi->Init(f, deviceName, index, GetRteFolder()); fi->Update(f, false); fi->AddTargetInfo(targetName); // set/update supported targets fi->SetRemoved(false); @@ -791,7 +800,7 @@ void RteProject::Update() continue; // leave available until missing is resolved // check if component has the file for given target (resolved component can have another set of files, even config ones) - RteFile *f = target->GetFile(fi, c); + RteFile *f = target->GetFile(fi, c, GetRteFolder()); if (f) { continue; } @@ -822,7 +831,7 @@ void RteProject::Update() // add forced copy files for (auto itf = forcedFiles.begin(); itf != forcedFiles.end(); itf++) { RteFile* f = *itf; - string dst = GetProjectPath() + f->GetInstancePathName(EMPTY_STRING, 0); + string dst = GetProjectPath() + f->GetInstancePathName(EMPTY_STRING, 0, GetRteFolder()); error_code ec; if (fs::exists(dst, ec)) @@ -1081,15 +1090,15 @@ void RteProject::CollectSettings() } -string RteProject::GetRteComponentsH(const string & targetName, const string & prefix) +string RteProject::GetRteComponentsH(const string & targetName, const string & prefix, const string& rteFolder) { - return GetRteHeader(string("/RTE_Components.h"), targetName, prefix); + return GetRteHeader(string("/RTE_Components.h"), targetName, prefix, rteFolder); } -string RteProject::GetRteHeader(const string& name, const string & targetName, const string & prefix) +string RteProject::GetRteHeader(const string& name, const string & targetName, const string & prefix, const string& rteFolder) { string rteHeader = prefix; - rteHeader += "RTE/_"; + rteHeader += rteFolder + "/_"; rteHeader += WildCards::ToX(targetName); rteHeader += "/"; rteHeader += name; @@ -1107,7 +1116,7 @@ void RteProject::CollectSettings(const string& targetName) // collect includes, libs and RTE_Components_h defines for active target for (auto itc = m_components.begin(); itc != m_components.end(); itc++) { RteComponentInstance* ci = itc->second; - t->CollectComponentSettings(ci); + t->CollectComponentSettings(ci, GetRteFolder()); } t->CollectClassDocs(); @@ -1155,7 +1164,7 @@ void RteProject::CollectSettings(const string& targetName) // check if RTE components are used before setting RTE_Components.h include path and adding to target as well as setting -D_RTE_ at the command line. // add .\RTE\_TargetName\RTE_Components.h filePath if (GetComponentCount() > 0) { - string rteComponentsH = GetRteComponentsH(targetName, "./"); + string rteComponentsH = GetRteComponentsH(targetName, "./", GetRteFolder()); t->AddIncludePath(RteUtils::ExtractFilePath(rteComponentsH, false)); t->AddFile("RTE_Components.h", RteFile::HEADER, "Component selection"); // add ".\RTE\_TargetName\RTE_Components.h" folder to all target includes t->InsertDefine("_RTE_"); diff --git a/libs/rtemodel/src/RteTarget.cpp b/libs/rtemodel/src/RteTarget.cpp index 241211f10..b31b02d81 100644 --- a/libs/rtemodel/src/RteTarget.cpp +++ b/libs/rtemodel/src/RteTarget.cpp @@ -45,17 +45,17 @@ RteFileInfo::RteFileInfo(RteFile::Category cat, RteComponentInstance* ci, RteFil { }; -int RteFileInfo::HasNewVersion(const string& targetName) const +int RteFileInfo::HasNewVersion(const string& targetName, const string& rteFolder) const { if (m_fi) - return m_fi->HasNewVersion(targetName); + return m_fi->HasNewVersion(targetName, rteFolder); return 0; } -int RteFileInfo::HasNewVersion() const +int RteFileInfo::HasNewVersion(const string& rteFolder) const { if (m_fi) - return m_fi->HasNewVersion(); + return m_fi->HasNewVersion(rteFolder); return 0; } @@ -657,7 +657,7 @@ void RteTarget::AddAlgorithm(RteItem* algo, RteItem* holder) m_algos.insert(pathName); } -void RteTarget::CollectComponentSettings(RteComponentInstance* ci) +void RteTarget::CollectComponentSettings(RteComponentInstance* ci, const std::string& rteFolder) { int count = ci->GetInstanceCount(GetName()); if (count <= 0) @@ -689,7 +689,7 @@ void RteTarget::CollectComponentSettings(RteComponentInstance* ci) continue; if (f->IsConfig()) { for (int i = 0; i < count; i++) { - string id = f->GetInstancePathName(deviceName, i); + string id = f->GetInstancePathName(deviceName, i, rteFolder); AddComponentInstanceForFile(id, ci); } continue; @@ -1263,7 +1263,7 @@ RteFile* RteTarget::FindFile(const string& fileName, RteComponent* c) const } -RteFile* RteTarget::GetFile(const RteFileInstance* fi, RteComponent* c) const +RteFile* RteTarget::GetFile(const RteFileInstance* fi, RteComponent* c, const std::string& rteFolder) const { if (!fi) return NULL; @@ -1273,7 +1273,7 @@ RteFile* RteTarget::GetFile(const RteFileInstance* fi, RteComponent* c) const const string& instanceName = fi->GetInstanceName(); for (auto itf = filteredFiles.begin(); itf != filteredFiles.end(); itf++) { RteFile* f = *itf; - if (f && f->GetInstancePathName(deviceName, index) == instanceName) { + if (f && f->GetInstancePathName(deviceName, index, rteFolder) == instanceName) { return f; } } @@ -1574,7 +1574,7 @@ const bool RteTarget::GenerateRteHeaderFile(const string& headerName, const stri if (!project) return false; - string rteCompH = RteProject::GetRteHeader(headerName, GetName(), project->GetProjectPath()); + string rteCompH = RteProject::GetRteHeader(headerName, GetName(), project->GetProjectPath(), project->GetRteFolder()); if (!RteFsUtils::MakeSureFilePath(rteCompH)) return false; diff --git a/libs/rtemodel/test/src/RteModelTest.cpp b/libs/rtemodel/test/src/RteModelTest.cpp index dda9b5a75..c6a63f1bd 100644 --- a/libs/rtemodel/test/src/RteModelTest.cpp +++ b/libs/rtemodel/test/src/RteModelTest.cpp @@ -53,9 +53,10 @@ const string prjsDir = "RteModelTestProjects"; const string RteTestM3 = "/RteTestM3"; const string RteTestM3_cprj = prjsDir + RteTestM3 + "/RteTestM3.cprj"; -const string preIncComp = prjsDir + RteTestM3 + "/RTE/_RteTestM3/Pre_Include__RteTest_ComponentLevel.h"; -const string preIncGlob = prjsDir + RteTestM3 + "/RTE/_RteTestM3/Pre_Include_Global.h"; -const string rteComp = prjsDir + RteTestM3 + "/RTE/_RteTestM3/RTE_Components.h"; +const string RTE_FOLDER = "CONFIG_FOLDER"; +const string preIncComp = prjsDir + RteTestM3 + "/" + RTE_FOLDER + "/_RteTestM3/Pre_Include__RteTest_ComponentLevel.h"; +const string preIncGlob = prjsDir + RteTestM3 + "/" + RTE_FOLDER + "/_RteTestM3/Pre_Include_Global.h"; +const string rteComp = prjsDir + RteTestM3 + "/" + RTE_FOLDER + "/_RteTestM3/RTE_Components.h"; const string RteTestM4 = "/RteTestM4"; const string RteTestM4_cprj = prjsDir + RteTestM4 + "/RteTestM4.cprj"; diff --git a/test/projects/RteTestM3/RTE/Device/RteTest_ARMCM3/ARMCM3_ac6.sct b/test/projects/RteTestM3/CONFIG_FOLDER/Device/RteTest_ARMCM3/ARMCM3_ac6.sct similarity index 100% rename from test/projects/RteTestM3/RTE/Device/RteTest_ARMCM3/ARMCM3_ac6.sct rename to test/projects/RteTestM3/CONFIG_FOLDER/Device/RteTest_ARMCM3/ARMCM3_ac6.sct diff --git a/test/projects/RteTestM3/RTE/Device/RteTest_ARMCM3/startup_ARMCM3.c b/test/projects/RteTestM3/CONFIG_FOLDER/Device/RteTest_ARMCM3/startup_ARMCM3.c similarity index 100% rename from test/projects/RteTestM3/RTE/Device/RteTest_ARMCM3/startup_ARMCM3.c rename to test/projects/RteTestM3/CONFIG_FOLDER/Device/RteTest_ARMCM3/startup_ARMCM3.c diff --git a/test/projects/RteTestM3/RTE/Device/RteTest_ARMCM3/system_ARMCM3.c b/test/projects/RteTestM3/CONFIG_FOLDER/Device/RteTest_ARMCM3/system_ARMCM3.c similarity index 100% rename from test/projects/RteTestM3/RTE/Device/RteTest_ARMCM3/system_ARMCM3.c rename to test/projects/RteTestM3/CONFIG_FOLDER/Device/RteTest_ARMCM3/system_ARMCM3.c diff --git a/test/projects/RteTestM3/RTE/RteTest/ComponentLevelConfig_0.h b/test/projects/RteTestM3/CONFIG_FOLDER/RteTest/ComponentLevelConfig_0.h similarity index 100% rename from test/projects/RteTestM3/RTE/RteTest/ComponentLevelConfig_0.h rename to test/projects/RteTestM3/CONFIG_FOLDER/RteTest/ComponentLevelConfig_0.h diff --git a/test/projects/RteTestM3/RTE/RteTest/ComponentLevelConfig_1.h b/test/projects/RteTestM3/CONFIG_FOLDER/RteTest/ComponentLevelConfig_1.h similarity index 100% rename from test/projects/RteTestM3/RTE/RteTest/ComponentLevelConfig_1.h rename to test/projects/RteTestM3/CONFIG_FOLDER/RteTest/ComponentLevelConfig_1.h diff --git a/test/projects/RteTestM3/RTE/RteTest/Config/ConfigInclude.h b/test/projects/RteTestM3/CONFIG_FOLDER/RteTest/Config/ConfigInclude.h similarity index 100% rename from test/projects/RteTestM3/RTE/RteTest/Config/ConfigInclude.h rename to test/projects/RteTestM3/CONFIG_FOLDER/RteTest/Config/ConfigInclude.h diff --git a/test/projects/RteTestM3/RTE/RteTest/ConfigInclude.h b/test/projects/RteTestM3/CONFIG_FOLDER/RteTest/ConfigInclude.h similarity index 100% rename from test/projects/RteTestM3/RTE/RteTest/ConfigInclude.h rename to test/projects/RteTestM3/CONFIG_FOLDER/RteTest/ConfigInclude.h diff --git a/test/projects/RteTestM3/RTE/RteTest/GlobalLevelConfig.h b/test/projects/RteTestM3/CONFIG_FOLDER/RteTest/GlobalLevelConfig.h similarity index 100% rename from test/projects/RteTestM3/RTE/RteTest/GlobalLevelConfig.h rename to test/projects/RteTestM3/CONFIG_FOLDER/RteTest/GlobalLevelConfig.h diff --git a/test/projects/RteTestM3/RTE/RteTest/MyDir/RelativeComponentLevelConfig_0.h b/test/projects/RteTestM3/CONFIG_FOLDER/RteTest/MyDir/RelativeComponentLevelConfig_0.h similarity index 100% rename from test/projects/RteTestM3/RTE/RteTest/MyDir/RelativeComponentLevelConfig_0.h rename to test/projects/RteTestM3/CONFIG_FOLDER/RteTest/MyDir/RelativeComponentLevelConfig_0.h diff --git a/test/projects/RteTestM3/RTE/RteTest/MyDir/RelativeComponentLevelConfig_1.h b/test/projects/RteTestM3/CONFIG_FOLDER/RteTest/MyDir/RelativeComponentLevelConfig_1.h similarity index 100% rename from test/projects/RteTestM3/RTE/RteTest/MyDir/RelativeComponentLevelConfig_1.h rename to test/projects/RteTestM3/CONFIG_FOLDER/RteTest/MyDir/RelativeComponentLevelConfig_1.h diff --git a/test/projects/RteTestM3/RTE/RteTest/RelativeComponentLevelConfig_0.h b/test/projects/RteTestM3/CONFIG_FOLDER/RteTest/RelativeComponentLevelConfig_0.h similarity index 100% rename from test/projects/RteTestM3/RTE/RteTest/RelativeComponentLevelConfig_0.h rename to test/projects/RteTestM3/CONFIG_FOLDER/RteTest/RelativeComponentLevelConfig_0.h diff --git a/test/projects/RteTestM3/RTE/RteTest/RelativeComponentLevelConfig_1.h b/test/projects/RteTestM3/CONFIG_FOLDER/RteTest/RelativeComponentLevelConfig_1.h similarity index 100% rename from test/projects/RteTestM3/RTE/RteTest/RelativeComponentLevelConfig_1.h rename to test/projects/RteTestM3/CONFIG_FOLDER/RteTest/RelativeComponentLevelConfig_1.h diff --git a/test/projects/RteTestM3/RTE/_RteTestM3/Pre_Include_Global.h b/test/projects/RteTestM3/CONFIG_FOLDER/_RteTestM3/Pre_Include_Global.h similarity index 100% rename from test/projects/RteTestM3/RTE/_RteTestM3/Pre_Include_Global.h rename to test/projects/RteTestM3/CONFIG_FOLDER/_RteTestM3/Pre_Include_Global.h diff --git a/test/projects/RteTestM3/RTE/_RteTestM3/Pre_Include__RteTest_ComponentLevel.h b/test/projects/RteTestM3/CONFIG_FOLDER/_RteTestM3/Pre_Include__RteTest_ComponentLevel.h similarity index 100% rename from test/projects/RteTestM3/RTE/_RteTestM3/Pre_Include__RteTest_ComponentLevel.h rename to test/projects/RteTestM3/CONFIG_FOLDER/_RteTestM3/Pre_Include__RteTest_ComponentLevel.h diff --git a/test/projects/RteTestM3/RTE/_RteTestM3/RTE_Components.h b/test/projects/RteTestM3/CONFIG_FOLDER/_RteTestM3/RTE_Components.h similarity index 100% rename from test/projects/RteTestM3/RTE/_RteTestM3/RTE_Components.h rename to test/projects/RteTestM3/CONFIG_FOLDER/_RteTestM3/RTE_Components.h diff --git a/test/projects/RteTestM3/RteTestM3.cprj b/test/projects/RteTestM3/RteTestM3.cprj index 922ffba83..de5eb0087 100644 --- a/test/projects/RteTestM3/RteTestM3.cprj +++ b/test/projects/RteTestM3/RteTestM3.cprj @@ -31,7 +31,7 @@ - + diff --git a/tools/buildmgr/cbuild/include/CbuildModel.h b/tools/buildmgr/cbuild/include/CbuildModel.h index 30df41627..778362dc1 100644 --- a/tools/buildmgr/cbuild/include/CbuildModel.h +++ b/tools/buildmgr/cbuild/include/CbuildModel.h @@ -435,7 +435,7 @@ class CbuildModel { const bool GetCompatibleToolchain(const std::string& name, const std::string& versionRange, const std::string& dir, const std::string& ext); std::vector SplitArgs(const std::string& args, const std::string& delim=std::string(" -"), bool relativePath=true); static std::vector MergeArgs(const std::vector& add, const std::vector& remove, const std::vector& reference); - static std::string GetExtendedRteGroupName(RteItem* ci); + static std::string GetExtendedRteGroupName(RteItem* ci, const std::string& rteFolder); }; #endif /* CBUILDMODEL_H */ diff --git a/tools/buildmgr/cbuild/src/CbuildModel.cpp b/tools/buildmgr/cbuild/src/CbuildModel.cpp index ca62fd459..6ffbb2837 100644 --- a/tools/buildmgr/cbuild/src/CbuildModel.cpp +++ b/tools/buildmgr/cbuild/src/CbuildModel.cpp @@ -243,7 +243,7 @@ const bool CbuildModel::GenerateFixedCprj(const string& update) { for (auto configFile : configFiles) { if (configFile.second->GetComponent(m_targetName)->Compare(component)) { - map fileAttributes = configFile.second->GetFile(m_targetName)->GetAttributes(); + map fileAttributes = configFile.second->GetFile(m_targetName, m_cprjProject->GetRteFolder())->GetAttributes(); fileAttributes["name"] = RteUtils::BackSlashesToSlashes(fileAttributes["name"]); // Iterate over component files @@ -311,7 +311,7 @@ const bool CbuildModel::GenerateAuditData() { string instanceName = configFile.second->GetInstanceName(); RteFsUtils::NormalizePath(instanceName, m_prjFolder); auditData << EOL << " - ConfigFile: " << instanceName << ":" << configFile.second->GetVersionString(); - if (configFile.second->HasNewVersion(m_targetName) > 0) auditData << " [" << configFile.second->GetFile(m_targetName)->GetVersionString() << "]"; + if (configFile.second->HasNewVersion(m_targetName) > 0) auditData << " [" << configFile.second->GetFile(m_targetName, m_cprjProject->GetRteFolder())->GetVersionString() << "]"; } } } @@ -456,10 +456,10 @@ const bool CbuildModel::EvalPreIncludeFiles() { for (auto it : preincludeFiles) { RteComponent* ci = it.first; if (ci != NULL) { - string componentName = GetExtendedRteGroupName(ci); + string componentName = GetExtendedRteGroupName(ci, m_cprjProject->GetRteFolder()); m_preIncludeFilesLocal[componentName] = vector(it.second.begin(), it.second.end()); } else { - const string& rteFolder = m_prjFolder + "RTE/_" + WildCards::ToX(m_cprjTarget->GetName()) + "/"; + const string& rteFolder = m_prjFolder + m_cprjProject->GetRteFolder() + "/_" + WildCards::ToX(m_cprjTarget->GetName()) + "/"; for (auto it2 : it.second) { string file = it2; if (!RteFsUtils::NormalizePath(file, rteFolder)) { @@ -498,7 +498,7 @@ const bool CbuildModel::EvalConfigFiles() { for (auto fi : compConfigFiles) { const string& prjFile = RteUtils::BackSlashesToSlashes(fi.second->GetInstanceName().c_str()); const string& absPrjFile = m_cprjProject->GetProjectPath() + prjFile; - const string& pkgFile = RteUtils::BackSlashesToSlashes(fi.second->GetFile(m_targetName)->GetOriginalAbsolutePath()); + const string& pkgFile = RteUtils::BackSlashesToSlashes(fi.second->GetFile(m_targetName, m_cprjProject->GetRteFolder())->GetOriginalAbsolutePath()); error_code ec; if (!fs::exists(absPrjFile, ec)) { // Copy config file from pack if it's missing @@ -935,7 +935,7 @@ const bool CbuildModel::EvalFlags() { const RteItem* components = m_cprjPack->GetItemByTag("components"); if (components) { for (auto ci : components->GetChildren()) { - const string& componentName = GetExtendedRteGroupName(ci); + const string& componentName = GetExtendedRteGroupName(ci, m_cprjProject->GetRteFolder()); SetItemFlags(ci, componentName); } } @@ -1022,7 +1022,7 @@ const bool CbuildModel::EvalRteSourceFiles(map> &cSourceFil return false; } // Use extended RTE group name instead of string obtained by RteAttributes::GetProjectGroupName() implementation("::" + Cclass) - const string& componentName = GetExtendedRteGroupName(m_cprjTarget->GetComponentInstanceForFile(file.first.c_str())); + const string& componentName = GetExtendedRteGroupName(m_cprjTarget->GetComponentInstanceForFile(file.first.c_str()), m_cprjProject->GetRteFolder()); switch (CbuildUtils::GetFileType(cat, file.first)) { case RteFile::Category::SOURCE_C: cSourceFiles[componentName].push_back(filepath); @@ -1046,7 +1046,7 @@ const bool CbuildModel::EvalRteSourceFiles(map> &cSourceFil return true; } -string CbuildModel::GetExtendedRteGroupName(RteItem* ci) { +string CbuildModel::GetExtendedRteGroupName(RteItem* ci, const string& rteFolder) { /* GetExtendedRteGroupName: Returns Cclass + Cgroup + Csub + Cvariant names @@ -1056,7 +1056,7 @@ string CbuildModel::GetExtendedRteGroupName(RteItem* ci) { const string& cGroupName = ci->GetCgroupName(); const string& cSubName = ci->GetCsubName(); const string& cVariantName = ci->GetCvariantName(); - string rteGroupName = "RTE"; + string rteGroupName = rteFolder; if (!cClassName.empty()) rteGroupName += "/" + CbuildUtils::RemoveSlash(cClassName); if (!cGroupName.empty()) rteGroupName += "/" + CbuildUtils::RemoveSlash(cGroupName); if (!cSubName.empty()) rteGroupName += "/" + CbuildUtils::RemoveSlash(cSubName); diff --git a/tools/buildmgr/test/integrationtests/src/CBuildGenTestFixture.cpp b/tools/buildmgr/test/integrationtests/src/CBuildGenTestFixture.cpp index fb403fc65..7679e9189 100644 --- a/tools/buildmgr/test/integrationtests/src/CBuildGenTestFixture.cpp +++ b/tools/buildmgr/test/integrationtests/src/CBuildGenTestFixture.cpp @@ -203,14 +203,14 @@ void CBuildGenTestFixture::GetDirectoryItems(const string& inPath, set & } } -void CBuildGenTestFixture::CheckLayerFiles(const TestParam& param) { +void CBuildGenTestFixture::CheckLayerFiles(const TestParam& param, const string& rteFolder) { string layerDir = testout_folder + "/" + param.name + "/Project/Layer"; string layerRef = testout_folder + "/" + param.name + "/Layer_Ref"; error_code ec; set dir, ref, clayers, clayers_ref; - GetDirectoryItems(layerDir, dir, "RTE"); - GetDirectoryItems(layerRef, ref, "RTE"); + GetDirectoryItems(layerDir, dir, rteFolder); + GetDirectoryItems(layerRef, ref, rteFolder); for (auto& p : fs::recursive_directory_iterator(layerDir, ec)) { if (p.path().extension() == ".clayer") { @@ -235,14 +235,14 @@ void CBuildGenTestFixture::CheckLayerFiles(const TestParam& param) { } } -void CBuildGenTestFixture::CheckProjectFiles(const TestParam& param) { +void CBuildGenTestFixture::CheckProjectFiles(const TestParam& param, const string& rteFolder) { string projectDir = testout_folder + "/" + param.name + "/Project"; string projectRef = testout_folder + "/" + param.name + "/Project_Ref"; error_code ec; set dir, ref; - GetDirectoryItems(projectDir, dir, "RTE"); - GetDirectoryItems(projectRef, ref, "RTE"); + GetDirectoryItems(projectDir, dir, rteFolder); + GetDirectoryItems(projectRef, ref, rteFolder); ASSERT_EQ(dir == ref, true) << "Project directory '" << projectDir << "' filetree is different from '" << projectRef << "' reference"; diff --git a/tools/buildmgr/test/integrationtests/src/CBuildGenTestFixture.h b/tools/buildmgr/test/integrationtests/src/CBuildGenTestFixture.h index c3d22d4ec..0cd4f6812 100644 --- a/tools/buildmgr/test/integrationtests/src/CBuildGenTestFixture.h +++ b/tools/buildmgr/test/integrationtests/src/CBuildGenTestFixture.h @@ -13,8 +13,8 @@ class CBuildGenTestFixture : public ::testing::Test { void RunCBuildGenAux (const std::string& cmd, bool expect); void CheckCMakeLists (const TestParam& param); void CheckDescriptionFiles (const std::string& filename1, const std::string& filename2); - void CheckLayerFiles (const TestParam& param); - void CheckProjectFiles (const TestParam& param); + void CheckLayerFiles (const TestParam& param, const std::string& rteFolder); + void CheckProjectFiles (const TestParam& param, const std::string& rteFolder); void CheckOutputDir (const TestParam& param, const std::string& outdir); void CheckCMakeIntermediateDir (const TestParam& param, const std::string& intdir); void CheckCPInstallFile (const TestParam& param); diff --git a/tools/buildmgr/test/integrationtests/src/CBuildGenTests.cpp b/tools/buildmgr/test/integrationtests/src/CBuildGenTests.cpp index d317ea690..45ffc4d62 100644 --- a/tools/buildmgr/test/integrationtests/src/CBuildGenTests.cpp +++ b/tools/buildmgr/test/integrationtests/src/CBuildGenTests.cpp @@ -258,7 +258,7 @@ TEST_F(CBuildGenTests, Layer_Extract) { TestParam param = { "Layers/Layers_Extract", "Simulation" }; RunLayerCommand (1/*L_EXTRACT*/, param); - CheckLayerFiles (param); + CheckLayerFiles (param, "RTE"); } // Validate creation of new projects from layers @@ -266,7 +266,7 @@ TEST_F(CBuildGenTests, Layer_Compose) { TestParam param = { "Layers/Layers_Compose", "Simulation" }; RunLayerCommand (2/*L_COMPOSE*/, param); - CheckProjectFiles (param); + CheckProjectFiles (param, "RTE"); } // Validate addition of new layers to the project @@ -274,7 +274,7 @@ TEST_F(CBuildGenTests, Layer_Add) { TestParam param = { "Layers/Layers_Add", "Simulation" }; RunLayerCommand (3/*L_ADD*/, param); - CheckProjectFiles (param); + CheckProjectFiles (param, "RTE"); } // Validate removal of layers from project @@ -282,7 +282,7 @@ TEST_F(CBuildGenTests, Layer_Remove) { TestParam param = { "Layers/Layers_Remove", "Simulation" }; RunLayerCommand (4/*L_REMOVE*/, param); - CheckProjectFiles (param); + CheckProjectFiles (param, "RTE"); } // Test creation of new directory(s) diff --git a/tools/packchk/include/ValidateSemantic.h b/tools/packchk/include/ValidateSemantic.h index 81c40a991..0706cca5c 100644 --- a/tools/packchk/include/ValidateSemantic.h +++ b/tools/packchk/include/ValidateSemantic.h @@ -38,7 +38,7 @@ class ValidateSemantic : public Validate bool FindName(const std::string& name, const std::string& searchName, const std::string& searchExt); bool UpdateRte(RteTarget* target, RteProject* rteProject, RteComponent* component); bool CheckDependencyResult(RteTarget* target, RteComponent* component, std::string mcuVendor, std::string mcuDispName, compiler_s compiler); - bool ExcludeSysHeaderDirectories(const std::string& systemHeader); + bool ExcludeSysHeaderDirectories(const std::string& systemHeader, const std::string& rteFolder); bool FindFileFromList(const std::string& systemHeader, const std::set& targFiles); bool CheckDeviceDependencies(RteDeviceItem* device, RteProject* rteProject); diff --git a/tools/packchk/src/ValidateSemantic.cpp b/tools/packchk/src/ValidateSemantic.cpp index 5d83b6b98..b426ceda3 100644 --- a/tools/packchk/src/ValidateSemantic.cpp +++ b/tools/packchk/src/ValidateSemantic.cpp @@ -409,20 +409,21 @@ bool ValidateSemantic::CheckDependencyResult(RteTarget* target, RteComponent* co /** * @brief skip directories * @param systemHeader string name to test + * @param rteFolder the "RTE" folder path used for placing files * @return true / false */ -bool ValidateSemantic::ExcludeSysHeaderDirectories(const string& systemHeader) +bool ValidateSemantic::ExcludeSysHeaderDirectories(const string& systemHeader, const string& rteFolder) { if(systemHeader.empty()) { return true; } - if(systemHeader == "RTE") { + if(systemHeader == rteFolder) { return true; } - if(systemHeader == "./RTE") { + if(systemHeader == "./" + rteFolder) { return true; } - if(systemHeader == "./RTE/_Test") { + if(systemHeader == "./" + rteFolder + "/_Test") { return true; } @@ -566,7 +567,7 @@ bool ValidateSemantic::CheckDeviceDependencies(RteDeviceItem *device, RteProject int incPathsCnt = 0; for(auto& incPath : incPaths) { systemHeader = RteUtils::BackSlashesToSlashes(incPath); - if(ExcludeSysHeaderDirectories(systemHeader)) { + if(ExcludeSysHeaderDirectories(systemHeader, rteProject->GetRteFolder())) { continue; }