Skip to content

Commit 553a26e

Browse files
Adding skipping default platform profile to dependency info
1 parent f8f2adb commit 553a26e

File tree

7 files changed

+164
-96
lines changed

7 files changed

+164
-96
lines changed

Include/runcpp2/Data/DependencyLinkProperty.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ namespace runcpp2
2626
std::unordered_map<ProfileName, ProfileLinkProperty> ProfileProperties;
2727

2828
bool ParseYAML_Node(ryml::ConstNodeRef node);
29+
bool ParseYAML_NodeWithProfile(ryml::ConstNodeRef node, ProfileName profile);
30+
bool IsYAML_NodeParsableAsDefault(ryml::ConstNodeRef node) const;
2931
std::string ToString(std::string indentation) const;
3032
bool Equals(const DependencyLinkProperty& other) const;
3133
};

Include/runcpp2/Data/FilesToCopyInfo.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ namespace runcpp2
1717
std::unordered_map<ProfileName, std::vector<std::string>> ProfileFiles;
1818

1919
bool ParseYAML_Node(ryml::ConstNodeRef node);
20+
bool ParseYAML_NodeWithProfile(ryml::ConstNodeRef node, ProfileName profile);
21+
bool IsYAML_NodeParsableAsDefault(ryml::ConstNodeRef node) const;
2022
std::string ToString(std::string indentation) const;
2123
bool Equals(const FilesToCopyInfo& other) const;
2224
};

Src/runcpp2/Data/DependencyInfo.cpp

Lines changed: 24 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Src/runcpp2/Data/DependencyLinkProperty.cpp

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
bool runcpp2::Data::DependencyLinkProperty::ParseYAML_Node(ryml::ConstNodeRef node)
77
{
8+
ssLOG_FUNC_DEBUG();
89
INTERNAL_RUNCPP2_SAFE_START();
910

1011
if(!node.is_map())
@@ -66,6 +67,87 @@ bool runcpp2::Data::DependencyLinkProperty::ParseYAML_Node(ryml::ConstNodeRef no
6667
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(false);
6768
}
6869

70+
bool runcpp2::Data::DependencyLinkProperty::ParseYAML_NodeWithProfile( ryml::ConstNodeRef node,
71+
ProfileName profile)
72+
{
73+
ssLOG_FUNC_DEBUG();
74+
INTERNAL_RUNCPP2_SAFE_START();
75+
76+
ProfileLinkProperty& property = ProfileProperties[profile];
77+
78+
std::vector<NodeRequirement> requirements =
79+
{
80+
NodeRequirement("SearchLibraryNames", ryml::NodeType_e::SEQ, true, false),
81+
NodeRequirement("SearchDirectories", ryml::NodeType_e::SEQ, true, false),
82+
NodeRequirement("ExcludeLibraryNames", ryml::NodeType_e::SEQ, false, true),
83+
NodeRequirement("AdditionalLinkOptions", ryml::NodeType_e::SEQ, false, true)
84+
};
85+
86+
if(!CheckNodeRequirements(node, requirements))
87+
{
88+
ssLOG_ERROR("DependencyLinkProperty: Failed to meet requirements for profile " <<
89+
profile);
90+
return false;
91+
}
92+
93+
for(int i = 0; i < node["SearchLibraryNames"].num_children(); ++i)
94+
property.SearchLibraryNames.push_back(GetValue(node["SearchLibraryNames"][i]));
95+
96+
for(int i = 0; i < node["SearchDirectories"].num_children(); ++i)
97+
property.SearchDirectories.push_back(GetValue(node["SearchDirectories"][i]));
98+
99+
if(ExistAndHasChild(node, "ExcludeLibraryNames"))
100+
{
101+
for(int i = 0; i < node["ExcludeLibraryNames"].num_children(); ++i)
102+
{
103+
property.ExcludeLibraryNames
104+
.push_back(GetValue(node["ExcludeLibraryNames"][i]));
105+
106+
}
107+
}
108+
109+
if(ExistAndHasChild(node, "AdditionalLinkOptions"))
110+
{
111+
for(int i = 0; i < node["AdditionalLinkOptions"].num_children(); ++i)
112+
{
113+
property.AdditionalLinkOptions
114+
.push_back(GetValue(node["AdditionalLinkOptions"][i]));
115+
}
116+
}
117+
118+
ProfileProperties[profile] = property;
119+
120+
return true;
121+
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(false);
122+
}
123+
124+
bool
125+
runcpp2::Data::DependencyLinkProperty::IsYAML_NodeParsableAsDefault(ryml::ConstNodeRef node) const
126+
{
127+
ssLOG_FUNC_DEBUG();
128+
INTERNAL_RUNCPP2_SAFE_START();
129+
130+
if(!INTERNAL_RUNCPP2_BIT_CONTANTS(node.type().type, ryml::NodeType_e::MAP))
131+
{
132+
ssLOG_ERROR("DependencyLinkProperty type requires a map");
133+
return false;
134+
}
135+
136+
if(ExistAndHasChild(node, "SearchLibraryNames") && ExistAndHasChild(node, "SearchDirectories"))
137+
{
138+
std::vector<NodeRequirement> requirements =
139+
{
140+
NodeRequirement("SearchLibraryNames", ryml::NodeType_e::SEQ, true, false),
141+
NodeRequirement("SearchDirectories", ryml::NodeType_e::SEQ, true, false)
142+
};
143+
144+
return CheckNodeRequirements(node, requirements);
145+
}
146+
147+
return false;
148+
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(false);
149+
}
150+
69151
std::string runcpp2::Data::DependencyLinkProperty::ToString(std::string indentation) const
70152
{
71153
std::string out;

Src/runcpp2/Data/FilesToCopyInfo.cpp

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
bool runcpp2::Data::FilesToCopyInfo::ParseYAML_Node(ryml::ConstNodeRef node)
66
{
7+
ssLOG_FUNC_DEBUG();
78
INTERNAL_RUNCPP2_SAFE_START();
89

910
if(!node.is_map())
@@ -12,24 +13,59 @@ bool runcpp2::Data::FilesToCopyInfo::ParseYAML_Node(ryml::ConstNodeRef node)
1213
return false;
1314
}
1415

15-
for(int i = 0; i < node.num_children(); i++)
16+
//If we skip platform profile
17+
if(IsYAML_NodeParsableAsDefault(node))
1618
{
17-
if(!node[i].is_seq())
18-
{
19-
ssLOG_ERROR("FilesToCopyInfo: Node is not a sequence");
19+
if(!ParseYAML_NodeWithProfile(node, "DefaultProfile"))
2020
return false;
21+
}
22+
else
23+
{
24+
for(int i = 0; i < node.num_children(); i++)
25+
{
26+
ProfileName profile = GetKey(node[i]);
27+
if(!ParseYAML_NodeWithProfile(node[i], profile))
28+
return false;
2129
}
22-
23-
ProfileName profile = GetKey(node[i]);
24-
for(int j = 0; j < node[i].num_children(); j++)
25-
ProfileFiles[profile].push_back(GetValue(node[i][j]));
2630
}
2731

2832
return true;
2933

3034
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(false);
3135
}
3236

37+
bool runcpp2::Data::FilesToCopyInfo::ParseYAML_NodeWithProfile( ryml::ConstNodeRef node,
38+
ProfileName profile)
39+
{
40+
ssLOG_FUNC_DEBUG();
41+
INTERNAL_RUNCPP2_SAFE_START();
42+
43+
if(!INTERNAL_RUNCPP2_BIT_CONTANTS(node.type().type, ryml::NodeType_e::SEQ))
44+
{
45+
ssLOG_ERROR("FilesToCopyInfo: Node is not a sequence");
46+
return false;
47+
}
48+
49+
for(int i = 0; i < node.num_children(); i++)
50+
ProfileFiles[profile].push_back(GetValue(node[i]));
51+
52+
return true;
53+
54+
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(false);
55+
}
56+
57+
bool runcpp2::Data::FilesToCopyInfo::IsYAML_NodeParsableAsDefault(ryml::ConstNodeRef node) const
58+
{
59+
ssLOG_FUNC_DEBUG();
60+
INTERNAL_RUNCPP2_SAFE_START();
61+
62+
if(!INTERNAL_RUNCPP2_BIT_CONTANTS(node.type().type, ryml::NodeType_e::SEQ))
63+
return false;
64+
65+
return true;
66+
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(false);
67+
}
68+
3369
std::string runcpp2::Data::FilesToCopyInfo::ToString(std::string indentation) const
3470
{
3571
std::string out;

Src/runcpp2/Data/FlagsOverrideInfo.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
bool runcpp2::Data::FlagsOverrideInfo::ParseYAML_Node(ryml::ConstNodeRef node)
77
{
8+
ssLOG_FUNC_DEBUG();
89
INTERNAL_RUNCPP2_SAFE_START();
910

1011
std::vector<NodeRequirement> requirements =
@@ -32,7 +33,15 @@ bool runcpp2::Data::FlagsOverrideInfo::ParseYAML_Node(ryml::ConstNodeRef node)
3233

3334
bool runcpp2::Data::FlagsOverrideInfo::IsYAML_NodeParsableAsDefault(ryml::ConstNodeRef node) const
3435
{
36+
ssLOG_FUNC_DEBUG();
3537
INTERNAL_RUNCPP2_SAFE_START();
38+
39+
if(!INTERNAL_RUNCPP2_BIT_CONTANTS(node.type().type, ryml::NodeType_e::MAP))
40+
{
41+
ssLOG_ERROR("FlagsOverrideInfo type requires a map");
42+
return false;
43+
}
44+
3645
if(ExistAndHasChild(node, "Remove") || ExistAndHasChild(node, "Append"))
3746
{
3847
std::vector<NodeRequirement> requirements =

Src/runcpp2/Data/ProfilesCommands.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
bool runcpp2::Data::ProfilesCommands::ParseYAML_Node(ryml::ConstNodeRef node)
77
{
8+
ssLOG_FUNC_DEBUG();
89
INTERNAL_RUNCPP2_SAFE_START();
910

1011
if(!node.is_map())

0 commit comments

Comments
 (0)