|
| 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 |
0 commit comments