@@ -22,7 +22,7 @@ class ProjMgrCbuildIdx : public ProjMgrCbuildBase {
2222 const map<string, ExecutesItem>& executes);
2323private:
2424 void SetExecutesNode (YAML ::Node node, const map<string, ExecutesItem>& executes, const string& base, const string& ref);
25- void SetVariablesNode (YAML ::Node node, ProjMgrParser* parser, const ContextItem* context, const map<string, map<string, set< const ConnectItem*>>>& layerTypes );
25+ void SetVariablesNode (YAML ::Node node, ProjMgrParser* parser, const ContextItem* context, const VariablesConfiguration& configuration );
2626};
2727
2828ProjMgrCbuildIdx::ProjMgrCbuildIdx (YAML ::Node node,
@@ -64,37 +64,17 @@ ProjMgrCbuildIdx::ProjMgrCbuildIdx(YAML::Node node,
6464 }
6565
6666 // Collect layer connection info specific to each target
67- if (context->validConnections . size () > 0 ) {
67+ if (! context->variablesConfigurations . empty () ) {
6868 configTargets.push_back (context->type .target );
69- map<int , map<string, map<string, set<const ConnectItem*>>>> configurations;
70- int index = 0 ;
71- for (const auto & combination : context->validConnections ) {
72- index++;
73- for (const auto & item : combination) {
74- if (item.type .empty ())
75- continue ;
76- for (const auto & [type, _] : context->compatibleLayers ) {
77- // add all required layer types, including discarded optionals
78- configurations[index][type].insert ({});
79- }
80- for (const auto & connect : item.connections ) {
81- configurations[index][item.type ][item.filename ].insert (connect);
82- }
83- }
84- }
85-
86- // Process connection info and generate nodes
87- if (configurations.size () > 0 ) {
88- YAML ::Node targetTypeNode;
89- SetNodeValue (targetTypeNode[YAML_TARGETTYPE ], context->type .target );
90- for (const auto & [index, types] : configurations) {
91- YAML ::Node configurationsNode;
92- configurationsNode[YAML_CONFIGURATION ] = YAML ::Null;
93- SetVariablesNode (configurationsNode[YAML_VARIABLES ], parser, context, types);
94- targetTypeNode[YAML_TARGET_CONFIGURATIONS ].push_back (configurationsNode);
95- }
96- node[YAML_CONFIGURATIONS ].push_back (targetTypeNode);
69+ YAML ::Node targetTypeNode;
70+ SetNodeValue (targetTypeNode[YAML_TARGETTYPE ], context->type .target );
71+ for (const auto & configuration : context->variablesConfigurations ) {
72+ YAML ::Node configurationsNode;
73+ configurationsNode[YAML_CONFIGURATION ] = YAML ::Null;
74+ SetVariablesNode (configurationsNode[YAML_VARIABLES ], parser, context, configuration);
75+ targetTypeNode[YAML_TARGET_CONFIGURATIONS ].push_back (configurationsNode);
9776 }
77+ node[YAML_CONFIGURATIONS ].push_back (targetTypeNode);
9878 }
9979 }
10080
@@ -206,53 +186,22 @@ ProjMgrCbuildIdx::ProjMgrCbuildIdx(YAML::Node node,
206186}
207187
208188void ProjMgrCbuildIdx::SetVariablesNode (YAML ::Node node, ProjMgrParser* parser, const ContextItem* context,
209- const map<string, map<string, set<const ConnectItem*>>>& layerTypes) {
210- for (const auto & [type, filenames] : layerTypes) {
211- if (type.empty ()) {
212- continue ;
213- }
189+ const VariablesConfiguration& configuration) {
190+ for (const auto & variable : configuration.variables ) {
214191 YAML ::Node layerNode;
215- string layerFile;
216- const string layerId = context->layerVariables .find (type) != context->layerVariables .end () ?
217- context->layerVariables .at (type) : type + " -Layer" ;
218- if (filenames.empty ()) {
219- layerNode[layerId] = " " ;
192+ if (variable.clayer .empty ()) {
193+ layerNode[variable.name ] = " " ;
220194 }
221- for (const auto & [filename, options] : filenames) {
222- string packRoot = ProjMgrKernel::Get ()->GetCmsisPackRoot ();
223- layerFile = filename;
224- RteFsUtils::NormalizePath (layerFile);
225- layerFile = RteFsUtils::MakePathCanonical (layerFile);
226- // Replace with ${CMSIS_PACK_ROOT} or $SolutionDir()$ depending on the detected path
227- size_t index = layerFile.find (packRoot);
228- if (index != string::npos) {
229- layerFile.replace (index, packRoot.length (), " ${CMSIS_PACK_ROOT}" );
230- }
231- else {
232- string relPath = RteFsUtils::RelativePath (filename, context->csolution ->directory );
233- if (!relPath.empty ()) {
234- layerFile = " $" + string (RteConstants::AS_SOLUTION_DIR_BR ) + " $/" + RteFsUtils::LexicallyNormal (relPath);
235- }
236- }
237- SetNodeValue (layerNode[layerId], layerFile);
238- if (parser->GetGenericClayers ().find (filename) != parser->GetGenericClayers ().end ()) {
239- const auto & clayer = parser->GetGenericClayers ().at (filename);
240- SetNodeValue (layerNode[YAML_DESCRIPTION ], clayer.description );
241- }
242- for (const auto & connect : options) {
243- if (!connect->set .empty ()) {
244- YAML ::Node setNode;
245- SetNodeValue (setNode[YAML_SET ], connect->set + " (" + connect->connect + (connect->info .empty () ? " " : " - " + connect->info ) + " )" );
246- layerNode[YAML_SETTINGS ].push_back (setNode);
247- }
248- }
249- if (context->packLayers .find (filename) != context->packLayers .end ()) {
250- const auto & clayer = context->packLayers .at (filename);
251- SetNodeValue (layerNode[YAML_PATH ], clayer->GetOriginalAbsolutePath (clayer->GetPathString ()));
252- SetNodeValue (layerNode[YAML_FILE ], clayer->GetFileString ());
253- SetNodeValue (layerNode[YAML_COPY_TO ], clayer->GetCopyToString ());
254- }
195+ SetNodeValue (layerNode[variable.name ], variable.clayer );
196+ SetNodeValue (layerNode[YAML_DESCRIPTION ], variable.description );
197+ for (const auto & setting : variable.settings ) {
198+ YAML ::Node setNode;
199+ SetNodeValue (setNode[YAML_SET ], setting.set );
200+ layerNode[YAML_SETTINGS ].push_back (setNode);
255201 }
202+ SetNodeValue (layerNode[YAML_PATH ], variable.path );
203+ SetNodeValue (layerNode[YAML_FILE ], variable.file );
204+ SetNodeValue (layerNode[YAML_COPY_TO ], variable.copyTo );
256205 node.push_back (layerNode);
257206 }
258207}
0 commit comments