@@ -40,11 +40,14 @@ bool runcpp2::Data::DependencyInfo::ParseYAML_Node(ryml::ConstNodeRef node)
4040 NodeRequirement (" Source" , ryml::NodeType_e::MAP, true , false ),
4141 NodeRequirement (" LibraryType" , ryml::NodeType_e::KEYVAL, true , false ),
4242 NodeRequirement (" IncludePaths" , ryml::NodeType_e::SEQ, false , true ),
43+
44+ // Expecting either platform profile map or ProfileLinkProperty map
4345 NodeRequirement (" LinkProperties" , ryml::NodeType_e::MAP, false , false ),
44- NodeRequirement (" Setup" , ryml::NodeType_e::MAP, false , true ),
45- NodeRequirement (" Cleanup" , ryml::NodeType_e::MAP, false , true ),
46- NodeRequirement (" Build" , ryml::NodeType_e::MAP, false , true ),
47- NodeRequirement (" FilesToCopy" , ryml::NodeType_e::MAP, false , true )
46+
47+ // Setup can be platform profile map or sequence of commands, handle later
48+ // Cleanup can be platform profile map or sequence of commands, handle later
49+ // Build can be platform profile map or sequence of commands, handle later
50+ // FilesToCopy can be platform profile map or sequence of paths, handle later
4851 };
4952
5053 if (!CheckNodeRequirements (node, requirements))
@@ -91,22 +94,12 @@ bool runcpp2::Data::DependencyInfo::ParseYAML_Node(ryml::ConstNodeRef node)
9194
9295 if (ExistAndHasChild (node, " LinkProperties" ))
9396 {
94- ryml::ConstNodeRef linkPropertiesNode = node[" LinkProperties" ];
95-
96- for (int i = 0 ; i < linkPropertiesNode.num_children (); ++i)
97+ if (!ParsePlatformProfileMap<DependencyLinkProperty>(node,
98+ " LinkProperties" ,
99+ LinkProperties,
100+ " LinkProperties" ))
97101 {
98- PlatformName platform = GetKey (linkPropertiesNode[i]);
99- ryml::ConstNodeRef platformNode = linkPropertiesNode[i];
100-
101- // Insert an empty DependencyLinkProperty and get a reference to it
102- DependencyLinkProperty& linkProperty = LinkProperties[platform];
103-
104- if (!linkProperty.ParseYAML_Node (platformNode))
105- {
106- ssLOG_ERROR (" DependencyInfo: Failed to parse LinkProperties for platform " <<
107- platform);
108- return false ;
109- }
102+ return false ;
110103 }
111104 }
112105 else if (LibraryType != DependencyLibraryType::HEADER)
@@ -115,75 +108,18 @@ bool runcpp2::Data::DependencyInfo::ParseYAML_Node(ryml::ConstNodeRef node)
115108 Data::DependencyLibraryTypeToString (LibraryType));
116109 return false ;
117110 }
118-
119- if (ExistAndHasChild (node, " Setup" ))
120- {
121- for (int i = 0 ; i < node[" Setup" ].num_children (); ++i)
122- {
123- ProfilesCommands currentSetup;
124- ryml::ConstNodeRef currentSetupNode = node[" Setup" ][i];
125-
126- if (!currentSetup.ParseYAML_Node (currentSetupNode))
127- {
128- ssLOG_ERROR (" DependencyInfo: Failed to parse Setup" );
129- return false ;
130- }
131-
132- Setup[GetKey (node[" Setup" ][i])] = currentSetup;
133- }
134- }
135-
136- if (ExistAndHasChild (node, " Cleanup" ))
137- {
138- for (int i = 0 ; i < node[" Cleanup" ].num_children (); ++i)
139- {
140- ProfilesCommands currentCleanup;
141- ryml::ConstNodeRef currentCleanupNode = node[" Cleanup" ][i];
142-
143- if (!currentCleanup.ParseYAML_Node (currentCleanupNode))
144- {
145- ssLOG_ERROR (" DependencyInfo: Failed to parse Cleanup" );
146- return false ;
147- }
148-
149- Cleanup[GetKey (node[" Cleanup" ][i])] = currentCleanup;
150- }
151- }
152-
153- if (ExistAndHasChild (node, " Build" ))
154- {
155- for (int i = 0 ; i < node[" Build" ].num_children (); ++i)
156- {
157- ProfilesCommands currentBuild;
158- ryml::ConstNodeRef currentBuildNode = node[" Build" ][i];
159-
160- if (!currentBuild.ParseYAML_Node (currentBuildNode))
161- {
162- ssLOG_ERROR (" DependencyInfo: Failed to parse Build" );
163- return false ;
164- }
165-
166- Build[GetKey (node[" Build" ][i])] = currentBuild;
167- }
168- }
169-
170- if (ExistAndHasChild (node, " FilesToCopy" ))
171- {
172- for (int i = 0 ; i < node[" FilesToCopy" ].num_children (); ++i)
173- {
174- FilesToCopyInfo currentFilesToCopy;
175- ryml::ConstNodeRef currentFilesToCopyNode = node[" FilesToCopy" ][i];
176- PlatformName platform = GetKey (currentFilesToCopyNode);
177-
178- if (!currentFilesToCopy.ParseYAML_Node (currentFilesToCopyNode))
179- {
180- ssLOG_ERROR (" DependencyInfo: Failed to parse FilesToCopy" );
181- return false ;
182- }
183-
184- FilesToCopy[platform] = currentFilesToCopy;
185- }
186- }
111+
112+ if (!ParsePlatformProfileMap<ProfilesCommands>(node, " Setup" , Setup, " Setup" ))
113+ return false ;
114+
115+ if (!ParsePlatformProfileMap<ProfilesCommands>(node, " Cleanup" , Cleanup, " Cleanup" ))
116+ return false ;
117+
118+ if (!ParsePlatformProfileMap<ProfilesCommands>(node, " Build" , Build, " Build" ))
119+ return false ;
120+
121+ if (!ParsePlatformProfileMap<FilesToCopyInfo>(node, " FilesToCopy" , FilesToCopy, " FilesToCopy" ))
122+ return false ;
187123
188124 return true ;
189125
0 commit comments