Skip to content

Commit 257cb36

Browse files
grasci-armedriouk
andauthored
Ensure packs with explicit paths have priority over installed (#2288)
Co-authored-by: Evgueni Driouk <[email protected]>
1 parent 2c6f0d5 commit 257cb36

File tree

2 files changed

+171
-160
lines changed

2 files changed

+171
-160
lines changed

libs/rtemodel/src/RteKernel.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ bool RteKernel::SetCmsisPackRoot(const string& cmsisPackRoot)
8181
return false;
8282
m_cmsisPackRoot = cmsisPackRoot;
8383
RteFsUtils::NormalizePath(m_cmsisPackRoot);
84+
if(m_globalModel) {
85+
m_globalModel->SetRtePath(cmsisPackRoot);
86+
}
8487
return true;
8588
}
8689

@@ -466,11 +469,14 @@ bool RteKernel::LoadAndInsertPacks(std::list<RtePackage*>& packs, std::list<std:
466469
std::list<RtePackage*> newPacks;
467470
pdscFiles.unique();
468471
for (const auto& pdscFile : pdscFiles) {
469-
RtePackage* pack = LoadPack(pdscFile);
472+
PackageState state = pdscFile.find(GetCmsisPackRoot()) == 0 ? PS_INSTALLED : PS_EXPLICIT_PATH;
473+
RtePackage* pack = LoadPack(pdscFile, state);
470474
if (!pack) {
471475
return false;
472476
}
473-
if(!RtePackage::GetPackFromList(pack->GetID(), packs)){
477+
// pack with explicit path must override installed pack
478+
auto loadedPack = RtePackage::GetPackFromList(pack->GetID(), packs);
479+
if(!loadedPack || (loadedPack->GetPackageState() == PS_INSTALLED && pack->GetPackageState() == PS_EXPLICIT_PATH)) {
474480
newPacks.push_back(pack);
475481
}
476482
}

0 commit comments

Comments
 (0)