Skip to content

Commit 0de4c2a

Browse files
committed
Add GetComponentsInfo request
1 parent 24faab2 commit 0de4c2a

9 files changed

Lines changed: 350 additions & 61 deletions

File tree

tools/projmgr/include/ProjMgr.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ class ProjMgr {
5757
*/
5858
ProjMgrWorker& GetWorker() { return m_worker; };
5959

60+
/**
61+
* @brief load solution
62+
* @param path to <solution>.csolution.yml file
63+
* @return processing status
64+
*/
65+
bool LoadSolution(std::string csolution);
66+
6067
protected:
6168
/**
6269
* @brief parse command line options
@@ -185,6 +192,7 @@ class ProjMgr {
185192
bool GenerateYMLConfigurationFiles(bool previousResult);
186193
bool UpdateRte();
187194
bool ParseAndValidateContexts();
195+
bool ProcessContexts();
188196
};
189197

190198
#endif // PROJMGR_H

tools/projmgr/include/ProjMgrExtGenerator.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ class ProjMgrExtGenerator {
101101
*/
102102
ClayerItem* GetGeneratorImport(const std::string& contextId, bool& success);
103103

104+
void Clear() {
105+
m_usedGenerators.clear();
106+
}
107+
104108
protected:
105109
ProjMgrParser* m_parser = nullptr;
106110
GeneratorContextVecMap m_usedGenerators;

tools/projmgr/include/ProjMgrParser.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,15 @@ class ProjMgrParser {
682682
*/
683683
CbuildSetItem& GetCbuildSetItem(void);
684684

685+
void Clear() {
686+
m_cdefault = {};
687+
m_csolution = {};
688+
m_cbuildSet = {};
689+
m_cprojects.clear();
690+
m_clayers.clear();
691+
m_genericClayers.clear();
692+
}
693+
685694
protected:
686695
CdefaultItem m_cdefault;
687696
CsolutionItem m_csolution;

tools/projmgr/include/ProjMgrRpcServer.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class ProjMgrRpcServer {
2323
/**
2424
* @brief class constructor
2525
*/
26-
ProjMgrRpcServer(ProjMgr* manager);
26+
ProjMgrRpcServer(ProjMgr& manager);
2727

2828
/**
2929
* @brief class destructor
@@ -38,9 +38,9 @@ class ProjMgrRpcServer {
3838

3939
/**
4040
* @brief get parser object
41-
* @return pointer to m_manager
41+
* @return reference to m_manager
4242
*/
43-
ProjMgr* GetManager() { return m_manager; };
43+
ProjMgr& GetManager() { return m_manager; };
4444

4545
/**
4646
* @brief set m_shutdown flag
@@ -55,7 +55,7 @@ class ProjMgrRpcServer {
5555
void SetContentLengthHeader(bool value) { m_contextLength = value; };
5656

5757
protected:
58-
ProjMgr* m_manager;
58+
ProjMgr& m_manager;
5959
bool m_shutdown = false;
6060
bool m_contextLength = false;
6161
const std::string GetRequestFromStdinWithLength(void);

tools/projmgr/include/ProjMgrRunDebug.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ class ProjMgrRunDebug {
147147
*/
148148
bool CollectSettings(const std::vector<ContextItem*>& contexts);
149149

150+
void Clear() {
151+
m_runDebug = {};
152+
}
153+
150154
protected:
151155
RunDebugType m_runDebug;
152156
void GetDebugSequenceBlock(const RteItem* item, DebugSequencesBlockType& block);

tools/projmgr/include/ProjMgrWorker.h

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,62 @@ class ProjMgrWorker {
794794
*/
795795
bool CheckRteErrors(void);
796796

797+
/**
798+
* @brief load packs
799+
* @param context item
800+
* @return true if there is no error
801+
*/
802+
bool LoadPacks(ContextItem& context);
803+
804+
/**
805+
* @brief set target attributes
806+
* @param context item
807+
* @param map of attributes
808+
* @return true if there is no error
809+
*/
810+
bool SetTargetAttributes(ContextItem& context, std::map<std::string, std::string>& attributes);
811+
812+
/**
813+
* @brief add required components
814+
* @param context item
815+
* @return true if there is no error
816+
*/
817+
bool AddRequiredComponents(ContextItem& context);
818+
819+
/**
820+
* @brief validate context
821+
* @param context item
822+
* @return true if there is no error
823+
*/
824+
bool ValidateContext(ContextItem& context);
825+
826+
/**
827+
* @brief clear worker members for reloading a solution
828+
* @return true if there is no error
829+
*/
830+
void Clear() {
831+
for (auto context : m_contexts) {
832+
for (auto componentItem : context.second.components) {
833+
delete componentItem.second.instance;
834+
}
835+
}
836+
m_contexts.clear();
837+
m_ymlOrderedContexts.clear();
838+
m_contextsPtr->clear();
839+
m_contextErrMap.clear();
840+
m_selectedContexts.clear();
841+
m_outputDir.clear();
842+
m_selectedToolchain.clear();
843+
m_rootDir.clear();
844+
m_undefLayerVars.clear();
845+
m_packMetadata.clear();
846+
m_executes.clear();
847+
m_toolchainErrors.clear();
848+
m_selectableCompilers.clear();
849+
m_missingFiles.clear();
850+
m_types = {};
851+
};
852+
797853
protected:
798854
ProjMgrParser* m_parser = nullptr;
799855
ProjMgrKernel* m_kernel = nullptr;
@@ -833,7 +889,6 @@ class ProjMgrWorker {
833889
bool m_undefCompiler = false;
834890
std::map<std::string, FileNode> m_missingFiles;
835891

836-
bool LoadPacks(ContextItem& context);
837892
bool CheckMissingPackRequirements(const std::string& contextName);
838893
void CheckMissingLinkerScript(ContextItem& context);
839894
bool CollectRequiredPdscFiles(ContextItem& context, const std::string& packRoot);
@@ -844,7 +899,6 @@ class ProjMgrWorker {
844899
bool GetTypeContent(ContextItem& context);
845900
bool GetProjectSetup(ContextItem& context);
846901
bool InitializeTarget(ContextItem& context);
847-
bool SetTargetAttributes(ContextItem& context, std::map<std::string, std::string>& attributes);
848902
bool ProcessPrecedences(ContextItem& context, BoardOrDevice process = BoardOrDevice::None, bool rerun = false);
849903
bool ProcessPrecedence(StringCollection& item);
850904
bool ProcessCompilerPrecedence(StringCollection& item, bool acceptRedefinition = false);
@@ -871,15 +925,13 @@ class ProjMgrWorker {
871925
bool ProcessLinkerOptions(ContextItem& context, const LinkerItem& linker, const std::string& ref);
872926
bool ProcessProcessorOptions(ContextItem& context);
873927
void AddContext(ContextDesc& descriptor, const TypePair& type, ContextItem& parentContext);
874-
bool ValidateContext(ContextItem& context);
875928
bool FormatValidationResults(std::set<std::string>& results, const ContextItem& context);
876929
void UpdateMisc(std::vector<MiscItem>& vec, const std::string& compiler);
877930
void AddMiscUniquely(MiscItem& dst, std::vector<std::vector<MiscItem>*>& srcVec);
878931
void AddMiscUniquely(MiscItem& dst, std::vector<MiscItem>& srcVec);
879932
bool AddGroup(const GroupNode& src, std::vector<GroupNode>& dst, ContextItem& context, const std::string root);
880933
bool AddFile(const FileNode& src, std::vector<FileNode>& dst, ContextItem& context, const std::string root);
881934
bool AddComponent(const ComponentItem& src, const std::string& layer, std::vector<std::pair<ComponentItem, std::string>>& dst, TypePair type, ContextItem& context);
882-
bool AddRequiredComponents(ContextItem& context);
883935
void GetDeviceItem(const std::string& element, DeviceItem& device) const;
884936
void GetBoardItem (const std::string& element, BoardItem& board) const;
885937
bool GetPrecedentValue(std::string& outValue, const std::string& element) const;
@@ -941,6 +993,7 @@ class ProjMgrWorker {
941993
StrVec CollectSelectableCompilers();
942994
void ProcessTmpDir(std::string& tmpdir, const std::string& base);
943995
bool IsCreatedByExecute(const std::string file, const std::string dir);
996+
bool CollectAllRequiredPdscFiles();
944997
};
945998

946999
#endif // PROJMGRWORKER_H

tools/projmgr/src/ProjMgr.cpp

Lines changed: 60 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ ProjMgr::ProjMgr() :
6464
m_extGenerator(&m_parser),
6565
m_worker(&m_parser, &m_extGenerator),
6666
m_emitter(&m_parser, &m_worker),
67-
m_rpcServer(this),
67+
m_rpcServer(*this),
6868
m_checkSchema(false),
6969
m_missingPacks(false),
7070
m_updateRteFiles(true),
@@ -409,7 +409,8 @@ int ProjMgr::ProcessCommands() {
409409
return ErrorCode::ERROR;
410410
}
411411
} else if (m_command == "rpc") {
412-
// Launch 'rpc' server
412+
// Launch 'rpc' server over stdin/stdout
413+
ProjMgrLogger::m_silent = true;
413414
if (!m_rpcServer.Run()) {
414415
return ErrorCode::ERROR;
415416
}
@@ -598,31 +599,8 @@ bool ProjMgr::Configure() {
598599
ProjMgrLogger::Get().Error(errMsg);
599600
}
600601

601-
// Get context pointers
602-
map<string, ContextItem>* contexts = nullptr;
603-
m_worker.GetContexts(contexts);
604-
605-
vector<string> orderedContexts;
606-
m_worker.GetYmlOrderedContexts(orderedContexts);
607-
608602
// Process contexts
609-
bool error = false;
610-
m_allContexts.clear();
611-
m_processedContexts.clear();
612-
m_failedContext.clear();
613-
for (auto& contextName : orderedContexts) {
614-
auto& contextItem = (*contexts)[contextName];
615-
m_allContexts.push_back(&contextItem);
616-
if (!m_worker.IsContextSelected(contextName)) {
617-
continue;
618-
}
619-
if (!m_worker.ProcessContext(contextItem, true, true, false)) {
620-
ProjMgrLogger::Get().Error("processing context '" + contextName + "' failed", contextName);
621-
m_failedContext.insert(contextItem.name);
622-
error = true;
623-
}
624-
m_processedContexts.push_back(&contextItem);
625-
}
603+
bool error = !ProcessContexts();
626604

627605
if (m_worker.HasToolchainErrors()) {
628606
error = true;
@@ -663,6 +641,35 @@ bool ProjMgr::Configure() {
663641
return !error;
664642
}
665643

644+
bool ProjMgr::ProcessContexts() {
645+
// Get context pointers
646+
map<string, ContextItem>* contexts = nullptr;
647+
m_worker.GetContexts(contexts);
648+
649+
vector<string> orderedContexts;
650+
m_worker.GetYmlOrderedContexts(orderedContexts);
651+
652+
// Process contexts
653+
bool success = true;
654+
m_allContexts.clear();
655+
m_processedContexts.clear();
656+
m_failedContext.clear();
657+
for (auto& contextName : orderedContexts) {
658+
auto& contextItem = (*contexts)[contextName];
659+
m_allContexts.push_back(&contextItem);
660+
if (!m_worker.IsContextSelected(contextName)) {
661+
continue;
662+
}
663+
if (!m_worker.ProcessContext(contextItem, true, true, false)) {
664+
ProjMgrLogger::Get().Error("processing context '" + contextName + "' failed", contextName);
665+
m_failedContext.insert(contextItem.name);
666+
success = false;
667+
}
668+
m_processedContexts.push_back(&contextItem);
669+
}
670+
return success;
671+
}
672+
666673
bool ProjMgr::UpdateRte() {
667674
// Update the RTE files
668675
for (auto& contextItem : m_processedContexts) {
@@ -1125,3 +1132,30 @@ string ProjMgr::GetToolboxVersion(const string& toolboxDir) {
11251132
regex_match(manifestFile, matchResult, regEx);
11261133
return matchResult[1].str();
11271134
}
1135+
1136+
bool ProjMgr::LoadSolution(std::string csolution) {
1137+
if (!m_csolutionFile.empty()) {
1138+
m_parser.Clear();
1139+
m_extGenerator.Clear();
1140+
m_worker.Clear();
1141+
m_runDebug.Clear();
1142+
ProjMgrLogger::Get().Clear();
1143+
}
1144+
1145+
m_csolutionFile = csolution;
1146+
m_rootDir = RteUtils::ExtractFilePath(m_csolutionFile, false);
1147+
1148+
m_contextSet = true;
1149+
m_updateRteFiles = false;
1150+
1151+
if (!PopulateContexts()) {
1152+
return false;
1153+
}
1154+
if (!ParseAndValidateContexts()) {
1155+
return false;
1156+
}
1157+
if (!ProcessContexts()) {
1158+
return false;
1159+
}
1160+
return true;
1161+
}

0 commit comments

Comments
 (0)