Skip to content

Commit a19f95f

Browse files
authored
[projmgr] Add dbgconf node in *.cbuild.yml
1 parent 58fd432 commit a19f95f

File tree

65 files changed

+585
-45
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+585
-45
lines changed

tools/projmgr/include/ProjMgrWorker.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ struct ContextTypesItem {
298298
* vector of board books
299299
* additional memory
300300
* debuggers
301+
* default dbgconf
301302
*/
302303
struct ContextItem {
303304
CdefaultItem* cdefault = nullptr;
@@ -361,6 +362,7 @@ struct ContextItem {
361362
std::vector<BookItem> boardBooks;
362363
std::vector<MemoryItem> memory;
363364
std::vector<DebuggerItem> debuggers;
365+
std::pair<std::string, RteFileInstance*> dbgconf;
364366
};
365367

366368
/**

tools/projmgr/schemas/common.schema.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,50 @@
3434
},
3535
"additionalProperties": false
3636
},
37+
"DebugConfigsType": {
38+
"type": "array",
39+
"uniqueItems": true,
40+
"minItems": 1,
41+
"items": { "$ref": "#/definitions/DebugConfigType" }
42+
},
43+
"DebugConfigType": {
44+
"type": "object",
45+
"properties": {
46+
"file": {
47+
"title": "file:",
48+
"type": "string",
49+
"description": "File name along with the path."
50+
},
51+
"base": {
52+
"title": "base:",
53+
"type": "string",
54+
"description": "Current configuration file with version."
55+
},
56+
"status": {
57+
"title": "status:",
58+
"$ref": "#/definitions/PLMStatusType"
59+
},
60+
"version": {
61+
"title": "version:",
62+
"$ref": "#/definitions/VersionType"
63+
},
64+
"update": {
65+
"title": "update:",
66+
"type": "string",
67+
"description": "New configuration file used for merge utility."
68+
},
69+
"debugger": {
70+
"title": "debugger:",
71+
"type": "array",
72+
"description": "Associated debugger connections.",
73+
"uniqueItems": true,
74+
"minItems": 1,
75+
"items": { "type": "string" }
76+
}
77+
},
78+
"required": [ "file" ],
79+
"additionalProperties": false
80+
},
3781
"ArrayOfContextMapAlternativeContext": {
3882
"type": "array",
3983
"uniqueItems": true,
@@ -1299,6 +1343,7 @@
12991343
"device": { "$ref": "#/definitions/DeviceType" },
13001344
"device-pack": { "$ref": "#/definitions/PackID" },
13011345
"device-books": { "$ref": "#/definitions/BooksType" },
1346+
"dbgconf": { "$ref": "#/definitions/DebugConfigsType" },
13021347
"processor": { "$ref": "#/definitions/BuildProcessorType" },
13031348
"packs": { "$ref": "#/definitions/BuildPacksType" },
13041349
"optimize": { "$ref": "#/definitions/OptimizeType" },

tools/projmgr/src/ProjMgrCbuild.cpp

Lines changed: 61 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class ProjMgrCbuild : public ProjMgrCbuildBase {
3838
void SetMiscNode(YAML::Node miscNode, const vector<MiscItem>& misc);
3939
void SetDefineNode(YAML::Node node, const vector<string>& vec);
4040
void SetBooksNode(YAML::Node node, const std::vector<BookItem>& books, const std::string& dir);
41+
void SetDebugConfigNode(YAML::Node node, const ContextItem* context);
42+
void SetPLMStatus(YAML::Node node, const ContextItem* context, const string& file);
4143
bool m_ignoreRteFileMissing;
4244
};
4345

@@ -80,6 +82,7 @@ void ProjMgrCbuild::SetContextNode(YAML::Node contextNode, const ContextItem* co
8082
SetNodeValue(contextNode[YAML_DEVICE_PACK], context->devicePack->GetID());
8183
}
8284
SetBooksNode(contextNode[YAML_DEVICE_BOOKS], context->deviceBooks, context->directories.cbuild);
85+
SetDebugConfigNode(contextNode[YAML_DBGCONF], context);
8386
SetProcessorNode(contextNode[YAML_PROCESSOR], context->targetAttributes);
8487
SetPacksNode(contextNode[YAML_PACKS], context);
8588
SetControlsNode(contextNode, context, context->controls.processed);
@@ -152,6 +155,27 @@ void ProjMgrCbuild::SetComponentsNode(YAML::Node node, const ContextItem* contex
152155
}
153156
}
154157

158+
void ProjMgrCbuild::SetDebugConfigNode(YAML::Node node, const ContextItem* context) {
159+
map<string, StrVec> dbgconfList;
160+
for (const auto& debugger : context->debuggers) {
161+
string dbgconf = debugger.dbgconf.empty() ? context->dbgconf.first : debugger.dbgconf;
162+
CollectionUtils::PushBackUniquely(dbgconfList[dbgconf], debugger.name);
163+
}
164+
if (dbgconfList.empty() && !context->dbgconf.first.empty()) {
165+
dbgconfList[context->dbgconf.first];
166+
}
167+
for (const auto& [dbgconf, debuggers] : dbgconfList) {
168+
YAML::Node fileNode;
169+
SetNodeValue(fileNode[YAML_FILE], FormatPath(dbgconf, context->directories.cbuild));
170+
if (dbgconf == context->dbgconf.first) {
171+
SetNodeValue(fileNode[YAML_VERSION], context->dbgconf.second->GetSemVer(true));
172+
SetPLMStatus(fileNode, context, dbgconf);
173+
}
174+
SetNodeValue(fileNode[YAML_DEBUGGER], debuggers);
175+
node.push_back(fileNode);
176+
}
177+
}
178+
155179
void ProjMgrCbuild::SetComponentFilesNode(YAML::Node node, const ContextItem* context, const string& componentId) {
156180
if (context->componentFiles.find(componentId) != context->componentFiles.end()) {
157181
for (const auto& [file, attr, category, language, scope, version, select] : context->componentFiles.at(componentId)) {
@@ -164,46 +188,50 @@ void ProjMgrCbuild::SetComponentFilesNode(YAML::Node node, const ContextItem* co
164188
SetNodeValue(fileNode[YAML_VERSION], version);
165189
SetNodeValue(fileNode[YAML_SELECT], select);
166190
if (attr == "config") {
167-
string directory = RteUtils::ExtractFilePath(file, false);
168-
string name = RteUtils::ExtractFileName(file);
191+
SetPLMStatus(fileNode, context, file);
192+
}
193+
node.push_back(fileNode);
194+
}
195+
}
196+
}
169197

170-
// lambda to get backup file with specified file filter
171-
auto GetBackupFile = [&](const string& fileFilter) {
172-
list<string> backupFiles;
173-
RteFsUtils::GrepFileNames(backupFiles, directory, fileFilter + "@*");
198+
void ProjMgrCbuild::SetPLMStatus(YAML::Node node, const ContextItem* context, const string& file) {
199+
string directory = RteUtils::ExtractFilePath(file, false);
200+
string name = RteUtils::ExtractFileName(file);
174201

175-
// Return empty string if no backup files found
176-
if (backupFiles.size() == 0) {
177-
return RteUtils::EMPTY_STRING;
178-
}
202+
// lambda to get backup file with specified file filter
203+
auto GetBackupFile = [&](const string& fileFilter) {
204+
list<string> backupFiles;
205+
RteFsUtils::GrepFileNames(backupFiles, directory, fileFilter + "@*");
179206

180-
// Warn if multiple backup files are found
181-
//This is a safeguard. however, this condition should never be triggered
182-
if (backupFiles.size() > 1) {
183-
ProjMgrLogger::Get().Warn(
184-
"'" + directory + "' contains more than one '" + fileFilter + " file, PLM may fail");
185-
}
207+
// Return empty string if no backup files found
208+
if (backupFiles.size() == 0) {
209+
return RteUtils::EMPTY_STRING;
210+
}
186211

187-
return FormatPath(backupFiles.front().c_str(), context->directories.cbuild);
188-
};
212+
// Warn if multiple backup files are found
213+
//This is a safeguard. however, this condition should never be triggered
214+
if (backupFiles.size() > 1) {
215+
ProjMgrLogger::Get().Warn(
216+
"'" + directory + "' contains more than one '" + fileFilter + " file, PLM may fail");
217+
}
189218

190-
// Get base and update backup files
191-
string baseFile = GetBackupFile(name + '.' + RteUtils::BASE_STRING);
192-
string updateFile = GetBackupFile(name + '.' + RteUtils::UPDATE_STRING);
219+
return FormatPath(backupFiles.front().c_str(), context->directories.cbuild);
220+
};
193221

194-
// Add nodes if both base and update files exist
195-
if (!baseFile.empty() && !updateFile.empty()) {
196-
SetNodeValue(fileNode[YAML_BASE], baseFile);
197-
SetNodeValue(fileNode[YAML_UPDATE], updateFile);
198-
}
222+
// Get base and update backup files
223+
string baseFile = GetBackupFile(name + '.' + RteUtils::BASE_STRING);
224+
string updateFile = GetBackupFile(name + '.' + RteUtils::UPDATE_STRING);
199225

200-
// Add PLM Status
201-
if (context->plmStatus.find(file) != context->plmStatus.end()) {
202-
SetNodeValue(fileNode[YAML_STATUS], context->plmStatus.at(file));
203-
}
204-
}
205-
node.push_back(fileNode);
206-
}
226+
// Add nodes if both base and update files exist
227+
if (!baseFile.empty() && !updateFile.empty()) {
228+
SetNodeValue(node[YAML_BASE], baseFile);
229+
SetNodeValue(node[YAML_UPDATE], updateFile);
230+
}
231+
232+
// Add PLM Status
233+
if (context->plmStatus.find(file) != context->plmStatus.end()) {
234+
SetNodeValue(node[YAML_STATUS], context->plmStatus.at(file));
207235
}
208236
}
209237

tools/projmgr/src/ProjMgrRunDebug.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,7 @@ bool ProjMgrRunDebug::CollectSettings(const vector<ContextItem*>& contexts) {
208208

209209
// default debugger parameters from DFP and BSP
210210
DebuggerType defaultDebugger;
211-
for (auto& [filename, fi] : context0->rteActiveProject->GetFileInstances()) {
212-
if (fi->HasAttribute("configfile")) {
213-
defaultDebugger.dbgconf = context0->cproject->directory + '/' + filename;
214-
break;
215-
}
216-
}
211+
defaultDebugger.dbgconf = context0->dbgconf.first;
217212
const auto& debugConfig = context0->devicePack ?
218213
context0->rteDevice->GetSingleEffectiveProperty("debugconfig", context0->deviceItem.pname) : nullptr;
219214
const auto& debugProbe = context0->boardPack ?
@@ -234,8 +229,7 @@ bool ProjMgrRunDebug::CollectSettings(const vector<ContextItem*>& contexts) {
234229
item.info = debugger.info;
235230
item.port = debugger.port.empty() ? defaultDebugger.port : debugger.port;
236231
item.clock = debugger.clock.empty() ? defaultDebugger.clock : RteUtils::StringToULL(debugger.clock);
237-
item.dbgconf = debugger.dbgconf.empty() ? defaultDebugger.dbgconf : RteFsUtils::IsRelative(item.dbgconf) ?
238-
context0->cproject->directory + '/' + debugger.dbgconf : debugger.dbgconf;
232+
item.dbgconf = debugger.dbgconf.empty() ? defaultDebugger.dbgconf : debugger.dbgconf;
239233
m_runDebug.debuggers.push_back(item);
240234
}
241235
} else {

tools/projmgr/src/ProjMgrWorker.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,14 +2124,14 @@ bool ProjMgrWorker::CheckConfigPLMFiles(ContextItem& context) {
21242124
continue;
21252125
}
21262126
// get base version
2127-
const string baseVersion = fi.second->GetSemVer();
2127+
const string baseVersion = fi.second->GetSemVer(true);
21282128
if (!RteFsUtils::Exists(file + '.' + RteUtils::BASE_STRING + '@' + baseVersion)) {
21292129
ProjMgrLogger::Get().Warn("file '" + file + ".base' not found; base version unknown", context.name);
21302130
context.plmStatus[file] = PLM_STATUS_MISSING_BASE;
21312131
} else {
21322132
// get update version
21332133
const RteItem* f = fi.second->GetFile(context.rteActiveTarget->GetName());
2134-
const string updateVersion = f ? f->GetSemVer() : "";
2134+
const string updateVersion = f ? f->GetSemVer(true) : "";
21352135
if (baseVersion != updateVersion) {
21362136
// parse and check each semantic version segment
21372137
static const regex regEx = regex("(\\d+).(\\d+).(\\d+)");
@@ -2474,9 +2474,21 @@ void ProjMgrWorker::ProcessDebuggers(ContextItem& context) {
24742474
const vector<DebuggerItem>& debuggers = m_parser->GetCsolution().debuggers;
24752475
for (const auto& item : debuggers) {
24762476
if (CheckContextFilters(item.type, context)) {
2477-
context.debuggers.push_back(item);
2477+
auto filtered = item;
2478+
if (!filtered.dbgconf.empty() && RteFsUtils::IsRelative(filtered.dbgconf)) {
2479+
RteFsUtils::NormalizePath(filtered.dbgconf, context.csolution->directory);
2480+
}
2481+
context.debuggers.push_back(filtered);
24782482
}
2479-
}
2483+
}
2484+
for (const auto& [filename, fi] : context.rteActiveProject->GetFileInstances()) {
2485+
if (fi->HasAttribute("configfile")) {
2486+
string dbgconf = filename;
2487+
RteFsUtils::NormalizePath(dbgconf, context.cproject->directory);
2488+
context.dbgconf = { dbgconf, fi };
2489+
break;
2490+
}
2491+
}
24802492
}
24812493

24822494
bool ProjMgrWorker::ProcessSolutionExecutes() {

tools/projmgr/test/data/ExternalGenerator/ref/MultiCore/core0.Debug+MultiCore.cbuild-gen.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ build-gen:
1111
device-books:
1212
- name: http://infocenter.arm.com/help/topic/com.arm.doc.dui0497a/index.html
1313
title: Cortex-M0 Device Generic Users Guide
14+
dbgconf:
15+
- file: ${DEVTOOLS(data)}/ExternalGenerator/multi_0/RTE/Device/RteTest_ARMCM0_Dual_cm0_core0/ARMCM.dbgconf
16+
version: 0.0.2
1417
processor:
1518
fpu: off
1619
core: Cortex-M0

tools/projmgr/test/data/ExternalGenerator/ref/MultiCore/core1.Debug+MultiCore.cbuild-gen.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ build-gen:
1111
device-books:
1212
- name: http://infocenter.arm.com/help/topic/com.arm.doc.dui0497a/index.html
1313
title: Cortex-M0 Device Generic Users Guide
14+
dbgconf:
15+
- file: ${DEVTOOLS(data)}/ExternalGenerator/multi_1/RTE/Device/RteTest_ARMCM0_Dual_cm0_core1/ARMCM.dbgconf
16+
version: 0.0.2
1417
processor:
1518
fpu: off
1619
core: Cortex-M0

tools/projmgr/test/data/ExternalGenerator/ref/SingleCore/single-core.Debug+Board.cbuild.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ build:
1818
device-books:
1919
- name: http://infocenter.arm.com/help/topic/com.arm.doc.dui0553a/index.html
2020
title: Cortex-M4 Device Generic Users Guide
21+
dbgconf:
22+
- file: RTE/Device/RteTest_ARMCM4_FP/ARMCM4.dbgconf
23+
version: 0.2.1
2124
processor:
2225
fpu: sp
2326
core: Cortex-M4

tools/projmgr/test/data/TestAccessSequences/ref/pack-access-sequences+CM4-Board.cbuild.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ build:
1818
device-books:
1919
- name: http://infocenter.arm.com/help/topic/com.arm.doc.dui0553a/index.html
2020
title: Cortex-M4 Device Generic Users Guide
21+
dbgconf:
22+
- file: ../data/TestAccessSequences/RTE/Device/RteTest_ARMCM4_FP/ARMCM4.dbgconf
23+
version: 0.1.0
2124
processor:
2225
fpu: sp
2326
core: Cortex-M4

tools/projmgr/test/data/TestDefault/ref/empty/project.Debug+TEST_TARGET.cbuild.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ build:
99
device-books:
1010
- name: http://infocenter.arm.com/help/topic/com.arm.doc.dui0497a/index.html
1111
title: Cortex-M0 Device Generic Users Guide
12+
dbgconf:
13+
- file: ../../data/TestDefault/RTE/Device/RteTest_ARMCM0/ARMCM.dbgconf
14+
version: 0.0.0
1215
processor:
1316
fpu: off
1417
core: Cortex-M0

0 commit comments

Comments
 (0)