Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[projmgr] External Generator PoC #16

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tools/projmgr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT projmgr)
SET(PROJMGR_SOURCE_FILES ProjMgr.cpp ProjMgrKernel.cpp ProjMgrCallback.cpp
ProjMgrParser.cpp ProjMgrWorker.cpp ProjMgrGenerator.cpp ProjMgrXmlParser.cpp
ProjMgrYamlParser.cpp ProjMgrLogger.cpp ProjMgrYamlSchemaChecker.cpp
ProjMgrYamlEmitter.cpp ProjMgrUtils.cpp
ProjMgrYamlEmitter.cpp ProjMgrUtils.cpp ProjMgrExtGenerator.cpp
)
SET(PROJMGR_HEADER_FILES ProjMgr.h ProjMgrKernel.h ProjMgrCallback.h
ProjMgrParser.h ProjMgrWorker.h ProjMgrGenerator.h ProjMgrXmlParser.h
ProjMgrYamlParser.h ProjMgrLogger.h ProjMgrYamlSchemaChecker.h
ProjMgrYamlEmitter.h ProjMgrUtils.h
ProjMgrYamlEmitter.h ProjMgrUtils.h ProjMgrExtGenerator.h
)

list(TRANSFORM PROJMGR_SOURCE_FILES PREPEND src/)
Expand Down
1 change: 1 addition & 0 deletions tools/projmgr/include/ProjMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class ProjMgr {

protected:
ProjMgrParser m_parser;
ProjMgrExtGenerator m_extGenerator;
ProjMgrWorker m_worker;
ProjMgrGenerator m_generator;
ProjMgrYamlEmitter m_emitter;
Expand Down
143 changes: 143 additions & 0 deletions tools/projmgr/include/ProjMgrExtGenerator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/*
* Copyright (c) 2020-2023 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef PROJMGREXTGENERATOR_H
#define PROJMGREXTGENERATOR_H

#include "ProjMgrParser.h"
#include "ProjMgrUtils.h"

/**
* @brief external generator item containing
* component identifier
* directory for generated files
* project type
*/
struct ExtGeneratorItem {
std::string componentId;
std::string genDir;
std::string projectType;
};


struct CbuildGenItem {
StrVec forContext;
std::string device;
std::string board;
std::string projectPart;
};

/**
* @brief map of used generators, directories and contexts
*/
typedef std::map<std::string, StrVecMap> GeneratorContextVecMap;

/**
* @brief vector of external generator items
*/
typedef std::vector<ExtGeneratorItem> ExtGeneratorVec;

/**
* @brief map of vector of external generator items
*/
typedef std::map<std::string, ExtGeneratorVec> ExtGeneratorVecMap;

/**
* @brief solution/project types
*/
static constexpr const char* TYPE_SINGLE_CORE = "single-core";
static constexpr const char* TYPE_MULTI_CORE = "multi-core";
static constexpr const char* TYPE_TRUSTZONE = "trustzone";

/**
* @brief projmgr external generator class responsible for handling global generators
*/
class ProjMgrExtGenerator {
public:
/**
* @brief class constructor
*/
ProjMgrExtGenerator(ProjMgrParser* parser);


/**
* @brief class destructor
*/
~ProjMgrExtGenerator(void);

/**
* @brief set check schema
* @param boolean check schema
*/
void SetCheckSchema(bool checkSchema);

/**
* @brief retrieve globally registered generators
* @return true if successful
*/
bool RetrieveGlobalGenerators(void);

/**
* @brief verify if generator is global
* @param generatorId generator identifier
* @return true if generator is global
*/
bool IsGlobalGenerator(const std::string& generatorId);

/**
* @brief verify if generator required by a given component is valid
* @param generatorId generator identifier
* @param componentId component identifier
* @return true if generator is valid
*/
bool CheckGeneratorId(const std::string& generatorId, const std::string& componentId);

/**
* @brief get directory for generated files
* @param generatorId generator identifier
* @return string directory for generated files
*/
const std::string& GetGlobalGenDir(const std::string& generatorId);

/**
* @brief get run command for generator call
* @param generatorId generator identifier
* @return string with run command for generator call
*/
const std::string& GetGlobalGenRunCmd(const std::string& generatorId);

/**
* @brief add generator to the list of used generators of a given context
* @param generatorId generator identifier
* @param genDir directory for generated files
* @param contextId context identifier
*/
void AddUsedGenerator(const std::string& generatorId, const std::string& genDir, const std::string& contextId);

/**
* @brief get map of used generators
* @return map of used generators
*/
const GeneratorContextVecMap& GetUsedGenerators(void);

/**
* @brief get layer item with generator-import file data
* @param contextId context identifier
* @param boolean reference, true if successful
* @return layer item
*/
ClayerItem* GetGeneratorImport(const std::string& contextId, bool& success);

protected:
ProjMgrParser* m_parser = nullptr;
StrVec m_globalGeneratorFiles;
std::map<std::string, GlobalGeneratorItem> m_globalGenerators;
GeneratorContextVecMap m_usedGenerators;
bool m_checkSchema;
std::string m_compilerRoot;
};

#endif // PROJMGREXTGENERATOR_H
36 changes: 36 additions & 0 deletions tools/projmgr/include/ProjMgrParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,14 @@ struct TargetType {
* @brief directories item containing
* intdir directory,
* outdir directory,
* cbuild directory,
* cprj directory,
* rte directory,
*/
struct DirectoriesItem {
std::string intdir;
std::string outdir;
std::string cbuild;
std::string cprj;
std::string rte;
};
Expand Down Expand Up @@ -413,6 +415,20 @@ struct CbuildSetItem {
std::string compiler;
};

/**
* @brief global generator item containing
* generator id,
* download url,
* bridge program,
* path for generated files
*/
struct GlobalGeneratorItem {
std::string id;
std::string downloadUrl;
std::string run;
std::string path;
};

/**
* @brief projmgr parser class for public interfacing
*/
Expand All @@ -430,31 +446,36 @@ class ProjMgrParser {

/**
* @brief parse cdefault
* @param checkSchema false to skip schema validation
* @param input cdefault.yml file
*/
bool ParseCdefault(const std::string& input, bool checkSchema);

/**
* @brief parse cproject
* @param input cproject.yml file
* @param checkSchema false to skip schema validation
* @param boolean parse single project, default false
*/
bool ParseCproject(const std::string& input, bool checkSchema, bool single = false);

/**
* @brief parse csolution
* @param checkSchema false to skip schema validation
* @param input csolution.yml file
*/
bool ParseCsolution(const std::string& input, bool checkSchema);

/**
* @brief parse clayer
* @param checkSchema false to skip schema validation
* @param input clayer.yml file
*/
bool ParseClayer(const std::string& input, bool checkSchema);

/**
* @brief parse generic clayer files
* @param checkSchema false to skip schema validation
* @param input clayer.yml file
*/
bool ParseGenericClayer(const std::string& input, bool checkSchema);
Expand All @@ -465,6 +486,13 @@ class ProjMgrParser {
*/
bool ParseCbuildSet(const std::string& input);

/**
* @brief parse global generator
* @param input generator.yml file
* @param checkSchema false to skip schema validation
*/
bool ParseGlobalGenerator(const std::string& input, bool checkSchema);

/**
* @brief get cdefault
* @return cdefault item
Expand Down Expand Up @@ -500,13 +528,21 @@ class ProjMgrParser {
* @return cbuildset item
*/
CbuildSetItem& GetCbuildSetItem(void);

/**
* @brief get global generators
* @return global generators map
*/
std::map<std::string, GlobalGeneratorItem>& GetGlobalGenerators(void);

protected:
CdefaultItem m_cdefault;
CsolutionItem m_csolution;
CbuildSetItem m_cbuildSet;
std::map<std::string, CprojectItem> m_cprojects;
std::map<std::string, ClayerItem> m_clayers;
std::map<std::string, ClayerItem> m_genericClayers;
std::map<std::string, GlobalGeneratorItem> m_globalGenerators;
};

#endif // PROJMGRPARSER_H
Loading
Loading