Skip to content

Commit

Permalink
Issue Open-CMSIS-Pack#676: Custom RTE directory computation replaces …
Browse files Browse the repository at this point in the history
…whitespaces
  • Loading branch information
grasci-arm authored Feb 2, 2023
1 parent 9ffa18a commit a705a82
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
8 changes: 2 additions & 6 deletions libs/rtemodel/src/RteFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,20 +200,16 @@ string RteFile::GetInstancePathName(const string& deviceName, int instanceIndex,
bool bForcedCopy = IsForcedCopy();
if (bConfig || bTemplate || bForcedCopy) {
if (bConfig || bForcedCopy) {
pathName = rteFolder + "/";
const string& className = c->GetCclassName();
pathName += className;
pathName += "/";
// replace all ' ' with '_' in class name, the generated path should not contain spaces
pathName += rteFolder + "/" + RteUtils::SpacesToUnderscore(c->GetCclassName()) + "/";
if (!bForcedCopy && !deviceName.empty() && c->IsDeviceDependent()) {
string device = WildCards::ToX(deviceName);
if (!device.empty()) {
pathName += device;
pathName += "/";
}
}
pathName = RteUtils::SpacesToUnderscore(pathName); // replace all ' ' with '_', the generated path should not contian spaces
}

string fullName = GetIncludeFileName(); // valid for all file categories
string fileName = RteUtils::ExtractFileName(fullName);
// add file path in case of relative header
Expand Down
13 changes: 13 additions & 0 deletions libs/rtemodel/test/src/RteModelTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,19 @@ TEST_F(RteModelPrjTest, LoadCprj_NoRTEFileCreation) {
EXPECT_FALSE(RteFsUtils::Exists(deviceDir + "ARMCM3_ac6.sct.update@1.2.0"));
EXPECT_FALSE(RteFsUtils::Exists(deviceDir + "startup_ARMCM3.c.base@2.0.3"));
EXPECT_FALSE(RteFsUtils::Exists(deviceDir + "system_ARMCM3.c.update@1.2.2"));

// additionally test support for RTE folder with spaces
auto& fileInstances= loadedCprjProject->GetFileInstances();
// take existing file instance
auto it = fileInstances.find("RTE/Device/RteTest_ARMCM3/startup_ARMCM3.c");
RteFileInstance* fi = it != fileInstances.end() ? it->second : nullptr;
ASSERT_NE(fi, nullptr);
// use its file to create path with another RTE directory
RteFile* f = fi->GetFile(loadedCprjProject->GetActiveTargetName());
ASSERT_NE(f, nullptr);
const string& deviceName = loadedCprjProject->GetActiveTarget()->GetDeviceName();
string pathName = f->GetInstancePathName(deviceName, 0 , "RTE With Spaces");
EXPECT_EQ(pathName, "RTE With Spaces/Device/RteTest_ARMCM3/startup_ARMCM3.c");
}

TEST_F(RteModelPrjTest, LoadCprj_PackPath) {
Expand Down

0 comments on commit a705a82

Please sign in to comment.