Skip to content

Commit a9839f3

Browse files
Initial implementation for skipping default platform profile pattern
1 parent ff88a9e commit a9839f3

File tree

11 files changed

+491
-173
lines changed

11 files changed

+491
-173
lines changed

Include/runcpp2/Data/ProfilesCommands.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ namespace runcpp2
1919
std::unordered_map<ProfileName, std::vector<std::string>> CommandSteps;
2020

2121
bool ParseYAML_Node(ryml::ConstNodeRef node);
22+
bool ParseYAML_NodeWithProfile(ryml::ConstNodeRef node, ProfileName profile);
23+
bool IsYAML_NodeParsableAsDefault(ryml::ConstNodeRef node) const;
2224
std::string ToString(std::string indentation) const;
2325
bool Equals(const ProfilesCommands& other) const;
2426
};

Include/runcpp2/Data/ProfilesDefines.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ namespace runcpp2
2525
std::unordered_map<ProfileName, std::vector<Define>> Defines;
2626

2727
bool ParseYAML_Node(ryml::ConstNodeRef node);
28+
bool ParseYAML_NodeWithProfile(ryml::ConstNodeRef node, ProfileName profile);
29+
bool IsYAML_NodeParsableAsDefault(ryml::ConstNodeRef node) const;
2830
std::string ToString(std::string indentation) const;
2931
bool Equals(const ProfilesDefines& other) const;
3032
};

Include/runcpp2/Data/ProfilesProcessPaths.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ namespace runcpp2
2222
std::unordered_map<ProfileName, std::vector<ghc::filesystem::path>> Paths;
2323

2424
bool ParseYAML_Node(ryml::ConstNodeRef node);
25+
bool ParseYAML_NodeWithProfile(ryml::ConstNodeRef node, ProfileName profile);
26+
bool IsYAML_NodeParsableAsDefault(ryml::ConstNodeRef node) const;
2527
std::string ToString(std::string indentation) const;
2628
bool Equals(const ProfilesProcessPaths& other) const;
2729
};

Include/runcpp2/ParseUtil.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ namespace runcpp2
2121
bool nullable);
2222
};
2323

24+
bool CheckNodeRequirement( ryml::ConstNodeRef node,
25+
const std::string name,
26+
ryml::NodeType nodeType,
27+
bool required,
28+
bool nullable);
29+
2430
bool CheckNodeRequirements( ryml::ConstNodeRef node,
2531
const std::vector<NodeRequirement>& requirements);
2632

Src/runcpp2/Data/FlagsOverrideInfo.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,27 @@ bool runcpp2::Data::FlagsOverrideInfo::ParseYAML_Node(ryml::ConstNodeRef node)
3030
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(false);
3131
}
3232

33+
bool runcpp2::Data::FlagsOverrideInfo::IsYAML_NodeParsableAsDefault(ryml::ConstNodeRef node) const
34+
{
35+
INTERNAL_RUNCPP2_SAFE_START();
36+
if(ExistAndHasChild(node, "Remove") || ExistAndHasChild(node, "Append"))
37+
{
38+
std::vector<NodeRequirement> requirements =
39+
{
40+
NodeRequirement("Remove", ryml::NodeType_e::KEYVAL, false, true),
41+
NodeRequirement("Append", ryml::NodeType_e::KEYVAL, false, true)
42+
};
43+
44+
if(!CheckNodeRequirements(node, requirements))
45+
return false;
46+
47+
return true;
48+
}
49+
50+
return false;
51+
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(false);
52+
}
53+
3354
std::string runcpp2::Data::FlagsOverrideInfo::ToString(std::string indentation) const
3455
{
3556
std::string out;

Src/runcpp2/Data/ProfilesCommands.cpp

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,44 @@ bool runcpp2::Data::ProfilesCommands::ParseYAML_Node(ryml::ConstNodeRef node)
1515

1616
for(int i = 0; i < node.num_children(); i++)
1717
{
18-
if(!node[i].is_seq())
19-
{
20-
ssLOG_ERROR("ProfilesCommands: Node is not a sequence");
21-
return false;
22-
}
23-
2418
ProfileName profile = GetKey(node[i]);
25-
for(int j = 0; j < node[i].num_children(); j++)
26-
CommandSteps[profile].push_back(GetValue(node[i][j]));
19+
if(!ParseYAML_NodeWithProfile(node[i], profile))
20+
return false;
21+
}
22+
23+
return true;
24+
25+
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(false);
26+
}
27+
28+
bool runcpp2::Data::ProfilesCommands::ParseYAML_NodeWithProfile(ryml::ConstNodeRef node,
29+
ProfileName profile)
30+
{
31+
ssLOG_FUNC_DEBUG();
32+
INTERNAL_RUNCPP2_SAFE_START();
33+
34+
if(!INTERNAL_RUNCPP2_BIT_CONTANTS(node.type().type, ryml::NodeType_e::SEQ))
35+
{
36+
ssLOG_ERROR("ProfilesDefines: Paths type requires a list");
37+
return false;
2738
}
2839

40+
for(int i = 0; i < node.num_children(); ++i)
41+
CommandSteps[profile].push_back(GetValue(node[i]));
42+
2943
return true;
44+
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(false);
45+
}
46+
47+
bool runcpp2::Data::ProfilesCommands::IsYAML_NodeParsableAsDefault(ryml::ConstNodeRef node) const
48+
{
49+
ssLOG_FUNC_DEBUG();
50+
INTERNAL_RUNCPP2_SAFE_START();
3051

52+
if(!INTERNAL_RUNCPP2_BIT_CONTANTS(node.type().type, ryml::NodeType_e::SEQ))
53+
return false;
54+
55+
return true;
3156
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(false);
3257
}
3358

Src/runcpp2/Data/ProfilesDefines.cpp

Lines changed: 48 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
bool runcpp2::Data::ProfilesDefines::ParseYAML_Node(ryml::ConstNodeRef node)
77
{
88
ssLOG_FUNC_DEBUG();
9-
109
INTERNAL_RUNCPP2_SAFE_START();
1110

1211
if(!node.is_map())
@@ -17,40 +16,63 @@ bool runcpp2::Data::ProfilesDefines::ParseYAML_Node(ryml::ConstNodeRef node)
1716

1817
for(int i = 0; i < node.num_children(); ++i)
1918
{
20-
if(!INTERNAL_RUNCPP2_BIT_CONTANTS(node[i].type().type, ryml::NodeType_e::SEQ))
21-
{
22-
ssLOG_ERROR("ProfilesDefines: Defines type requires a list");
23-
return false;
24-
}
25-
2619
ryml::ConstNodeRef currentProfileDefinesNode = node[i];
2720
ProfileName profile = GetKey(currentProfileDefinesNode);
21+
if(!ParseYAML_NodeWithProfile(currentProfileDefinesNode, profile))
22+
return false;
23+
}
24+
25+
return true;
26+
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(false);
27+
}
2828

29-
for(int j = 0; j < currentProfileDefinesNode.num_children(); ++j)
29+
bool runcpp2::Data::ProfilesDefines::ParseYAML_NodeWithProfile( ryml::ConstNodeRef node,
30+
ProfileName profile)
31+
{
32+
ssLOG_FUNC_DEBUG();
33+
INTERNAL_RUNCPP2_SAFE_START();
34+
35+
if(!INTERNAL_RUNCPP2_BIT_CONTANTS(node.type().type, ryml::NodeType_e::SEQ))
36+
{
37+
ssLOG_ERROR("ProfilesDefines: Paths type requires a list");
38+
return false;
39+
}
40+
41+
for(int i = 0; i < node.num_children(); ++i)
42+
{
43+
std::string defineStr = GetValue(node[i]);
44+
Define define;
45+
46+
size_t equalPos = defineStr.find('=');
47+
if(equalPos != std::string::npos)
3048
{
31-
std::string defineStr = GetValue(currentProfileDefinesNode[j]);
32-
Define define;
33-
34-
size_t equalPos = defineStr.find('=');
35-
if(equalPos != std::string::npos)
36-
{
37-
define.Name = defineStr.substr(0, equalPos);
38-
define.Value = defineStr.substr(equalPos + 1);
39-
define.HasValue = true;
40-
}
41-
else
42-
{
43-
define.Name = defineStr;
44-
define.Value = "";
45-
define.HasValue = false;
46-
}
47-
48-
Defines[profile].push_back(define);
49+
define.Name = defineStr.substr(0, equalPos);
50+
define.Value = defineStr.substr(equalPos + 1);
51+
define.HasValue = true;
52+
}
53+
else
54+
{
55+
define.Name = defineStr;
56+
define.Value = "";
57+
define.HasValue = false;
4958
}
59+
60+
Defines[profile].push_back(define);
5061
}
5162

5263
return true;
64+
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(false);
65+
}
66+
67+
bool runcpp2::Data::ProfilesDefines::IsYAML_NodeParsableAsDefault(ryml::ConstNodeRef node) const
68+
{
69+
ssLOG_FUNC_DEBUG();
70+
INTERNAL_RUNCPP2_SAFE_START();
5371

72+
if(!INTERNAL_RUNCPP2_BIT_CONTANTS(node.type().type, ryml::NodeType_e::SEQ))
73+
return false;
74+
75+
return true;
5476
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(false);
5577
}
5678

Src/runcpp2/Data/ProfilesFlagsOverride.cpp

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

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

910
if(!node.is_map())

Src/runcpp2/Data/ProfilesProcessPaths.cpp

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
bool runcpp2::Data::ProfilesProcessPaths::ParseYAML_Node(ryml::ConstNodeRef node)
66
{
77
ssLOG_FUNC_DEBUG();
8-
98
INTERNAL_RUNCPP2_SAFE_START();
109

1110
if(!node.is_map())
@@ -16,21 +15,45 @@ bool runcpp2::Data::ProfilesProcessPaths::ParseYAML_Node(ryml::ConstNodeRef node
1615

1716
for(int i = 0; i < node.num_children(); ++i)
1817
{
19-
if(!INTERNAL_RUNCPP2_BIT_CONTANTS(node[i].type().type, ryml::NodeType_e::SEQ))
20-
{
21-
ssLOG_ERROR("ProfilesProcessPaths: Paths type requires a list");
22-
return false;
23-
}
24-
2518
ryml::ConstNodeRef currentProfilePathsNode = node[i];
2619
ProfileName profile = GetKey(currentProfilePathsNode);
20+
21+
if(!ParseYAML_NodeWithProfile(currentProfilePathsNode, profile))
22+
return false;
23+
}
24+
25+
return true;
26+
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(false);
27+
}
2728

28-
for(int j = 0; j < currentProfilePathsNode.num_children(); ++j)
29-
Paths[profile].push_back(GetValue(currentProfilePathsNode[j]));
29+
bool runcpp2::Data::ProfilesProcessPaths::ParseYAML_NodeWithProfile(ryml::ConstNodeRef node,
30+
ProfileName profile)
31+
{
32+
ssLOG_FUNC_DEBUG();
33+
INTERNAL_RUNCPP2_SAFE_START();
34+
35+
if(!INTERNAL_RUNCPP2_BIT_CONTANTS(node.type().type, ryml::NodeType_e::SEQ))
36+
{
37+
ssLOG_ERROR("ProfilesProcessPaths: Paths type requires a list");
38+
return false;
3039
}
3140

41+
for(int i = 0; i < node.num_children(); ++i)
42+
Paths[profile].push_back(GetValue(node[i]));
43+
3244
return true;
45+
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(false);
46+
}
47+
48+
bool runcpp2::Data::ProfilesProcessPaths::IsYAML_NodeParsableAsDefault(ryml::ConstNodeRef node) const
49+
{
50+
ssLOG_FUNC_DEBUG();
51+
INTERNAL_RUNCPP2_SAFE_START();
3352

53+
if(!INTERNAL_RUNCPP2_BIT_CONTANTS(node.type().type, ryml::NodeType_e::SEQ))
54+
return false;
55+
56+
return true;
3457
INTERNAL_RUNCPP2_SAFE_CATCH_RETURN(false);
3558
}
3659

0 commit comments

Comments
 (0)