Skip to content

Commit 93506fc

Browse files
authored
[projmgr] Global Generator: update context selection, defer partial processing failures
1 parent 3e77d41 commit 93506fc

7 files changed

Lines changed: 493 additions & 31 deletions

File tree

tools/projmgr/src/ProjMgrWorker.cpp

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,10 @@ bool ProjMgrWorker::LoadAllRelevantPacks() {
526526
m_loadedPacks.clear(); // the list will be updated, it should not contain dangling pointers
527527
// Get required pdsc files
528528
std::list<std::string> pdscFiles;
529+
bool noPackRequirements = true;
529530
for (const auto& context : m_selectedContexts) {
530531
auto& contextItem = m_contexts.at(context);
532+
noPackRequirements &= contextItem.packRequirements.empty();
531533
for (const auto& [pdscFile, pathVer] : contextItem.pdscFiles) {
532534
const string& path = pathVer.first;
533535
if (!path.empty()) {
@@ -543,12 +545,12 @@ bool ProjMgrWorker::LoadAllRelevantPacks() {
543545
}
544546
}
545547
// Check load packs policy
546-
if (pdscFiles.empty() && (m_loadPacksPolicy == LoadPacksPolicy::REQUIRED)) {
548+
if (noPackRequirements && (m_loadPacksPolicy == LoadPacksPolicy::REQUIRED)) {
547549
ProjMgrLogger::Get().Error("required packs must be specified");
548550
return false;
549551
}
550552
// Get installed packs
551-
if (pdscFiles.empty() || (m_loadPacksPolicy == LoadPacksPolicy::ALL) || (m_loadPacksPolicy == LoadPacksPolicy::LATEST)) {
553+
if (noPackRequirements || (m_loadPacksPolicy == LoadPacksPolicy::ALL) || (m_loadPacksPolicy == LoadPacksPolicy::LATEST)) {
552554
const bool latest = (m_loadPacksPolicy == LoadPacksPolicy::LATEST) || (m_loadPacksPolicy == LoadPacksPolicy::DEFAULT);
553555
if (!m_kernel->GetEffectivePdscFiles(pdscFiles, latest)) {
554556
ProjMgrLogger::Get().Error("parsing installed packs failed");
@@ -585,16 +587,15 @@ bool ProjMgrWorker::LoadPacks(ContextItem& context) {
585587
if (!InitializeTarget(context)) {
586588
return false;
587589
}
590+
bool deferredFail = false;
588591
if (!CollectAllRequiredPdscFiles()) {
589592
PrintContextErrors(context.name);
590-
if(!m_rpcMode) {
591-
return false;
592-
}
593+
// defer return due to pdsc collection failure
594+
deferredFail = true;
593595
}
594596
if ((m_loadedPacks.empty() || m_rpcMode) && !LoadAllRelevantPacks()) {
595-
if(!m_rpcMode) {
596-
return false;
597-
}
597+
// defer return due to pack loading failure
598+
deferredFail = true;
598599
}
599600
// Filter context specific packs
600601
set<string> selectedPacks;
@@ -624,6 +625,10 @@ bool ProjMgrWorker::LoadPacks(ContextItem& context) {
624625
filter.SetSelectedPackages(selectedPacks);
625626
context.rteActiveTarget->SetPackageFilter(filter);
626627
context.rteActiveTarget->UpdateFilterModel();
628+
// report deferred failure; in rpc mode continue processing despite it
629+
if (!m_rpcMode && deferredFail) {
630+
return false;
631+
}
627632
return CheckRteErrors();
628633
}
629634

@@ -4807,12 +4812,12 @@ bool ProjMgrWorker::ListGenerators(vector<string>& generators) {
48074812
set<string> generatorsSet;
48084813
map <string, map<string, map<string, StrVec>>> sortedGeneratorsMap;
48094814
StrMap generatorsDescription;
4815+
bool deferredFail = false;
48104816
// classic generators
48114817
for (const auto& selectedContext : m_selectedContexts) {
48124818
ContextItem& context = m_contexts[selectedContext];
4813-
if (!ProcessContext(context, false, true, false)) {
4814-
return false;
4815-
}
4819+
// defer failure report
4820+
deferredFail |= !ProcessContext(context, false, true, false);
48164821
for (const auto& [id, generator] : context.generators) {
48174822
for (const auto& [gpdsc, item] : context.gpdscs) {
48184823
if (item.generator == id) {
@@ -4827,6 +4832,11 @@ bool ProjMgrWorker::ListGenerators(vector<string>& generators) {
48274832
}
48284833
}
48294834
}
4835+
if (deferredFail) {
4836+
// report deferred failure
4837+
return false;
4838+
}
4839+
48304840
// global generators
48314841
for (const auto& [options, contexts] : m_extGenerator->GetUsedGenerators()) {
48324842
sortedGeneratorsMap.insert({ options.id, {} });
@@ -5678,22 +5688,31 @@ std::string ProjMgrWorker::GetSelectedToochain(void) {
56785688
bool ProjMgrWorker::ProcessGlobalGenerators(ContextItem* selectedContext, const string& generatorId,
56795689
string& projectType, StrVec& siblings) {
56805690

5681-
// iterate over contexts with same build and target types
5682-
m_selectedContexts.clear();
5683-
for (auto& [_, context] : m_contexts) {
5684-
if ((context.type.build != selectedContext->type.build) ||
5685-
(context.type.target != selectedContext->type.target)) {
5686-
continue;
5687-
}
5688-
if (!ParseContextLayers(context)) {
5689-
return false;
5691+
if (m_activeTargetType.empty()) {
5692+
// if active target type is not given, select all contexts with same build and target types
5693+
m_selectedContexts.clear();
5694+
for (auto& [_, context] : m_contexts) {
5695+
if ((context.type.build != selectedContext->type.build) ||
5696+
(context.type.target != selectedContext->type.target)) {
5697+
continue;
5698+
}
5699+
m_selectedContexts.push_back(context.name);
56905700
}
5691-
m_selectedContexts.push_back(context.name);
56925701
}
5693-
for (auto& context : m_selectedContexts) {
5694-
if (!ProcessContext(m_contexts.at(context), false, true, false)) {
5695-
return false;
5702+
// parse layers and process selected contexts
5703+
bool deferredFail = false;
5704+
for (auto& contextName : m_selectedContexts) {
5705+
if (!ParseContextLayers(m_contexts.at(contextName))) {
5706+
// defer failure report due to layers parsing
5707+
deferredFail = true;
5708+
continue;
56965709
}
5710+
// defer failure report due to context processing
5711+
deferredFail |= !ProcessContext(m_contexts.at(contextName), false, true, false);
5712+
}
5713+
// report deferred failure
5714+
if (deferredFail) {
5715+
return false;
56975716
}
56985717
StrVec contextVec;
56995718
const string& genDir = selectedContext->extGen[generatorId].path;
@@ -6147,7 +6166,8 @@ void ProjMgrWorker::CollectUnusedPacks() {
61476166
continue;
61486167
}
61496168
context.unusedPacks.clear();
6150-
for (const auto& [packId, _] : context.rteFilteredModel->GetPackages()) {
6169+
for (const auto& [_, packItem] : context.rteFilteredModel->GetPackages()) {
6170+
const auto packId = packItem->GetPackageID();
61516171
if (context.packages.find(packId) == context.packages.end()) {
61526172
CollectionUtils::PushBackUniquely(context.unusedPacks, packId);
61536173
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
* Copyright (c) 2023 Arm Limited. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the License); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
14+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/* ----------------------------------------------------------------------------
20+
Stack seal size definition
21+
*----------------------------------------------------------------------------*/
22+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
23+
#define __STACKSEAL_SIZE 8
24+
#else
25+
#define __STACKSEAL_SIZE 0
26+
#endif
27+
28+
/*----------------------------------------------------------------------------
29+
Scatter File Definitions definition
30+
*----------------------------------------------------------------------------*/
31+
32+
LR_ROM0 __ROM0_BASE __ROM0_SIZE {
33+
34+
ER_ROM0 __ROM0_BASE __ROM0_SIZE {
35+
*.o (RESET, +First)
36+
*(InRoot$$Sections)
37+
*(+RO +XO)
38+
}
39+
40+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
41+
ER_CMSE_VENEER AlignExpr(+0, 32) (__ROM0_SIZE - AlignExpr(ImageLength(ER_ROM0), 32)) {
42+
*(Veneer$$CMSE)
43+
}
44+
#endif
45+
46+
RW_NOINIT __RAM0_BASE UNINIT (__RAM0_SIZE - __HEAP_SIZE - __STACK_SIZE - __STACKSEAL_SIZE) {
47+
*.o(.bss.noinit)
48+
*.o(.bss.noinit.*)
49+
}
50+
51+
RW_RAM0 AlignExpr(+0, 8) (__RAM0_SIZE - __HEAP_SIZE - __STACK_SIZE - __STACKSEAL_SIZE - AlignExpr(ImageLength(RW_NOINIT), 8)) {
52+
*(+RW +ZI)
53+
}
54+
55+
#if __HEAP_SIZE > 0
56+
ARM_LIB_HEAP (AlignExpr(+0, 8)) EMPTY __HEAP_SIZE { ; Reserve empty region for heap
57+
}
58+
#endif
59+
60+
ARM_LIB_STACK (__RAM0_BASE + __RAM0_SIZE - __STACKSEAL_SIZE) EMPTY -__STACK_SIZE { ; Reserve empty region for stack
61+
}
62+
63+
#if __STACKSEAL_SIZE > 0
64+
STACKSEAL +0 EMPTY __STACKSEAL_SIZE { ; Reserve empty region for stack seal immediately after stack
65+
}
66+
#endif
67+
68+
#if __RAM1_SIZE > 0
69+
RW_RAM1 __RAM1_BASE __RAM1_SIZE {
70+
.ANY (+RW +ZI)
71+
}
72+
#endif
73+
74+
#if __RAM2_SIZE > 0
75+
RW_RAM2 __RAM2_BASE __RAM2_SIZE {
76+
.ANY (+RW +ZI)
77+
}
78+
#endif
79+
80+
#if __RAM3_SIZE > 0
81+
RW_RAM3 __RAM3_BASE __RAM3_SIZE {
82+
.ANY (+RW +ZI)
83+
}
84+
#endif
85+
}
86+
87+
#if __ROM1_SIZE > 0
88+
LR_ROM1 __ROM1_BASE __ROM1_SIZE {
89+
ER_ROM1 +0 __ROM1_SIZE {
90+
.ANY (+RO +XO)
91+
}
92+
}
93+
#endif
94+
95+
#if __ROM2_SIZE > 0
96+
LR_ROM2 __ROM2_BASE __ROM2_SIZE {
97+
ER_ROM2 +0 __ROM2_SIZE {
98+
.ANY (+RO +XO)
99+
}
100+
}
101+
#endif
102+
103+
#if __ROM3_SIZE > 0
104+
LR_ROM3 __ROM3_BASE __ROM3_SIZE {
105+
ER_ROM3 +0 __ROM3_SIZE {
106+
.ANY (+RO +XO)
107+
}
108+
}
109+
#endif
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#ifndef REGIONS_RTETESTGEN_ARMCM0_H
2+
#define REGIONS_RTETESTGEN_ARMCM0_H
3+
4+
5+
//-------- <<< Use Configuration Wizard in Context Menu >>> --------------------
6+
//------ With VS Code: Open Preview for Configuration Wizard -------------------
7+
8+
// <n> Auto-generated using information from packs
9+
// <i> Device Family Pack (DFP): ARM::RteTestGenerator@0.1.0
10+
11+
// <h> ROM Configuration
12+
// =======================
13+
// <h> __ROM0 (unused)
14+
// <o> Base address <0x0-0xFFFFFFFF:8>
15+
// <i> Defines base address of memory region.
16+
// <i> Contains Startup and Vector Table
17+
#define __ROM0_BASE 0x0
18+
// <o> Region size [bytes] <0x0-0xFFFFFFFF:8>
19+
// <i> Defines size of memory region.
20+
#define __ROM0_SIZE 0x0
21+
// </h>
22+
23+
// <h> __ROM1 (unused)
24+
// <o> Base address <0x0-0xFFFFFFFF:8>
25+
// <i> Defines base address of memory region.
26+
#define __ROM1_BASE 0x0
27+
// <o> Region size [bytes] <0x0-0xFFFFFFFF:8>
28+
// <i> Defines size of memory region.
29+
#define __ROM1_SIZE 0x0
30+
// </h>
31+
32+
// <h> __ROM2 (unused)
33+
// <o> Base address <0x0-0xFFFFFFFF:8>
34+
// <i> Defines base address of memory region.
35+
#define __ROM2_BASE 0x0
36+
// <o> Region size [bytes] <0x0-0xFFFFFFFF:8>
37+
// <i> Defines size of memory region.
38+
#define __ROM2_SIZE 0x0
39+
// </h>
40+
41+
// <h> __ROM3 (unused)
42+
// <o> Base address <0x0-0xFFFFFFFF:8>
43+
// <i> Defines base address of memory region.
44+
#define __ROM3_BASE 0x0
45+
// <o> Region size [bytes] <0x0-0xFFFFFFFF:8>
46+
// <i> Defines size of memory region.
47+
#define __ROM3_SIZE 0x0
48+
// </h>
49+
50+
// </h>
51+
52+
// <h> RAM Configuration
53+
// =======================
54+
// <h> __RAM0 (unused)
55+
// <o> Base address <0x0-0xFFFFFFFF:8>
56+
// <i> Defines base address of memory region.
57+
// <i> Contains uninitialized RAM, Stack, and Heap
58+
#define __RAM0_BASE 0x0
59+
// <o> Region size [bytes] <0x0-0xFFFFFFFF:8>
60+
// <i> Defines size of memory region.
61+
#define __RAM0_SIZE 0x0
62+
// </h>
63+
64+
// <h> __RAM1 (unused)
65+
// <o> Base address <0x0-0xFFFFFFFF:8>
66+
// <i> Defines base address of memory region.
67+
#define __RAM1_BASE 0x0
68+
// <o> Region size [bytes] <0x0-0xFFFFFFFF:8>
69+
// <i> Defines size of memory region.
70+
#define __RAM1_SIZE 0x0
71+
// </h>
72+
73+
// <h> __RAM2 (unused)
74+
// <o> Base address <0x0-0xFFFFFFFF:8>
75+
// <i> Defines base address of memory region.
76+
#define __RAM2_BASE 0x0
77+
// <o> Region size [bytes] <0x0-0xFFFFFFFF:8>
78+
// <i> Defines size of memory region.
79+
#define __RAM2_SIZE 0x0
80+
// </h>
81+
82+
// <h> __RAM3 (unused)
83+
// <o> Base address <0x0-0xFFFFFFFF:8>
84+
// <i> Defines base address of memory region.
85+
#define __RAM3_BASE 0x0
86+
// <o> Region size [bytes] <0x0-0xFFFFFFFF:8>
87+
// <i> Defines size of memory region.
88+
#define __RAM3_SIZE 0x0
89+
// </h>
90+
91+
// </h>
92+
93+
// <h> Stack / Heap Configuration
94+
// <o0> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
95+
// <o1> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
96+
#define __STACK_SIZE 0x00000200
97+
#define __HEAP_SIZE 0x00000000
98+
// </h>
99+
100+
101+
#endif /* REGIONS_RTETESTGEN_ARMCM0_H */

tools/projmgr/test/data/TestSolution/PackMissing/ref/missing_pack.cbuild-idx.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
build-idx:
2-
generated-by: csolution version 0.0.0+g79b66b5f
2+
generated-by: csolution version 0.0.0
33
csolution: ../data/TestSolution/PackMissing/missing_pack.csolution.yml
44
tmpdir: tmp
55
cprojects:
@@ -12,7 +12,6 @@ build-idx:
1212
messages:
1313
errors:
1414
- "required pack: ARM::Missing_DFP@0.0.9 not installed"
15-
- "specified device 'RteTest_ARMCM0' not found in the installed packs. Use:\n cpackget add Vendor::PackName"
1615
- processing context 'project+CM0' failed
1716
info:
1817
- missing_pack.cbuild-pack.yml - file generated successfully
@@ -26,7 +25,6 @@ build-idx:
2625
messages:
2726
errors:
2827
- "required pack: ARM::Missing_PACK@0.0.1 not installed"
29-
- "specified device 'RteTest_ARMCM3' not found in the installed packs. Use:\n cpackget add Vendor::PackName"
3028
- processing context 'project+Gen' failed
3129
info:
3230
- missing_pack.cbuild-pack.yml - file generated successfully
@@ -42,7 +40,6 @@ build-idx:
4240
- "required pack: ARM::Missing_DFP@>=0.0.5 not installed"
4341
- "required pack: ARM::Missing_PACK not installed"
4442
- "required pack: ARM::RteTest@3.0.1 not installed"
45-
- "specified device 'RteTest_ARMCM0' not found in the installed packs. Use:\n cpackget add Vendor::PackName"
4643
- processing context 'project+Miss' failed
4744
info:
4845
- missing_pack.cbuild-pack.yml - file generated successfully

0 commit comments

Comments
 (0)