|
6 | 6 | */ |
7 | 7 | /******************************************************************************/ |
8 | 8 | /* |
9 | | - * Copyright (c) 2020-2021 Arm Limited. All rights reserved. |
| 9 | + * Copyright (c) 2020-2025 Arm Limited. All rights reserved. |
10 | 10 | * |
11 | 11 | * SPDX-License-Identifier: Apache-2.0 |
12 | 12 | */ |
@@ -80,6 +80,7 @@ bool RteKernel::SetCmsisPackRoot(const string& cmsisPackRoot) |
80 | 80 | if (m_cmsisPackRoot == cmsisPackRoot) |
81 | 81 | return false; |
82 | 82 | m_cmsisPackRoot = cmsisPackRoot; |
| 83 | + RteFsUtils::NormalizePath(m_cmsisPackRoot); |
83 | 84 | return true; |
84 | 85 | } |
85 | 86 |
|
@@ -413,12 +414,19 @@ bool RteKernel::GetEffectivePdscFilesAsMap(map<string, string, RtePackageCompara |
413 | 414 | if(cmsisPackRoot.empty()) { |
414 | 415 | return false; |
415 | 416 | } |
416 | | - // Get all installed files |
417 | | - RteKernel::GetInstalledPdscFiles(pdscMap); |
418 | 417 |
|
419 | | - // Overwrite entries with local pdsc files if any |
420 | | - XmlItem emptyAttributes; |
421 | | - GetLocalPdscFiles(emptyAttributes, pdscMap); |
| 418 | + // Get pdsc map |
| 419 | + RtePackRegistry* packRegistry = GetPackRegistry(); |
| 420 | + pdscMap = packRegistry->GetPdscMap(); |
| 421 | + if (pdscMap.empty()) { |
| 422 | + // Get all installed files |
| 423 | + GetInstalledPdscFiles(pdscMap); |
| 424 | + // Overwrite entries with local pdsc files if any |
| 425 | + XmlItem emptyAttributes; |
| 426 | + GetLocalPdscFiles(emptyAttributes, pdscMap); |
| 427 | + // Store pdsc map |
| 428 | + packRegistry->SetPdscMap(pdscMap); |
| 429 | + } |
422 | 430 |
|
423 | 431 | // purge entries if only latest are required |
424 | 432 | if(latest) { |
@@ -482,51 +490,54 @@ void RteKernel::GetInstalledPdscFiles(std::map<std::string, std::string, RtePack |
482 | 490 | { |
483 | 491 | list<string> allFiles; |
484 | 492 | RteFsUtils::GetPackageDescriptionFiles(allFiles, GetCmsisPackRoot(), 3); |
485 | | - for(auto& f : allFiles) { |
486 | | - string id = RtePackage::PackIdFromPath(f); |
| 493 | + for (auto& f : allFiles) { |
| 494 | + string id = RteUtils::ToLower(RtePackage::PackIdFromPath(f)); |
487 | 495 | pdscMap[id] = f; |
488 | 496 | } |
489 | 497 | } |
490 | 498 |
|
491 | | -pair<string, string> RteKernel::GetInstalledPdscFile(const XmlItem& attributes) const |
| 499 | +pair<string, string> RteKernel::GetEffectivePdscFile(const XmlItem& attributes) const |
492 | 500 | { |
493 | 501 | const string& name = attributes.GetAttribute("name"); |
494 | 502 | const string& vendor = attributes.GetAttribute("vendor"); |
495 | | - if(!name.empty() && !vendor.empty()) { |
496 | | - string path = GetCmsisPackRoot() + '/' + vendor + '/' + name; |
497 | | - const string& versionRange = attributes.GetAttribute("version"); |
498 | | - string installedVersion = RteFsUtils::GetInstalledPackVersion(path, versionRange); |
499 | | - if(!installedVersion.empty()) { |
500 | | - string packId = RtePackage::ComposePackageID(vendor, name, installedVersion); |
501 | | - path += '/' + installedVersion + '/' + vendor + '.' + name + ".pdsc"; |
502 | | - return make_pair(packId, path); |
| 503 | + if (!name.empty() && !vendor.empty()) { |
| 504 | + const string& packId = RteUtils::ToLower(vendor + RteConstants::SUFFIX_PACK_VENDOR + name); |
| 505 | + // get map of effective pdscs with lower-case ids |
| 506 | + map<string, string, RtePackageComparator> pdscMap; |
| 507 | + GetEffectivePdscFilesAsMap(pdscMap, false); |
| 508 | + StrPairVec pdscs; |
| 509 | + // get subset of pdscs for the searched packId |
| 510 | + for (const auto& pdsc : pdscMap) { |
| 511 | + if (RtePackage::CommonIdFromId(pdsc.first) == packId) { |
| 512 | + pdscs.push_back(pdsc); |
| 513 | + } |
| 514 | + } |
| 515 | + if (!pdscs.empty()) { |
| 516 | + const string& versionRange = attributes.GetAttribute("version"); |
| 517 | + StrPair effectivePdsc; |
| 518 | + if (versionRange.empty()) { |
| 519 | + // required version range is empty = get greatest effective version |
| 520 | + effectivePdsc = *pdscs.begin(); |
| 521 | + } else { |
| 522 | + for (const auto& pdsc : pdscs) { |
| 523 | + // find the greatest effective version in the required version range |
| 524 | + if (VersionCmp::RangeCompare(RtePackage::VersionFromId(pdsc.first), versionRange) == 0) { |
| 525 | + effectivePdsc = pdsc; |
| 526 | + break; |
| 527 | + } |
| 528 | + } |
| 529 | + } |
| 530 | + auto& id = effectivePdsc.first; |
| 531 | + if (!id.empty()) { |
| 532 | + // preserve name::vendor as given in input attributes |
| 533 | + id = RtePackage::ComposePackageID(vendor, name, RtePackage::VersionFromId(id)); |
| 534 | + return effectivePdsc; |
| 535 | + } |
503 | 536 | } |
504 | 537 | } |
505 | 538 | return make_pair(RteUtils::EMPTY_STRING, RteUtils::EMPTY_STRING); |
506 | 539 | } |
507 | 540 |
|
508 | | -pair<string, string> RteKernel::GetLocalPdscFile(const XmlItem& attributes) const |
509 | | -{ |
510 | | - map<string, string, RtePackageComparator> pdscMap; |
511 | | - if(!attributes.IsEmpty() && GetLocalPdscFiles(attributes, pdscMap)) { |
512 | | - return *pdscMap.begin(); |
513 | | - } |
514 | | - return make_pair(RteUtils::EMPTY_STRING, RteUtils::EMPTY_STRING); |
515 | | -} |
516 | | - |
517 | | -pair<string, string> RteKernel::GetEffectivePdscFile(const XmlItem& attributes) const |
518 | | -{ |
519 | | - auto localPdsc = GetLocalPdscFile(attributes); |
520 | | - auto installedPdsc = GetInstalledPdscFile(attributes); |
521 | | - |
522 | | - string localVersion = RtePackage::VersionFromId(localPdsc.first); |
523 | | - string installedVersion = RtePackage::VersionFromId(installedPdsc.first); |
524 | | - if(!localVersion.empty() && VersionCmp::Compare(localVersion, installedVersion) >= 0) { |
525 | | - return localPdsc; |
526 | | - } |
527 | | - return installedPdsc; |
528 | | -} |
529 | | - |
530 | 541 |
|
531 | 542 | pair<string, string> RteKernel::GetPdscFileFromPath(const XmlItem& attributes, const string& prjPath) const |
532 | 543 | { |
@@ -579,7 +590,7 @@ bool RteKernel::GetLocalPdscFiles(const XmlItem& attr, std::map<std::string, std |
579 | 590 | if(pack) { |
580 | 591 | const string& version = pack->GetVersionString(); |
581 | 592 | if(versionRange.empty() || VersionCmp::RangeCompare(version, versionRange) == 0) { |
582 | | - pdscMap[pack->GetID()] = localPdscFile; |
| 593 | + pdscMap[RteUtils::ToLower(pack->GetID())] = localPdscFile; |
583 | 594 | found = true; |
584 | 595 | } |
585 | 596 | } |
|
0 commit comments