66
77#include " ProjMgrMlops.h"
88
9- #include " ProjMgrLogger.h"
109#include " ProjMgrParser.h"
1110#include " ProjMgrUtils.h"
1211
@@ -27,7 +26,6 @@ bool ProjMgrMlops::FindTargetType(const CsolutionItem& csolution, const string&
2726 return true ;
2827 }
2928 }
30- ProjMgrLogger::Get ().Error (" mlops: target-type '" + typeName + " ' not found" );
3129 return false ;
3230}
3331
@@ -41,7 +39,6 @@ bool ProjMgrMlops::GetTargetSetItemRef(const TargetType& targetType, const strin
4139 return true ;
4240 }
4341 }
44- ProjMgrLogger::Get ().Error (" mlops: simulator target with debugger 'Arm-FVP' not found" );
4542 return false ;
4643 }
4744 if (!targetType.targetSet .empty ()) {
@@ -56,8 +53,6 @@ bool ProjMgrMlops::GetTargetSetItemRef(const TargetType& targetType, const strin
5653 }
5754 }
5855 }
59- ProjMgrLogger::Get ().Error (" mlops: target-type '" + targetTypeName + " ' target-set '" +
60- (targetSetName.empty () ? " <default>" : targetSetName) + " ' not found" );
6156 return false ;
6257}
6358
@@ -91,6 +86,20 @@ string ProjMgrMlops::BuildVelaOptions(const MlopsNpuType& npu, const MlopsVelaIt
9186 return options;
9287}
9388
89+ bool ProjMgrMlops::ResolveMlopsPath (string& path, const string& solutionDir,
90+ bool hardwareFound, ContextItem& hardwareContext) const {
91+ if (hardwareFound && !m_worker->ProcessSequenceRelative (hardwareContext, path, solutionDir, false )) {
92+ return false ;
93+ }
94+ if (ProjMgrUtils::HasAccessSequence (path)) {
95+ path.clear ();
96+ } else if (RteFsUtils::IsRelative (path)) {
97+ const auto & baseDir = hardwareFound ? hardwareContext.directories .cprj : solutionDir;
98+ RteFsUtils::NormalizePath (path, baseDir);
99+ }
100+ return true ;
101+ }
102+
94103void ProjMgrMlops::SetMlopsRunType (MlopsRunType& run, const string& targetType, const string& targetSet,
95104 const vector<ContextItem>& contexts, const string& outBaseDir, const string& solutionName) const {
96105 run.active = BuildActive (targetType, targetSet);
@@ -119,17 +128,15 @@ bool ProjMgrMlops::CollectSettings(const CsolutionItem& csolution, MlopsType& ml
119128 // get hardware set
120129 TargetType hardwareTargetType;
121130 TargetSetItem hardwareTargetSet;
122- if (!FindTargetType (csolution, hardwareType, hardwareTargetType) ||
123- !GetTargetSetItemRef (hardwareTargetType, hardwareType, solutionMlops.hardware .targetSet , false , hardwareTargetSet)) {
124- return false ;
131+ if (FindTargetType (csolution, hardwareType, hardwareTargetType)) {
132+ GetTargetSetItemRef (hardwareTargetType, hardwareType, solutionMlops.hardware .targetSet , false , hardwareTargetSet);
125133 }
126134
127135 // get simulator set
128136 TargetType simulatorTargetType;
129137 TargetSetItem simulatorTargetSet;
130- if (!FindTargetType (csolution, simulatorType, simulatorTargetType) ||
131- !GetTargetSetItemRef (simulatorTargetType, simulatorType, solutionMlops.simulator .targetSet , true , simulatorTargetSet)) {
132- return false ;
138+ if (FindTargetType (csolution, simulatorType, simulatorTargetType)) {
139+ GetTargetSetItemRef (simulatorTargetType, simulatorType, solutionMlops.simulator .targetSet , true , simulatorTargetSet);
133140 }
134141
135142 // get all context items
@@ -164,20 +171,11 @@ bool ProjMgrMlops::CollectSettings(const CsolutionItem& csolution, MlopsType& ml
164171 }
165172
166173 // check if hardware and simulator contexts were found
167- vector<tuple<const vector<ContextItem>&, const string&, const string&>> contextRefs = {
168- {hardwareContexts, hardwareType, hardwareTargetSet.set },
169- {simulatorContexts, simulatorType, simulatorTargetSet.set }
170- };
171- for (const auto & [ref, targetType, targetSet] : contextRefs) {
172- if (ref.empty ()) {
173- ProjMgrLogger::Get ().Error (" mlops: target-type '" + targetType + " ' target-set '" +
174- (targetSet.empty () ? " <default>" : targetSet) + " ' project-contexts not found" );
175- return false ;
176- }
177- }
178-
179- auto & hardwareContext = hardwareContexts.front ();
180- auto & simulatorContext = simulatorContexts.front ();
174+ bool hardwareFound = !hardwareContexts.empty ();
175+ bool simulatorFound = !simulatorContexts.empty ();
176+ ContextItem defaultContext;
177+ ContextItem& hardwareContext = hardwareFound ? hardwareContexts.front () : defaultContext;
178+ ContextItem& simulatorContext = simulatorFound ? simulatorContexts.front () : defaultContext;
181179
182180 // mlops description
183181 mlops.description = solutionMlops.description ;
@@ -244,40 +242,41 @@ bool ProjMgrMlops::CollectSettings(const CsolutionItem& csolution, MlopsType& ml
244242 } else {
245243 // explicit vela ini
246244 mlops.vela .ini = solutionMlops.vela .ini ;
247- if (!m_worker-> ProcessSequenceRelative (hardwareContext, mlops.vela .ini , csolution.directory , false )) {
245+ if (!ResolveMlopsPath ( mlops.vela .ini , csolution.directory , hardwareFound, hardwareContext )) {
248246 return false ;
249247 }
250- if (RteFsUtils::IsRelative (mlops.vela .ini )) {
251- RteFsUtils::NormalizePath (mlops.vela .ini , hardwareContext.directories .cprj );
252- }
253248 }
254-
249+
255250 // model name and clayer
256251 if (!solutionMlops.model .clayer .empty ()) {
257252 mlops.model .name = solutionMlops.model .name .empty () ? " Algorithm" : solutionMlops.model .name ;
258253 mlops.model .clayer = solutionMlops.model .clayer ;
259- if (!m_worker-> ProcessSequenceRelative (hardwareContext, mlops.model .clayer , csolution.directory , false )) {
254+ if (!ResolveMlopsPath ( mlops.model .clayer , csolution.directory , hardwareFound, hardwareContext )) {
260255 return false ;
261- }
262- if (RteFsUtils::IsRelative (mlops.model .clayer )) {
263- RteFsUtils::NormalizePath (mlops.model .clayer , hardwareContext.directories .cprj );
264- }
256+ }
265257 }
266258
267- // set hardware and simulator run types
268- const string outBaseDir = hardwareContext.directories .cprj + " /" + hardwareContext.directories .outBaseDir ;
269- SetMlopsRunType (mlops.hardware , hardwareType, hardwareTargetSet.set , hardwareContexts, outBaseDir, csolution.name );
270- SetMlopsRunType (mlops.simulator , simulatorType, simulatorTargetSet.set , simulatorContexts, outBaseDir, csolution.name );
259+ if (hardwareFound) {
260+ // set hardware run types
261+ const string outBaseDir = hardwareContext.directories .cprj + " /" + hardwareContext.directories .outBaseDir ;
262+ SetMlopsRunType (mlops.hardware , hardwareType, hardwareTargetSet.set , hardwareContexts, outBaseDir, csolution.name );
263+ }
271264
272- // get debugger model and config-file
273- mlops.simulator .model = GetCustomScalar (simulatorTargetSet.debugger .custom , " model" );
274- mlops.simulator .configFile = GetCustomScalar (simulatorTargetSet.debugger .custom , " config-file" );
275- if (!mlops.simulator .configFile .empty ()) {
276- if (!m_worker->ProcessSequenceRelative (simulatorContext, mlops.simulator .configFile , csolution.directory , false )) {
277- return false ;
278- }
279- if (RteFsUtils::IsRelative (mlops.simulator .configFile )) {
280- RteFsUtils::NormalizePath (mlops.simulator .configFile , simulatorContext.directories .cprj );
265+ if (simulatorFound) {
266+ // set simulator run types
267+ const string outBaseDir = simulatorContext.directories .cprj + " /" + simulatorContext.directories .outBaseDir ;
268+ SetMlopsRunType (mlops.simulator , simulatorType, simulatorTargetSet.set , simulatorContexts, outBaseDir, csolution.name );
269+
270+ // get debugger model and config-file
271+ mlops.simulator .model = GetCustomScalar (simulatorTargetSet.debugger .custom , " model" );
272+ mlops.simulator .configFile = GetCustomScalar (simulatorTargetSet.debugger .custom , " config-file" );
273+ if (!mlops.simulator .configFile .empty ()) {
274+ if (!m_worker->ProcessSequenceRelative (simulatorContext, mlops.simulator .configFile , csolution.directory , false )) {
275+ return false ;
276+ }
277+ if (RteFsUtils::IsRelative (mlops.simulator .configFile )) {
278+ RteFsUtils::NormalizePath (mlops.simulator .configFile , simulatorContext.directories .cprj );
279+ }
281280 }
282281 }
283282
0 commit comments