Skip to content

Commit 32ce30f

Browse files
committed
[projmgr] External Generator PoC - Initial commit
1 parent c5728d5 commit 32ce30f

76 files changed

Lines changed: 1826 additions & 152 deletions

File tree

Some content is hidden

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

tools/projmgr/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT projmgr)
1313
SET(PROJMGR_SOURCE_FILES ProjMgr.cpp ProjMgrKernel.cpp ProjMgrCallback.cpp
1414
ProjMgrParser.cpp ProjMgrWorker.cpp ProjMgrGenerator.cpp ProjMgrXmlParser.cpp
1515
ProjMgrYamlParser.cpp ProjMgrLogger.cpp ProjMgrYamlSchemaChecker.cpp
16-
ProjMgrYamlEmitter.cpp ProjMgrUtils.cpp
16+
ProjMgrYamlEmitter.cpp ProjMgrUtils.cpp ProjMgrExtGenerator.cpp
1717
)
1818
SET(PROJMGR_HEADER_FILES ProjMgr.h ProjMgrKernel.h ProjMgrCallback.h
1919
ProjMgrParser.h ProjMgrWorker.h ProjMgrGenerator.h ProjMgrXmlParser.h
2020
ProjMgrYamlParser.h ProjMgrLogger.h ProjMgrYamlSchemaChecker.h
21-
ProjMgrYamlEmitter.h ProjMgrUtils.h
21+
ProjMgrYamlEmitter.h ProjMgrUtils.h ProjMgrExtGenerator.h
2222
)
2323

2424
list(TRANSFORM PROJMGR_SOURCE_FILES PREPEND src/)

tools/projmgr/include/ProjMgr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class ProjMgr {
8585

8686
protected:
8787
ProjMgrParser m_parser;
88+
ProjMgrExtGenerator m_extGenerator;
8889
ProjMgrWorker m_worker;
8990
ProjMgrGenerator m_generator;
9091
ProjMgrYamlEmitter m_emitter;
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/*
2+
* Copyright (c) 2020-2023 Arm Limited. All rights reserved.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef PROJMGREXTGENERATOR_H
8+
#define PROJMGREXTGENERATOR_H
9+
10+
#include "ProjMgrParser.h"
11+
#include "ProjMgrUtils.h"
12+
13+
/**
14+
* @brief external generator item containing
15+
* component identifier
16+
* directory for generated files
17+
* project type
18+
*/
19+
struct ExtGeneratorItem {
20+
std::string componentId;
21+
std::string genDir;
22+
std::string projectType;
23+
};
24+
25+
26+
struct CbuildGenItem {
27+
StrVec forContext;
28+
std::string device;
29+
std::string board;
30+
std::string projectPart;
31+
};
32+
33+
/**
34+
* @brief map of used generators, directories and contexts
35+
*/
36+
typedef std::map<std::string, StrVecMap> GeneratorContextVecMap;
37+
38+
/**
39+
* @brief vector of external generator items
40+
*/
41+
typedef std::vector<ExtGeneratorItem> ExtGeneratorVec;
42+
43+
/**
44+
* @brief map of vector of external generator items
45+
*/
46+
typedef std::map<std::string, ExtGeneratorVec> ExtGeneratorVecMap;
47+
48+
/**
49+
* @brief solution/project types
50+
*/
51+
static constexpr const char* TYPE_SINGLE_CORE = "single-core";
52+
static constexpr const char* TYPE_MULTI_CORE = "multi-core";
53+
static constexpr const char* TYPE_TRUSTZONE = "trustzone";
54+
55+
/**
56+
* @brief projmgr external generator class responsible for handling global generators
57+
*/
58+
class ProjMgrExtGenerator {
59+
public:
60+
/**
61+
* @brief class constructor
62+
*/
63+
ProjMgrExtGenerator(ProjMgrParser* parser);
64+
65+
66+
/**
67+
* @brief class destructor
68+
*/
69+
~ProjMgrExtGenerator(void);
70+
71+
/**
72+
* @brief set check schema
73+
* @param boolean check schema
74+
*/
75+
void SetCheckSchema(bool checkSchema);
76+
77+
/**
78+
* @brief retrieve globally registered generators
79+
* @return true if successful
80+
*/
81+
bool RetrieveGlobalGenerators(void);
82+
83+
/**
84+
* @brief verify if generator is global
85+
* @param generatorId generator identifier
86+
* @return true if generator is global
87+
*/
88+
bool IsGlobalGenerator(const std::string& generatorId);
89+
90+
/**
91+
* @brief verify if generator required by a given component is valid
92+
* @param generatorId generator identifier
93+
* @param componentId component identifier
94+
* @return true if generator is valid
95+
*/
96+
bool CheckGeneratorId(const std::string& generatorId, const std::string& componentId);
97+
98+
/**
99+
* @brief get directory for generated files
100+
* @param generatorId generator identifier
101+
* @return string directory for generated files
102+
*/
103+
const std::string& GetGlobalGenDir(const std::string& generatorId);
104+
105+
/**
106+
* @brief get run command for generator call
107+
* @param generatorId generator identifier
108+
* @return string with run command for generator call
109+
*/
110+
const std::string& GetGlobalGenRunCmd(const std::string& generatorId);
111+
112+
/**
113+
* @brief add generator to the list of used generators of a given context
114+
* @param generatorId generator identifier
115+
* @param genDir directory for generated files
116+
* @param contextId context identifier
117+
*/
118+
void AddUsedGenerator(const std::string& generatorId, const std::string& genDir, const std::string& contextId);
119+
120+
/**
121+
* @brief get map of used generators
122+
* @return map of used generators
123+
*/
124+
const GeneratorContextVecMap& GetUsedGenerators(void);
125+
126+
/**
127+
* @brief get layer item with generator-import file data
128+
* @param contextId context identifier
129+
* @param boolean reference, true if successful
130+
* @return layer item
131+
*/
132+
ClayerItem* GetGeneratorImport(const std::string& contextId, bool& success);
133+
134+
protected:
135+
ProjMgrParser* m_parser = nullptr;
136+
StrVec m_globalGeneratorFiles;
137+
std::map<std::string, GlobalGeneratorItem> m_globalGenerators;
138+
GeneratorContextVecMap m_usedGenerators;
139+
bool m_checkSchema;
140+
std::string m_compilerRoot;
141+
};
142+
143+
#endif // PROJMGREXTGENERATOR_H

tools/projmgr/include/ProjMgrParser.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,14 @@ struct TargetType {
140140
* @brief directories item containing
141141
* intdir directory,
142142
* outdir directory,
143+
* cbuild directory,
143144
* cprj directory,
144145
* rte directory,
145146
*/
146147
struct DirectoriesItem {
147148
std::string intdir;
148149
std::string outdir;
150+
std::string cbuild;
149151
std::string cprj;
150152
std::string rte;
151153
};
@@ -413,6 +415,20 @@ struct CbuildSetItem {
413415
std::string compiler;
414416
};
415417

418+
/**
419+
* @brief global generator item containing
420+
* generator id,
421+
* download url,
422+
* bridge program,
423+
* path for generated files
424+
*/
425+
struct GlobalGeneratorItem {
426+
std::string id;
427+
std::string downloadUrl;
428+
std::string run;
429+
std::string path;
430+
};
431+
416432
/**
417433
* @brief projmgr parser class for public interfacing
418434
*/
@@ -430,31 +446,36 @@ class ProjMgrParser {
430446

431447
/**
432448
* @brief parse cdefault
449+
* @param checkSchema false to skip schema validation
433450
* @param input cdefault.yml file
434451
*/
435452
bool ParseCdefault(const std::string& input, bool checkSchema);
436453

437454
/**
438455
* @brief parse cproject
439456
* @param input cproject.yml file
457+
* @param checkSchema false to skip schema validation
440458
* @param boolean parse single project, default false
441459
*/
442460
bool ParseCproject(const std::string& input, bool checkSchema, bool single = false);
443461

444462
/**
445463
* @brief parse csolution
464+
* @param checkSchema false to skip schema validation
446465
* @param input csolution.yml file
447466
*/
448467
bool ParseCsolution(const std::string& input, bool checkSchema);
449468

450469
/**
451470
* @brief parse clayer
471+
* @param checkSchema false to skip schema validation
452472
* @param input clayer.yml file
453473
*/
454474
bool ParseClayer(const std::string& input, bool checkSchema);
455475

456476
/**
457477
* @brief parse generic clayer files
478+
* @param checkSchema false to skip schema validation
458479
* @param input clayer.yml file
459480
*/
460481
bool ParseGenericClayer(const std::string& input, bool checkSchema);
@@ -465,6 +486,13 @@ class ProjMgrParser {
465486
*/
466487
bool ParseCbuildSet(const std::string& input);
467488

489+
/**
490+
* @brief parse global generator
491+
* @param input generator.yml file
492+
* @param checkSchema false to skip schema validation
493+
*/
494+
bool ParseGlobalGenerator(const std::string& input, bool checkSchema);
495+
468496
/**
469497
* @brief get cdefault
470498
* @return cdefault item
@@ -500,13 +528,21 @@ class ProjMgrParser {
500528
* @return cbuildset item
501529
*/
502530
CbuildSetItem& GetCbuildSetItem(void);
531+
532+
/**
533+
* @brief get global generators
534+
* @return global generators map
535+
*/
536+
std::map<std::string, GlobalGeneratorItem>& GetGlobalGenerators(void);
537+
503538
protected:
504539
CdefaultItem m_cdefault;
505540
CsolutionItem m_csolution;
506541
CbuildSetItem m_cbuildSet;
507542
std::map<std::string, CprojectItem> m_cprojects;
508543
std::map<std::string, ClayerItem> m_clayers;
509544
std::map<std::string, ClayerItem> m_genericClayers;
545+
std::map<std::string, GlobalGeneratorItem> m_globalGenerators;
510546
};
511547

512548
#endif // PROJMGRPARSER_H

0 commit comments

Comments
 (0)