Skip to content

Commit 220ae74

Browse files
Adding platform independent compile and link flags
1 parent 4897d8d commit 220ae74

File tree

10 files changed

+357
-214
lines changed

10 files changed

+357
-214
lines changed

DefaultYAMLs/DefaultUserConfig.yaml

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,24 @@ CompilerProfiles:
5353
Executable: "g++"
5454

5555
# Default arguments to provide for compilation which can be overridden by the script
56-
DefaultCompileFlags: "-std=c++17 -Wall -Werror"
56+
DefaultCompileFlags:
57+
# Applies to all platforms (Can be changed to Linux, MacOS, Windows, Unix, etc.)
58+
All: "-std=c++17 -Wall -Werror"
59+
60+
# Flags for compiling to an executable
61+
ExecutableCompileFlags:
62+
# Applies to all platforms (Can be changed to Linux, MacOS, Windows, Unix, etc.)
63+
All: ""
64+
65+
# Flags for compiling to a static library
66+
StaticLibCompileFlags:
67+
# Applies to all platforms (Can be changed to Linux, MacOS, Windows, Unix, etc.)
68+
All: ""
69+
70+
# Flags for compiling to a shared library
71+
SharedLibCompileFlags:
72+
# Applies to all platforms (Can be changed to Linux, MacOS, Windows, Unix, etc.)
73+
All: ""
5774

5875
# The syntax to compile the given file.
5976
# [Setup steps if any] -->
@@ -78,7 +95,24 @@ CompilerProfiles:
7895

7996
# Default arguments to provide for linking dependencies to the binary,
8097
# which can be overridden by the script
81-
DefaultLinkFlags: ""
98+
DefaultLinkFlags:
99+
# Applies to all platforms (Can be changed to Linux, MacOS, Windows, Unix, etc.)
100+
All: ""
101+
102+
# Flags for linking as an executable
103+
ExecutableLinkFlags:
104+
# Applies to all platforms (Can be changed to Linux, MacOS, Windows, Unix, etc.)
105+
All: ""
106+
107+
# Flags for linking as a static library
108+
StaticLibLinkFlags:
109+
# Applies to all platforms (Can be changed to Linux, MacOS, Windows, Unix, etc.)
110+
All: ""
111+
112+
# Flags for linking as a shared library
113+
SharedLibLinkFlags:
114+
# Applies to all platforms (Can be changed to Linux, MacOS, Windows, Unix, etc.)
115+
All: ""
82116

83117
# The syntax to link the given file
84118
LinkerArgs:

DefaultYAMLs/UserConfigSchema.json

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,42 @@
106106
"additionalProperties": false
107107
},
108108
"Executable": { "type": "string" },
109-
"DefaultCompileFlags": { "type": "string" },
109+
"DefaultCompileFlags":
110+
{
111+
"type": "object",
112+
"patternProperties":
113+
{
114+
"^.*$": { "type": "string" }
115+
},
116+
"additionalProperties": false
117+
},
118+
"ExecutableCompileFlags":
119+
{
120+
"type": "object",
121+
"patternProperties":
122+
{
123+
"^.*$": { "type": "string" }
124+
},
125+
"additionalProperties": false
126+
},
127+
"StaticLibCompileFlags":
128+
{
129+
"type": "object",
130+
"patternProperties":
131+
{
132+
"^.*$": { "type": "string" }
133+
},
134+
"additionalProperties": false
135+
},
136+
"SharedLibCompileFlags":
137+
{
138+
"type": "object",
139+
"patternProperties":
140+
{
141+
"^.*$": { "type": "string" }
142+
},
143+
"additionalProperties": false
144+
},
110145
"CompileArgs":
111146
{
112147
"type": "object",
@@ -130,6 +165,9 @@
130165
[
131166
"Executable",
132167
"DefaultCompileFlags",
168+
"ExecutableCompileFlags",
169+
"StaticLibCompileFlags",
170+
"SharedLibCompileFlags",
133171
"CompileArgs"
134172
]
135173
},
@@ -152,7 +190,42 @@
152190
"additionalProperties": false
153191
},
154192
"Executable": { "type": "string" },
155-
"DefaultLinkFlags": { "type": "string" },
193+
"DefaultLinkFlags":
194+
{
195+
"type": "object",
196+
"patternProperties":
197+
{
198+
"^.*$": { "type": "string" }
199+
},
200+
"additionalProperties": false
201+
},
202+
"ExecutableLinkFlags":
203+
{
204+
"type": "object",
205+
"patternProperties":
206+
{
207+
"^.*$": { "type": "string" }
208+
},
209+
"additionalProperties": false
210+
},
211+
"StaticLibLinkFlags":
212+
{
213+
"type": "object",
214+
"patternProperties":
215+
{
216+
"^.*$": { "type": "string" }
217+
},
218+
"additionalProperties": false
219+
},
220+
"SharedLibLinkFlags":
221+
{
222+
"type": "object",
223+
"patternProperties":
224+
{
225+
"^.*$": { "type": "string" }
226+
},
227+
"additionalProperties": false
228+
},
156229
"LinkerArgs":
157230
{
158231
"type": "object",
@@ -172,6 +245,9 @@
172245
[
173246
"Executable",
174247
"DefaultLinkFlags",
248+
"ExecutableLinkFlags",
249+
"StaticLibLinkFlags",
250+
"SharedLibLinkFlags",
175251
"LinkerArgs"
176252
]
177253
}

Include/runcpp2/Data/CompilerInfo.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ namespace runcpp2
1717
public:
1818
std::unordered_map<PlatformName, std::string> EnvironmentSetup;
1919
std::string Executable;
20-
std::string DefaultCompileFlags;
20+
21+
std::unordered_map<PlatformName, std::string> DefaultCompileFlags;
22+
std::unordered_map<PlatformName, std::string> ExecutableCompileFlags;
23+
std::unordered_map<PlatformName, std::string> StaticLibCompileFlags;
24+
std::unordered_map<PlatformName, std::string> SharedLibCompileFlags;
2125

2226
struct Args
2327
{

Include/runcpp2/Data/LinkerInfo.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ namespace runcpp2
1717
public:
1818
std::unordered_map<PlatformName, std::string> EnvironmentSetup;
1919
std::string Executable;
20-
std::string DefaultLinkFlags;
20+
21+
std::unordered_map<PlatformName, std::string> DefaultLinkFlags;
22+
std::unordered_map<PlatformName, std::string> ExecutableLinkFlags;
23+
std::unordered_map<PlatformName, std::string> StaticLibLinkFlags;
24+
std::unordered_map<PlatformName, std::string> SharedLibLinkFlags;
2125

2226
struct Args
2327
{

Src/runcpp2/CompilerProfileHelper.cpp

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,24 +77,16 @@ namespace
7777

7878
if(!scriptInfo.RequiredProfiles.empty())
7979
{
80-
std::vector<PlatformName> platformNames = runcpp2::GetPlatformNames();
80+
if(!runcpp2::HasValueFromPlatformMap(scriptInfo.RequiredProfiles))
81+
return false;
8182

82-
for(int i = 0; i < platformNames.size(); ++i)
83-
{
84-
if(scriptInfo.RequiredProfiles.find(platformNames.at(i)) == scriptInfo.RequiredProfiles.end())
85-
continue;
86-
87-
const std::vector<ProfileName> allowedProfileNames = scriptInfo .RequiredProfiles
88-
.at(platformNames.at(i));
83+
const std::vector<ProfileName>& allowedProfileNames =
84+
*runcpp2::GetValueFromPlatformMap(scriptInfo.RequiredProfiles);
8985

90-
for(int j = 0; j < allowedProfileNames.size(); ++j)
91-
{
92-
if(allowedProfileNames.at(j) == profile.Name)
93-
return true;
94-
}
95-
96-
//If we went through all the specified profile names, exit
97-
return false;
86+
for(int j = 0; j < allowedProfileNames.size(); ++j)
87+
{
88+
if(allowedProfileNames.at(j) == profile.Name)
89+
return true;
9890
}
9991

10092
//If we went through all the specified platform names for required profiles, exit

0 commit comments

Comments
 (0)