Skip to content

Commit 772339e

Browse files
Adding profile name alias and command for checking existence
1 parent 9d97867 commit 772339e

File tree

13 files changed

+259
-68
lines changed

13 files changed

+259
-68
lines changed

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ option(RUNCPP2_UPDATE_DEFAULT_YAMLS "Update default yaml files" OFF)
1313
# External Dependencies
1414
# =========================================================================
1515
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/ssLogger")
16+
17+
set(RYML_DEFAULT_CALLBACK_USES_EXCEPTIONS ON CACHE BOOL "" FORCE)
1618
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/rapidyaml")
19+
1720
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/filesystem")
1821
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/System2")
1922
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/External/dylib")
@@ -103,4 +106,4 @@ else()
103106
"-Werror")
104107
endif()
105108

106-
target_compile_options(runcpp2 PRIVATE ${STANDARD_COMPILE_FLAGS})
109+
target_compile_options(runcpp2 PRIVATE ${STANDARD_COMPILE_FLAGS})

DefaultYAMLs/DefaultUserConfig.yaml

Lines changed: 104 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,18 @@ PreferredProfile: "g++"
66

77
# List of compiler/linker profiles that instruct how to compile/link
88
Profiles:
9+
# Name (case sensitive) of the profile that can be queried from a script
910
- Name: "g++"
1011

12+
# (Optional) Name aliases (case sensitive) of the current profile
13+
NameAliases: ["mingw"]
14+
1115
# The file extensions associated with the profile
1216
FileExtensions: [cpp, cc, cxx]
1317

1418
# The languages supported by the profile
1519
Languages: ["c++"]
1620

17-
# (Optional) Steps to run before calling the compiler/linker.
18-
# This is run inside the .runcpp2 directory where the build happens.
19-
# SetupSteps:
20-
# # Applies to all platforms (Can be changed to Linux, MacOS, Windows, Unix, etc.)
21-
# All: []
22-
2321
# The following fields set the prefixes and extensions for each type of the files
2422
# If the name of an object files are libtest.so and libtest2.so,
2523
# the prefixes and extensions are "lib" and ".so"
@@ -31,6 +29,12 @@ Profiles:
3129
# - MacOS
3230
# - Unix
3331

32+
# (Optional) The commands to run in **shell** before calling the compiler/linker for each platform.
33+
# This is run inside the .runcpp2 directory where the build happens.
34+
# SetupSteps:
35+
# All: []
36+
37+
# TODO: Make this common
3438
# The file properties for the object files for each platform.
3539
ObjectLinkFile:
3640
Prefix:
@@ -90,6 +94,9 @@ Profiles:
9094
# Executable to be called
9195
Executable: "g++"
9296

97+
# Shell command to use for checking if the executable exists or not
98+
CheckExistence: "g++ -v"
99+
93100
# Default arguments to provide for compilation which can be overridden
94101
# by the script for each platform
95102
DefaultCompileFlags:
@@ -134,6 +141,9 @@ Profiles:
134141
# Executable to be called
135142
Executable: "g++"
136143

144+
# Shell command to use for checking if the executable exists or not
145+
CheckExistence: "g++ -v"
146+
137147
# Default arguments to provide for linking dependencies to the binary,
138148
# which can be overridden by the script for each platform
139149
DefaultLinkFlags:
@@ -164,3 +174,91 @@ Profiles:
164174
# {LinkFilePath} will be replaced by the path to the object file
165175
# we are linking against
166176
LinkPart: "{LinkFilePath}"
177+
178+
# https://learn.microsoft.com/en-us/cpp/overview/compiler-versions?view=msvc-170
179+
- &MSVC_2022
180+
Name: "vs2022_v17+"
181+
NameAliases: ["msvc1930+", "msvc"]
182+
FileExtensions: [cpp, cc, cxx]
183+
Languages: ["c++"]
184+
185+
ObjectLinkFile:
186+
Prefix:
187+
Windows: ""
188+
Extension:
189+
Windows: ".obj"
190+
191+
SharedLinkFile:
192+
Prefix:
193+
Windows: ""
194+
Extension:
195+
Windows: ".lib"
196+
197+
SharedLibraryFile:
198+
Prefix:
199+
Windows: ""
200+
Extension:
201+
Windows: ".dll"
202+
203+
StaticLinkFile:
204+
Prefix:
205+
Windows: ""
206+
Extension:
207+
Windows: ".lib"
208+
209+
DebugSymbolFile:
210+
Prefix:
211+
Windows: ""
212+
Extension:
213+
Windows: ".pdb"
214+
215+
Compiler:
216+
EnvironmentSetup:
217+
Windows: "\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat\" x64"
218+
219+
Executable: "CL.exe"
220+
221+
CheckExistence: "where.exe CL.exe"
222+
223+
DefaultCompileFlags:
224+
Windows: "/utf-8 /MD /EHa /TP"
225+
226+
ExecutableCompileFlags:
227+
Windows: ""
228+
229+
StaticLibCompileFlags:
230+
Windows: ""
231+
232+
SharedLibCompileFlags:
233+
Windows: ""
234+
235+
# Should be: CL.exe /c {CompileFlags} /I{IncludeDirectoryPath} /Fo"{ObjectFilePath}" {InputFilePath}
236+
CompileArgs:
237+
CompilePart: "/c {CompileFlags}"
238+
IncludePart: "/I{IncludeDirectoryPath}"
239+
InputPart: "{InputFilePath}"
240+
OutputPart: "/Fo\"{ObjectFilePath}\""
241+
242+
Linker:
243+
EnvironmentSetup:
244+
Windows: "\"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat\" x64"
245+
246+
Executable: "link.exe"
247+
248+
CheckExistence: "where.exe link.exe"
249+
250+
DefaultLinkFlags:
251+
Windows: ""
252+
253+
ExecutableLinkFlags:
254+
Windows: ""
255+
256+
StaticLibLinkFlags:
257+
Windows: ""
258+
259+
SharedLibLinkFlags:
260+
Windows: ""
261+
262+
LinkArgs:
263+
OutputPart: "{LinkFlags} -o {OutputFilePath}"
264+
LinkPart: "{LinkFilePath}"

DefaultYAMLs/UserConfigSchema.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
"properties":
1515
{
1616
"Name": { "type": "string" },
17+
"NameAliases":
18+
{
19+
"type": "array",
20+
"items": { "type":"string" },
21+
"uniqueItems": true
22+
},
1723
"FileExtensions" :
1824
{
1925
"type": "array",
@@ -210,6 +216,7 @@
210216
"additionalProperties": false
211217
},
212218
"Executable": { "type": "string" },
219+
"CheckExistence": { "type": "string" },
213220
"DefaultCompileFlags":
214221
{
215222
"type": "object",
@@ -268,6 +275,7 @@
268275
"required":
269276
[
270277
"Executable",
278+
"CheckExistence",
271279
"DefaultCompileFlags",
272280
"ExecutableCompileFlags",
273281
"StaticLibCompileFlags",
@@ -291,6 +299,7 @@
291299
"additionalProperties": false
292300
},
293301
"Executable": { "type": "string" },
302+
"CheckExistence": { "type": "string" },
294303
"DefaultLinkFlags":
295304
{
296305
"type": "object",
@@ -345,6 +354,7 @@
345354
"required":
346355
[
347356
"Executable",
357+
"CheckExistence",
348358
"DefaultLinkFlags",
349359
"ExecutableLinkFlags",
350360
"StaticLibLinkFlags",
@@ -370,4 +380,4 @@
370380
}
371381
},
372382
"required": ["Profiles"]
373-
}
383+
}

Include/runcpp2/Data/CompilerInfo.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace runcpp2
1717
public:
1818
std::unordered_map<PlatformName, std::string> EnvironmentSetup;
1919
std::string Executable;
20-
20+
std::string CheckExistence;
2121
std::unordered_map<PlatformName, std::string> DefaultCompileFlags;
2222
std::unordered_map<PlatformName, std::string> ExecutableCompileFlags;
2323
std::unordered_map<PlatformName, std::string> StaticLibCompileFlags;
@@ -39,4 +39,4 @@ namespace runcpp2
3939
}
4040
}
4141

42-
#endif
42+
#endif

Include/runcpp2/Data/LinkerInfo.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace runcpp2
1717
public:
1818
std::unordered_map<PlatformName, std::string> EnvironmentSetup;
1919
std::string Executable;
20-
20+
std::string CheckExistence;
2121
std::unordered_map<PlatformName, std::string> DefaultLinkFlags;
2222
std::unordered_map<PlatformName, std::string> ExecutableLinkFlags;
2323
std::unordered_map<PlatformName, std::string> StaticLibLinkFlags;
@@ -37,4 +37,4 @@ namespace runcpp2
3737
}
3838
}
3939

40-
#endif
40+
#endif

Include/runcpp2/Data/Profile.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace runcpp2
2121
{
2222
public:
2323
std::string Name;
24+
std::unordered_set<std::string> NameAliases;
2425
std::unordered_set<std::string> FileExtensions;
2526
std::unordered_set<std::string> Languages;
2627
std::unordered_map<PlatformName, std::vector<std::string>> SetupSteps;
@@ -39,4 +40,4 @@ namespace runcpp2
3940
}
4041
}
4142

42-
#endif
43+
#endif

Include/runcpp2/DependenciesSetupHelper.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace runcpp2
1111
bool IsDependencyAvailableForThisPlatform(const Data::DependencyInfo& dependency);
1212

1313

14-
bool SetupScriptDependencies( const ProfileName& profileName,
14+
bool SetupScriptDependencies( const Data::Profile& profile,
1515
const std::string& scriptPath,
1616
Data::ScriptInfo& scriptInfo,
1717
bool resetDependencies,
@@ -25,4 +25,4 @@ namespace runcpp2
2525
std::vector<std::string>& outCopiedBinariesPaths);
2626
}
2727

28-
#endif
28+
#endif

Src/runcpp2/Data/CompilerInfo.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ bool runcpp2::Data::CompilerInfo::ParseYAML_Node(ryml::ConstNodeRef& node)
1111
{
1212
NodeRequirement("EnvironmentSetup", ryml::NodeType_e::MAP, false, true),
1313
NodeRequirement("Executable", ryml::NodeType_e::KEYVAL, true, false),
14+
NodeRequirement("CheckExistence", ryml::NodeType_e::KEYVAL, true, false),
1415
NodeRequirement("DefaultCompileFlags", ryml::NodeType_e::MAP, true, true),
1516
NodeRequirement("ExecutableCompileFlags", ryml::NodeType_e::MAP, true, true),
1617
NodeRequirement("StaticLibCompileFlags", ryml::NodeType_e::MAP, true, true),
@@ -50,6 +51,7 @@ bool runcpp2::Data::CompilerInfo::ParseYAML_Node(ryml::ConstNodeRef& node)
5051
}
5152

5253
node["Executable"] >> Executable;
54+
node["CheckExistence"] >> CheckExistence;
5355

5456
for(int i = 0; i < node["DefaultCompileFlags"].num_children(); ++i)
5557
{
@@ -138,6 +140,7 @@ std::string runcpp2::Data::CompilerInfo::ToString(std::string indentation) const
138140
}
139141

140142
out += indentation + " Executable: " + Executable + "\n";
143+
out += indentation + " CheckExistence: " + CheckExistence + "\n";
141144
out += indentation + " DefaultCompileFlags: \n";
142145
for(auto it = DefaultCompileFlags.begin(); it != DefaultCompileFlags.end(); ++it)
143146
out += indentation + " " + it->first + ": " + it->second + "\n";
@@ -161,4 +164,4 @@ std::string runcpp2::Data::CompilerInfo::ToString(std::string indentation) const
161164
out += indentation + " OutputPart: " + CompileArgs.OutputPart + "\n";
162165
out += "\n";
163166
return out;
164-
}
167+
}

Src/runcpp2/Data/LinkerInfo.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ bool runcpp2::Data::LinkerInfo::ParseYAML_Node(ryml::ConstNodeRef& node)
1212
{
1313
NodeRequirement("EnvironmentSetup", ryml::NodeType_e::MAP, false, true),
1414
NodeRequirement("Executable", ryml::NodeType_e::KEYVAL, true, false),
15+
NodeRequirement("CheckExistence", ryml::NodeType_e::KEYVAL, true, false),
1516
NodeRequirement("DefaultLinkFlags", ryml::NodeType_e::KEYVAL, true, true),
1617
NodeRequirement("ExecutableLinkFlags", ryml::NodeType_e::KEYVAL, true, true),
1718
NodeRequirement("StaticLibLinkFlags", ryml::NodeType_e::KEYVAL, true, true),
@@ -49,6 +50,7 @@ bool runcpp2::Data::LinkerInfo::ParseYAML_Node(ryml::ConstNodeRef& node)
4950
}
5051

5152
node["Executable"] >> Executable;
53+
node["CheckExistence"] >> CheckExistence;
5254

5355
for(int i = 0; i < node["DefaultLinkFlags"].num_children(); ++i)
5456
{
@@ -136,6 +138,7 @@ std::string runcpp2::Data::LinkerInfo::ToString(std::string indentation) const
136138
}
137139

138140
out += indentation + " Executable: " + Executable + "\n";
141+
out += indentation + " CheckExistence: " + CheckExistence + "\n";
139142
out += indentation + " DefaultLinkFlags: \n";
140143
for(auto it = DefaultLinkFlags.begin(); it != DefaultLinkFlags.end(); ++it)
141144
out += indentation + " " + it->first + ": " + it->second + "\n";
@@ -157,4 +160,4 @@ std::string runcpp2::Data::LinkerInfo::ToString(std::string indentation) const
157160
out += indentation + " LinkPart: " + LinkArgs.LinkPart + "\n";
158161

159162
return out;
160-
}
163+
}

Src/runcpp2/Data/Profile.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ bool runcpp2::Data::Profile::ParseYAML_Node(ryml::ConstNodeRef& profileNode)
1010
std::vector<NodeRequirement> requirements =
1111
{
1212
NodeRequirement("Name", ryml::NodeType_e::KEYVAL, true, false),
13+
NodeRequirement("NameAliases", ryml::NodeType_e::SEQ, false, true),
1314
NodeRequirement("FileExtensions", ryml::NodeType_e::SEQ, true, false),
1415
NodeRequirement("Languages", ryml::NodeType_e::SEQ, false, true),
1516
NodeRequirement("SetupSteps", ryml::NodeType_e::MAP, false, true),
@@ -30,6 +31,12 @@ bool runcpp2::Data::Profile::ParseYAML_Node(ryml::ConstNodeRef& profileNode)
3031

3132
profileNode["Name"] >> Name;
3233

34+
if(ExistAndHasChild(profileNode, "NameAliases"))
35+
{
36+
for(int i = 0; i < profileNode["NameAliases"].num_children(); ++i)
37+
NameAliases.insert(GetValue(profileNode["NameAliases"][i]));
38+
}
39+
3340
for(int i = 0; i < profileNode["FileExtensions"].num_children(); ++i)
3441
FileExtensions.insert(GetValue(profileNode["FileExtensions"][i]));
3542

@@ -117,6 +124,9 @@ std::string runcpp2::Data::Profile::ToString(std::string indentation) const
117124
std::string out;
118125

119126
out += indentation + "Name: " + Name + "\n";
127+
out += indentation + "NameAliases:\n";
128+
for(auto it = NameAliases.begin(); it != NameAliases.end(); ++it)
129+
out += indentation + "- " + *it + "\n";
120130

121131
out += indentation + "FileExtensions:\n";
122132
for(auto it = FileExtensions.begin(); it != FileExtensions.end(); ++it)
@@ -129,9 +139,9 @@ std::string runcpp2::Data::Profile::ToString(std::string indentation) const
129139
out += indentation + "SetupSteps:\n";
130140
for(auto it = SetupSteps.begin(); it != SetupSteps.end(); ++it)
131141
{
132-
out += indentation + it->first + ":\n";
142+
out += indentation + " " + it->first + ":\n";
133143
for(int i = 0; i < it->second.size(); ++i)
134-
out += indentation + "- " + it->second[i] + "\n";
144+
out += indentation + " - " + it->second[i] + "\n";
135145
}
136146

137147
out += indentation + "ObjectLinkFile:\n";

0 commit comments

Comments
 (0)