Skip to content

Commit 2114cf7

Browse files
grasci-armbrondani
andauthored
[projmgr] Initial target-set implementation
Partly address #2056 New: - `target-set` and its subnodes parsing and selected contexts handling - add `a`, `--active` options to set active `target-set` - add `list target-sets` command Changes: - Rename `load` to `images` - Move `debugger` and `images` from csolution top level into `target-set` Differences from implementation and current specification due to inconsistencies: - `images` is allowed only under `target-set` - `load` mode and `load-offset` have a coherent structure between input and output (csolution.yml and cbuild-run.yml) - active `target-set` in cbuild-run.yml Not implemented in this PR: - `debug-adapters.yml` handling Co-authored-by: Daniel Brondani <[email protected]>
1 parent a0e5b74 commit 2114cf7

22 files changed

+645
-329
lines changed

tools/projmgr/include/ProjMgr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ class ProjMgr {
145145
std::string m_clayerSearchPath;
146146
std::string m_export;
147147
std::string m_selectedToolchain;
148+
std::string m_activeTargetSet;
148149
bool m_checkSchema;
149150
bool m_missingPacks;
150151
bool m_updateRteFiles;
@@ -172,6 +173,7 @@ class ProjMgr {
172173
bool RunListConfigs();
173174
bool RunListDependencies();
174175
bool RunListContexts();
176+
bool RunListTargetSets();
175177
bool RunListGenerators();
176178
bool RunListLayers();
177179
bool RunListToolchains();

tools/projmgr/include/ProjMgrParser.h

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,54 @@ struct MemoryItem {
126126
std::string algorithm;
127127
};
128128

129+
/**
130+
* @brief debugger item containing
131+
* name of debug configuration
132+
* debug protocol (jtag or swd)
133+
* debug clock speed
134+
* debug configuration file
135+
* start pname
136+
*/
137+
struct DebuggerItem {
138+
std::string name;
139+
std::string protocol;
140+
std::string clock;
141+
std::string dbgconf;
142+
std::string startPname;
143+
};
144+
145+
/**
146+
* @brief target set image containing
147+
* project context
148+
* image file
149+
* info brief description
150+
* type specifies an explicit file type
151+
* load mode
152+
* load offset
153+
*/
154+
struct ImageItem {
155+
std::string context;
156+
std::string image;
157+
std::string info;
158+
std::string type;
159+
std::string load;
160+
std::string offset;
161+
};
162+
163+
/**
164+
* @brief target set containing
165+
* set name (default unnamed),
166+
* info string,
167+
* target set images,
168+
* debugger configuration
169+
*/
170+
struct TargetSetItem {
171+
std::string set;
172+
std::string info;
173+
std::vector<ImageItem> images;
174+
DebuggerItem debugger;
175+
};
176+
129177
/**
130178
* @brief build types containing
131179
* toolchain,
@@ -168,12 +216,14 @@ struct BuildType {
168216
* platform board,
169217
* platform device,
170218
* additional memory,
219+
* target set,
171220
* build options
172221
*/
173222
struct TargetType {
174223
std::string board;
175224
std::string device;
176225
std::vector<MemoryItem> memory;
226+
std::vector<TargetSetItem> targetSet;
177227
BuildType build;
178228
};
179229

@@ -420,42 +470,6 @@ struct CdefaultItem {
420470
std::vector<MiscItem> misc;
421471
};
422472

423-
/**
424-
* @brief debugger item containing
425-
* name of debug configuration
426-
* brief description
427-
* debug protocol (jtag or swd)
428-
* debug clock speed
429-
* debug configuration file
430-
* type filter
431-
*/
432-
struct DebuggerItem {
433-
std::string name;
434-
std::string info;
435-
std::string protocol;
436-
std::string clock;
437-
std::string dbgconf;
438-
TypeFilter type;
439-
};
440-
441-
/**
442-
* @brief load item containing
443-
* file specifies the file name
444-
* info brief description of the file
445-
* type specifies an explicit file type
446-
* run additional command string for download or programming
447-
* debug additional command string for debug
448-
* type filter
449-
*/
450-
struct LoadItem {
451-
std::string file;
452-
std::string info;
453-
std::string type;
454-
std::string run;
455-
std::string debug;
456-
TypeFilter typeFilter;
457-
};
458-
459473
typedef std::vector<std::pair<std::string, BuildType>> BuildTypes;
460474
typedef std::vector<std::pair<std::string, TargetType>> TargetTypes;
461475
/**
@@ -476,8 +490,6 @@ typedef std::vector<std::pair<std::string, TargetType>> TargetTypes;
476490
* cdefault enable switch,
477491
* generator options,
478492
* list of executes,
479-
* list of debuggers,
480-
* list of loads
481493
*/
482494
struct CsolutionItem {
483495
std::string name;
@@ -497,8 +509,6 @@ struct CsolutionItem {
497509
GeneratorsItem generators;
498510
CbuildPackItem cbuildPack;
499511
std::vector<ExecutesItem> executes;
500-
std::vector<DebuggerItem> debuggers;
501-
std::vector<LoadItem> loads;
502512
std::vector<std::string> ymlOrderedBuildTypes;
503513
std::vector<std::string> ymlOrderedTargetTypes;
504514
};

tools/projmgr/include/ProjMgrRunDebug.h

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ struct FilesType {
5555
std::string file;
5656
std::string info;
5757
std::string type;
58-
std::string run;
59-
std::string debug;
58+
std::string load;
59+
std::string offset;
6060
std::string pname;
6161
};
6262

@@ -90,17 +90,6 @@ struct DebugVarsType {
9090
std::string vars;
9191
};
9292

93-
/**
94-
* @brief debugger type
95-
*/
96-
struct DebuggerType {
97-
std::string name;
98-
std::string info;
99-
std::string protocol;
100-
std::optional<unsigned long long> clock;
101-
std::string dbgconf;
102-
};
103-
10493
/**
10594
* @brief punit type
10695
*/
@@ -172,6 +161,7 @@ struct RunDebugType {
172161
std::string solution;
173162
std::string solutionName;
174163
std::string targetType;
164+
std::string targetSet;
175165
std::string compiler;
176166
std::string board;
177167
std::string boardPack;
@@ -181,7 +171,7 @@ struct RunDebugType {
181171
std::vector<FilesType> outputs;
182172
std::vector<FilesType> systemDescriptions;
183173
SystemResourcesType systemResources;
184-
std::vector<DebuggerType> debuggers;
174+
DebuggerType debugger;
185175
DebugVarsType debugVars;
186176
std::vector<DebugSequencesType> debugSequences;
187177
DebugTopologyType debugTopology;

tools/projmgr/include/ProjMgrWorker.h

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,24 @@ struct ContextTypesItem {
242242
BoolMap missingTargetTypes;
243243
};
244244

245+
/**
246+
* @brief debugger type
247+
* name of debug configuration
248+
* brief description
249+
* debug protocol (jtag or swd)
250+
* debug clock speed
251+
* debug configuration file
252+
* start pname
253+
*/
254+
struct DebuggerType {
255+
std::string name;
256+
std::string info;
257+
std::string protocol;
258+
std::optional<unsigned long long> clock;
259+
std::string dbgconf;
260+
std::string startPname;
261+
};
262+
245263
/**
246264
* @brief project context item containing
247265
* pointer to csolution,
@@ -297,9 +315,10 @@ struct ContextTypesItem {
297315
* vector of device books
298316
* vector of board books
299317
* additional memory
300-
* debuggers
318+
* debugger
301319
* default dbgconf
302-
* loads
320+
* images
321+
* selected target-set
303322
*/
304323
struct ContextItem {
305324
CdefaultItem* cdefault = nullptr;
@@ -362,9 +381,10 @@ struct ContextItem {
362381
std::vector<BookItem> deviceBooks;
363382
std::vector<BookItem> boardBooks;
364383
std::vector<MemoryItem> memory;
365-
std::vector<DebuggerItem> debuggers;
384+
DebuggerType debugger;
366385
std::pair<std::string, RteFileInstance*> dbgconf;
367-
std::vector<LoadItem> loads;
386+
std::vector<ImageItem> images;
387+
std::string targetSet;
368388
};
369389

370390
/**
@@ -486,6 +506,14 @@ class ProjMgrWorker {
486506
*/
487507
bool ListContexts(std::vector<std::string>& contexts, const std::string& filter = RteUtils::EMPTY_STRING, const bool ymlOrder = false);
488508

509+
/**
510+
* @brief list target-sets
511+
* @param reference to list of target-sets
512+
* @param filter words to filter results
513+
* @return true if executed successfully
514+
*/
515+
bool ListTargetSets(std::vector<std::string>& targetSets, const std::string& filter = RteUtils::EMPTY_STRING);
516+
489517
/**
490518
* @brief list generators of a given context
491519
* @param reference to list of generators
@@ -662,12 +690,14 @@ class ProjMgrWorker {
662690
/**
663691
* @brief parse context selection
664692
* @param contexts pattern (wildcards are allowed)
665-
* @param context replacement pattern (wildcards are allowed)
693+
* @param check cbuildset flag (default false)
694+
* @param active target-set (default empty)
666695
* @return true if executed successfully
667696
*/
668697
bool ParseContextSelection(
669698
const std::vector<std::string>& contextSelection,
670-
const bool checkCbuildSet = false);
699+
const bool checkCbuildSet = false,
700+
const std::string activeTargetSet = std::string());
671701

672702
/**
673703
* @brief get the list of selected contexts
@@ -832,6 +862,8 @@ class ProjMgrWorker {
832862
StrVec m_selectableCompilers;
833863
bool m_undefCompiler = false;
834864
std::map<std::string, FileNode> m_missingFiles;
865+
std::string m_activeTargetType;
866+
TargetSetItem m_activeTargetSet;
835867

836868
bool LoadPacks(ContextItem& context);
837869
bool CheckMissingPackRequirements(const std::string& contextName);
@@ -859,7 +891,7 @@ class ProjMgrWorker {
859891
bool ProcessConfigFiles(ContextItem& context);
860892
bool ProcessComponentFiles(ContextItem& context);
861893
bool ProcessDebuggers(ContextItem& context);
862-
bool ProcessLoads(ContextItem& context);
894+
bool ProcessImages(ContextItem& context);
863895
bool ProcessExecutes(ContextItem& context, bool solutionLevel = false);
864896
bool ProcessGroups(ContextItem& context);
865897
bool ProcessSequencesRelatives(ContextItem& context, bool rerun);
@@ -941,6 +973,8 @@ class ProjMgrWorker {
941973
StrVec CollectSelectableCompilers();
942974
void ProcessTmpDir(std::string& tmpdir, const std::string& base);
943975
bool IsCreatedByExecute(const std::string file, const std::string dir);
976+
bool ParseTargetSetContextSelection(const std::string& activeTargetSet);
977+
bool GetActiveTargetSet(const std::string& activeTargetSet);
944978
};
945979

946980
#endif // PROJMGRWORKER_H

tools/projmgr/include/ProjMgrYamlParser.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ static constexpr const char* YAML_HOST = "host";
122122
static constexpr const char* YAML_HPROT = "HPROT";
123123
static constexpr const char* YAML_ID = "id";
124124
static constexpr const char* YAML_IF = "if";
125+
static constexpr const char* YAML_IMAGES = "images";
126+
static constexpr const char* YAML_IMAGE = "image";
125127
static constexpr const char* YAML_IMPLEMENTED_BY = "implemented-by";
126128
static constexpr const char* YAML_IMPLEMENTS = "implements";
127129
static constexpr const char* YAML_INDEX = "index";
@@ -135,6 +137,7 @@ static constexpr const char* YAML_LANGUAGE_CPP = "language-CPP";
135137
static constexpr const char* YAML_LAYER = "layer";
136138
static constexpr const char* YAML_LAYERS = "layers";
137139
static constexpr const char* YAML_LOAD = "load";
140+
static constexpr const char* YAML_LOAD_OFFSET = "load-offset";
138141
static constexpr const char* YAML_LICENSE = "license";
139142
static constexpr const char* YAML_LICENSES = "licenses";
140143
static constexpr const char* YAML_LICENSE_AGREEMENT = "license-agreement";
@@ -179,6 +182,7 @@ static constexpr const char* YAML_PROCESSOR = "processor";
179182
static constexpr const char* YAML_PROGRAMMING = "programming";
180183
static constexpr const char* YAML_PROJECT = "project";
181184
static constexpr const char* YAML_PROJECTS = "projects";
185+
static constexpr const char* YAML_PROJECT_CONTEXT = "project-context";
182186
static constexpr const char* YAML_PROJECT_TYPE = "project-type";
183187
static constexpr const char* YAML_PROTOCOL = "protocol";
184188
static constexpr const char* YAML_PROVIDES = "provides";
@@ -204,6 +208,7 @@ static constexpr const char* YAML_SETTINGS = "settings";
204208
static constexpr const char* YAML_SELECT_COMPILER = "select-compiler";
205209
static constexpr const char* YAML_SIZE = "size";
206210
static constexpr const char* YAML_START = "start";
211+
static constexpr const char* YAML_START_PNAME = "start-pname";
207212
static constexpr const char* YAML_STATUS = "status";
208213
static constexpr const char* YAML_SOLUTION = "solution";
209214
static constexpr const char* YAML_SPROT = "SPROT";
@@ -215,6 +220,7 @@ static constexpr const char* YAML_SYSTEM_RESOURCES = "system-resources";
215220
static constexpr const char* YAML_TAPINDEX = "tapindex";
216221
static constexpr const char* YAML_TARGET_CONFIGURATIONS = "target-configurations";
217222
static constexpr const char* YAML_TARGETSEL = "targetsel";
223+
static constexpr const char* YAML_TARGET_SET = "target-set";
218224
static constexpr const char* YAML_TARGETTYPE = "target-type";
219225
static constexpr const char* YAML_TARGETTYPES = "target-types";
220226
static constexpr const char* YAML_TIMEOUT = "timeout";
@@ -312,8 +318,9 @@ class ProjMgrYamlParser {
312318
void ParseOutputDirs(const YAML::Node& parent, const std::string& file, struct DirectoriesItem& directories);
313319
void ParseGenerators(const YAML::Node& parent, const std::string& file, GeneratorsItem& generators);
314320
void ParseExecutes(const YAML::Node& parent, const std::string& file, std::vector<ExecutesItem>& executes);
315-
bool ParseDebugger(const YAML::Node& parent, const std::string& file, std::vector<DebuggerItem>& debbugers);
316-
bool ParseLoad(const YAML::Node& parent, const std::string& file, std::vector<LoadItem>& loads);
321+
void ParseDebugger(const YAML::Node& parent, const std::string& file, DebuggerItem& debugger);
322+
void ParseTargetSet(const YAML::Node& parent, const std::string& file, std::vector<TargetSetItem>& targetSet);
323+
void ParseImages(const YAML::Node& parent, const std::string& file, std::vector<ImageItem>& loads);
317324
void ParseConnections(const YAML::Node& parent, std::vector<ConnectItem>& connects);
318325
bool ParseTargetType(const YAML::Node& parent, const std::string& file, TargetType& targetType);
319326
bool ParseBuildTypes(const YAML::Node& parent, const std::string& file, BuildTypes& buildTypes);

0 commit comments

Comments
 (0)