Skip to content

Commit 5e8b336

Browse files
authored
LoadPacks without context (#1255)
Does not require global ContextItem Clear() is added to ProjMgr
1 parent 57988df commit 5e8b336

File tree

5 files changed

+23
-15
lines changed

5 files changed

+23
-15
lines changed

tools/projmgr/include/ProjMgr.h

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

60+
/**
61+
* @brief clear internal structures and worker object
62+
*/
63+
void Clear();
64+
6065
/**
6166
* @brief load solution
6267
* @param path to <solution>.csolution.yml file

tools/projmgr/include/ProjMgrWorker.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ struct ValidationResult {
269269
std::vector<ValidationCondition> conditions;
270270
};
271271

272-
/**
272+
/**
273273
* @brief gdb server item containing
274274
* port number of processor
275275
* processor name
@@ -922,7 +922,7 @@ class ProjMgrWorker {
922922
}
923923
m_contexts.clear();
924924
m_ymlOrderedContexts.clear();
925-
m_contextsPtr->clear();
925+
m_contexts.clear();
926926
m_contextErrMap.clear();
927927
m_selectedContexts.clear();
928928
m_outputDir.clear();
@@ -951,7 +951,6 @@ class ProjMgrWorker {
951951
std::map<std::string, StrMap> m_regToolchainsEnvVars;
952952
std::vector<std::string> m_ymlOrderedContexts;
953953
std::map<std::string, ContextItem> m_contexts;
954-
std::map<std::string, ContextItem>* m_contextsPtr;
955954
std::map<std::string, std::set<std::string>> m_contextErrMap;
956955
std::vector<std::string> m_selectedContexts;
957956
std::string m_outputDir;

tools/projmgr/src/ProjMgr.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,14 +1170,16 @@ const string ProjMgr::GetToolboxVersion(const string& toolboxDir) {
11701170
return matchResult[1].str();
11711171
}
11721172

1173+
void ProjMgr::Clear() {
1174+
m_parser.Clear();
1175+
m_extGenerator.Clear();
1176+
m_worker.Clear();
1177+
m_runDebug.Clear();
1178+
ProjMgrLogger::Get().Clear();
1179+
}
1180+
11731181
bool ProjMgr::LoadSolution(const std::string& csolution) {
1174-
if (!m_csolutionFile.empty()) {
1175-
m_parser.Clear();
1176-
m_extGenerator.Clear();
1177-
m_worker.Clear();
1178-
m_runDebug.Clear();
1179-
ProjMgrLogger::Get().Clear();
1180-
}
1182+
Clear();
11811183

11821184
m_csolutionFile = csolution;
11831185
m_rootDir = RteUtils::ExtractFilePath(m_csolutionFile, false);

tools/projmgr/src/ProjMgrRpcServer.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,13 @@ RpcArgs::UsedItems RpcHandler::GetUsedItems(const string& context) {
220220
}
221221

222222
bool RpcHandler::LoadPacks(void) {
223+
m_manager.Clear();
224+
m_solutionLoaded = false;
225+
m_worker.InitializeModel();
223226
m_worker.SetLoadPacksPolicy(LoadPacksPolicy::ALL);
224-
m_packsLoaded = m_worker.LoadPacks(m_globalContext);
227+
m_packsLoaded = m_worker.LoadAllRelevantPacks();
225228
m_worker.SetLoadPacksPolicy(LoadPacksPolicy::DEFAULT);
226-
if (!m_packsLoaded) {
229+
if(!m_packsLoaded) {
227230
throw JsonRpcException(PACKS_LOADING_FAIL, "packs failed to load");
228231
}
229232
return true;
@@ -256,7 +259,7 @@ RpcArgs::PacksInfo RpcHandler::GetPacksInfo(const string& context) {
256259
}
257260

258261
RpcArgs::PacksInfo packsInfo;
259-
for (auto& [pack, packItem] : m_globalContext.rteActiveTarget->GetFilteredModel()->GetPackages()) {
262+
for (auto& [pack, packItem] : contextItem.rteActiveTarget->GetFilteredModel()->GetPackages()) {
260263
RpcArgs::Pack p;
261264
p.id = packItem->GetPackageID(true);
262265
const auto& description = packItem->GetDescription();

tools/projmgr/src/ProjMgrWorker.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,7 @@ bool ProjMgrWorker::ParseContextLayers(ContextItem& context) {
229229
}
230230

231231
void ProjMgrWorker::GetContexts(map<string, ContextItem>* &contexts) {
232-
m_contextsPtr = &m_contexts;
233-
contexts = m_contextsPtr;
232+
contexts = &m_contexts;
234233
}
235234

236235
void ProjMgrWorker::GetYmlOrderedContexts(vector<string> &contexts) {

0 commit comments

Comments
 (0)