Skip to content

Commit

Permalink
[projmgr] Implement External Generator
Browse files Browse the repository at this point in the history
  • Loading branch information
grasci-arm authored Oct 18, 2023
1 parent c5728d5 commit afcc7e5
Show file tree
Hide file tree
Showing 79 changed files with 1,831 additions and 160 deletions.
10 changes: 10 additions & 0 deletions tools/buildmgr/cbuildgen/installer/create_installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ curl --retry 3 -L ${cpackget_base}_linux_arm64.tar.gz -o - | tar xzfO - --wildc
curl --retry 3 -L ${cpackget_base}_windows_arm64.zip -o temp.zip && unzip -p temp.zip '*/cpackget.exe' > ${distdir}/bin/cpackget.exe-arm64 && rm temp.zip
curl --retry 3 -L ${cpackget_base}_darwin_arm64.tar.gz -o - | tar xzfO - --wildcards '*cpackget' > ${distdir}/bin/cpackget.mac-arm64

# Get cbridge
# cbridge_version="0.9.0"
# cbridge_base=https://github.com/Open-CMSIS-Pack/generator-bridge/releases/download/${cbridge_version}/cbridge_${cbridge_version}
# curl --retry 3 -L ${cbridge_base}_linux_amd64.tar.gz -o - | tar xzfO - --wildcards '*cbridge' > ${distdir}/bin/cbridge.lin-amd64
# curl --retry 3 -L ${cbridge_base}_windows_amd64.zip -o temp.zip && unzip -p temp.zip '*/cbridge.exe' > ${distdir}/bin/cbridge.exe-amd64 && rm temp.zip
# curl --retry 3 -L ${cbridge_base}_darwin_amd64.tar.gz -o - | tar xzfO - --wildcards '*cbridge' > ${distdir}/bin/cbridge.mac-amd64
# curl --retry 3 -L ${cbridge_base}_linux_arm64.tar.gz -o - | tar xzfO - --wildcards '*cbridge' > ${distdir}/bin/cbridge.lin-arm64
# curl --retry 3 -L ${cbridge_base}_windows_arm64.zip -o temp.zip && unzip -p temp.zip '*/cbridge.exe' > ${distdir}/bin/cbridge.exe-arm64 && rm temp.zip
# curl --retry 3 -L ${cbridge_base}_darwin_arm64.tar.gz -o - | tar xzfO - --wildcards '*cbridge' > ${distdir}/bin/cbridge.mac-arm64

# Get csolution
csolution_version="2.1.0"
csolution_base=https://github.com/Open-CMSIS-Pack/devtools/releases/download/tools%2Fprojmgr%2F${csolution_version}/projmgr.zip
Expand Down
5 changes: 5 additions & 0 deletions tools/buildmgr/cbuildgen/installer/make_deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ cpackget_version="1.0.1"
cpackget_base=https://github.com/Open-CMSIS-Pack/cpackget/releases/download/v${cpackget_version}/cpackget_${cpackget_version}
curl --retry 3 -L ${cpackget_base}_linux_amd64.tar.gz -o - | tar xzfO - --wildcards '*cpackget' > ${input}/bin/cpackget.lin-amd64

# Get generator-bridge
# cbridge_version="0.9.0"
# cbridge_base=https://github.com/Open-CMSIS-Pack/generator-bridge/releases/download/${cbridge_version}/cbridge_${cbridge_version}
# curl --retry 3 -L ${cbridge_base}_linux_amd64.tar.gz -o - | tar xzfO - --wildcards '*cpackget' > ${input}/bin/cbridge.lin-amd64

# Get csolution
csolution_version="2.1.0"
csolution_base=https://github.com/Open-CMSIS-Pack/devtools/releases/download/tools%2Fprojmgr%2F${csolution_version}/projmgr.zip
Expand Down
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
125 changes: 125 additions & 0 deletions tools/projmgr/include/ProjMgrExtGenerator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*
* 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;
};

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

/**
* @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
39 changes: 38 additions & 1 deletion 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,40 +446,53 @@ 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);

/**
* @brief parse cbuild set file
* @param checkSchema false to skip schema validation
* @param input path to *.cbuild-set.yml file
*/
bool ParseCbuildSet(const std::string& input);
bool ParseCbuildSet(const std::string& input, bool checkSchema);

/**
* @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
Expand Down Expand Up @@ -500,13 +529,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

0 comments on commit afcc7e5

Please sign in to comment.