Skip to content

Commit c413ff6

Browse files
WIP
1 parent 0f315af commit c413ff6

File tree

5 files changed

+403
-125
lines changed

5 files changed

+403
-125
lines changed

DefaultYAMLs/DefaultCompilerProfiles.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ CompilerProfiles:
7070
# The syntax to link the given file
7171
LinkerArgs:
7272
# Syntax for outputting to the binary.
73-
# {LinkFlags}, {ProgramName} will be replaced accordingly
74-
OutputPart: "{LinkFlags} -o {ProgramName}"
73+
# {LinkFlags}, {OutputFile}, {ObjectFile} will be replaced accordingly
74+
OutputPart: "{LinkFlags} -o {OutputFile} {ObjectFile}"
7575

7676
# Syntax for linking each dependency.
7777
# {DependencyName} will be replaced accordingly

Include/runcpp2/runcpp2.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ namespace runcpp2
9595
//--------------------------------------------
9696
bool RunScript( const std::string& scriptPath,
9797
const std::vector<CompilerProfile>& profiles,
98-
const std::string& configPreferredProfile);
98+
const std::string& configPreferredProfile,
99+
const std::string& runArgs);
99100

100101

101102

Src/runcpp2/DefaultYAMLs.c

Lines changed: 61 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -214,29 +214,31 @@ const uint8_t DefaultCompilerProfiles[] = {
214214
0x20, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x2e, 0x20, 0x0a, 0x20, 0x20,
215215
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23, 0x20,
216216
0x7b, 0x4c, 0x69, 0x6e, 0x6b, 0x46, 0x6c, 0x61, 0x67, 0x73, 0x7d, 0x2c,
217-
0x20, 0x7b, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x4e, 0x61, 0x6d,
217+
0x20, 0x7b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x46, 0x69, 0x6c, 0x65,
218+
0x7d, 0x2c, 0x20, 0x7b, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x46, 0x69,
219+
0x6c, 0x65, 0x7d, 0x20, 0x77, 0x69, 0x6c, 0x6c, 0x20, 0x62, 0x65, 0x20,
220+
0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x64, 0x20, 0x61, 0x63, 0x63,
221+
0x6f, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x6c, 0x79, 0x0a, 0x20, 0x20, 0x20,
222+
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x4f, 0x75, 0x74,
223+
0x70, 0x75, 0x74, 0x50, 0x61, 0x72, 0x74, 0x3a, 0x20, 0x22, 0x7b, 0x4c,
224+
0x69, 0x6e, 0x6b, 0x46, 0x6c, 0x61, 0x67, 0x73, 0x7d, 0x20, 0x2d, 0x6f,
225+
0x20, 0x7b, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x46, 0x69, 0x6c, 0x65,
226+
0x7d, 0x20, 0x7b, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x46, 0x69, 0x6c,
227+
0x65, 0x7d, 0x22, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
228+
0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
229+
0x20, 0x20, 0x20, 0x20, 0x20, 0x23, 0x20, 0x53, 0x79, 0x6e, 0x74, 0x61,
230+
0x78, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x6c, 0x69, 0x6e, 0x6b, 0x69, 0x6e,
231+
0x67, 0x20, 0x65, 0x61, 0x63, 0x68, 0x20, 0x64, 0x65, 0x70, 0x65, 0x6e,
232+
0x64, 0x65, 0x6e, 0x63, 0x79, 0x2e, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20,
233+
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23, 0x20, 0x7b, 0x44,
234+
0x65, 0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x4e, 0x61, 0x6d,
218235
0x65, 0x7d, 0x20, 0x77, 0x69, 0x6c, 0x6c, 0x20, 0x62, 0x65, 0x20, 0x72,
219236
0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x64, 0x20, 0x61, 0x63, 0x63, 0x6f,
220237
0x72, 0x64, 0x69, 0x6e, 0x67, 0x6c, 0x79, 0x0a, 0x20, 0x20, 0x20, 0x20,
221-
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x4f, 0x75, 0x74, 0x70,
222-
0x75, 0x74, 0x50, 0x61, 0x72, 0x74, 0x3a, 0x20, 0x22, 0x7b, 0x4c, 0x69,
223-
0x6e, 0x6b, 0x46, 0x6c, 0x61, 0x67, 0x73, 0x7d, 0x20, 0x2d, 0x6f, 0x20,
224-
0x7b, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x61, 0x6d, 0x4e, 0x61, 0x6d, 0x65,
225-
0x7d, 0x22, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
226-
0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
227-
0x20, 0x20, 0x20, 0x20, 0x23, 0x20, 0x53, 0x79, 0x6e, 0x74, 0x61, 0x78,
228-
0x20, 0x66, 0x6f, 0x72, 0x20, 0x6c, 0x69, 0x6e, 0x6b, 0x69, 0x6e, 0x67,
229-
0x20, 0x65, 0x61, 0x63, 0x68, 0x20, 0x64, 0x65, 0x70, 0x65, 0x6e, 0x64,
230-
0x65, 0x6e, 0x63, 0x79, 0x2e, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
231-
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23, 0x20, 0x7b, 0x44, 0x65,
232-
0x70, 0x65, 0x6e, 0x64, 0x65, 0x6e, 0x63, 0x79, 0x4e, 0x61, 0x6d, 0x65,
233-
0x7d, 0x20, 0x77, 0x69, 0x6c, 0x6c, 0x20, 0x62, 0x65, 0x20, 0x72, 0x65,
234-
0x70, 0x6c, 0x61, 0x63, 0x65, 0x64, 0x20, 0x61, 0x63, 0x63, 0x6f, 0x72,
235-
0x64, 0x69, 0x6e, 0x67, 0x6c, 0x79, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
236-
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x44, 0x65, 0x70, 0x65, 0x6e,
237-
0x64, 0x65, 0x6e, 0x63, 0x69, 0x65, 0x73, 0x50, 0x61, 0x72, 0x74, 0x3a,
238-
0x20, 0x22, 0x2d, 0x6c, 0x7b, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64, 0x65,
239-
0x6e, 0x63, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x7d, 0x22,
238+
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x44, 0x65, 0x70, 0x65,
239+
0x6e, 0x64, 0x65, 0x6e, 0x63, 0x69, 0x65, 0x73, 0x50, 0x61, 0x72, 0x74,
240+
0x3a, 0x20, 0x22, 0x2d, 0x6c, 0x7b, 0x44, 0x65, 0x70, 0x65, 0x6e, 0x64,
241+
0x65, 0x6e, 0x63, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x7d, 0x22,
240242
};
241243
const size_t DefaultCompilerProfiles_size = sizeof(DefaultCompilerProfiles);
242244
const uint8_t DefaultScriptInfo[] = {
@@ -385,43 +387,46 @@ const uint8_t DefaultScriptInfo[] = {
385387
0x20, 0x77, 0x69, 0x6c, 0x6c, 0x20, 0x62, 0x65, 0x20, 0x72, 0x65, 0x70,
386388
0x6c, 0x61, 0x63, 0x65, 0x64, 0x20, 0x61, 0x63, 0x63, 0x6f, 0x72, 0x64,
387389
0x69, 0x6e, 0x67, 0x6c, 0x79, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
388-
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68,
389-
0x50, 0x61, 0x74, 0x68, 0x3a, 0x20, 0x2e, 0x2f, 0x62, 0x75, 0x69, 0x6c,
390-
0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x23,
391-
0x20, 0x28, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x29, 0x20,
392-
0x4c, 0x69, 0x73, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x73, 0x65, 0x74, 0x75,
393-
0x70, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x20, 0x66,
394-
0x6f, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x75, 0x70, 0x70, 0x6f,
395-
0x72, 0x74, 0x65, 0x64, 0x20, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72,
396-
0x6d, 0x73, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x53, 0x65, 0x74, 0x75, 0x70,
397-
0x3a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23, 0x20,
398-
0x53, 0x65, 0x74, 0x75, 0x70, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e,
399-
0x64, 0x73, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73,
400-
0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x64, 0x20, 0x70, 0x6c, 0x61,
401-
0x74, 0x66, 0x6f, 0x72, 0x6d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
402-
0x20, 0x20, 0x41, 0x6c, 0x6c, 0x3a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
403-
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23, 0x20, 0x53, 0x65, 0x74,
390+
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23, 0x20, 0x54, 0x4f, 0x44, 0x4f,
391+
0x3a, 0x20, 0x4d, 0x61, 0x6b, 0x65, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20,
392+
0x61, 0x20, 0x6c, 0x69, 0x73, 0x74, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
393+
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x53, 0x65, 0x61, 0x72, 0x63,
394+
0x68, 0x50, 0x61, 0x74, 0x68, 0x3a, 0x20, 0x2e, 0x2f, 0x62, 0x75, 0x69,
395+
0x6c, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20,
396+
0x23, 0x20, 0x28, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x29,
397+
0x20, 0x4c, 0x69, 0x73, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x73, 0x65, 0x74,
404398
0x75, 0x70, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x20,
405-
0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x70, 0x65, 0x63,
406-
0x69, 0x66, 0x69, 0x65, 0x64, 0x20, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c,
407-
0x65, 0x2e, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
408-
0x20, 0x20, 0x20, 0x20, 0x23, 0x20, 0x7b, 0x42, 0x75, 0x69, 0x6c, 0x64,
409-
0x54, 0x79, 0x70, 0x65, 0x7d, 0x20, 0x77, 0x69, 0x6c, 0x6c, 0x20, 0x62,
410-
0x65, 0x20, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x64, 0x20, 0x61,
411-
0x63, 0x63, 0x6f, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x6c, 0x79, 0x0a, 0x20,
412-
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22,
413-
0x67, 0x2b, 0x2b, 0x22, 0x3a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
414-
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x20, 0x20, 0x20, 0x22, 0x6d,
415-
0x6b, 0x64, 0x69, 0x72, 0x20, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x22, 0x0a,
399+
0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x75, 0x70, 0x70,
400+
0x6f, 0x72, 0x74, 0x65, 0x64, 0x20, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f,
401+
0x72, 0x6d, 0x73, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x53, 0x65, 0x74, 0x75,
402+
0x70, 0x3a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23,
403+
0x20, 0x53, 0x65, 0x74, 0x75, 0x70, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61,
404+
0x6e, 0x64, 0x73, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20,
405+
0x73, 0x70, 0x65, 0x63, 0x69, 0x66, 0x69, 0x65, 0x64, 0x20, 0x70, 0x6c,
406+
0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
407+
0x20, 0x20, 0x20, 0x41, 0x6c, 0x6c, 0x3a, 0x0a, 0x20, 0x20, 0x20, 0x20,
408+
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23, 0x20, 0x53, 0x65,
409+
0x74, 0x75, 0x70, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73,
410+
0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x70, 0x65,
411+
0x63, 0x69, 0x66, 0x69, 0x65, 0x64, 0x20, 0x70, 0x72, 0x6f, 0x66, 0x69,
412+
0x6c, 0x65, 0x2e, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
413+
0x20, 0x20, 0x20, 0x20, 0x20, 0x23, 0x20, 0x7b, 0x42, 0x75, 0x69, 0x6c,
414+
0x64, 0x54, 0x79, 0x70, 0x65, 0x7d, 0x20, 0x77, 0x69, 0x6c, 0x6c, 0x20,
415+
0x62, 0x65, 0x20, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x64, 0x20,
416+
0x61, 0x63, 0x63, 0x6f, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x6c, 0x79, 0x0a,
416417
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
417-
0x2d, 0x20, 0x20, 0x20, 0x22, 0x63, 0x64, 0x20, 0x62, 0x75, 0x69, 0x6c,
418-
0x64, 0x20, 0x26, 0x26, 0x20, 0x63, 0x6d, 0x61, 0x6b, 0x65, 0x20, 0x2e,
419-
0x2e, 0x20, 0x2d, 0x44, 0x43, 0x4d, 0x41, 0x4b, 0x45, 0x5f, 0x42, 0x55,
420-
0x49, 0x4c, 0x44, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x3d, 0x7b, 0x42, 0x75,
421-
0x69, 0x6c, 0x64, 0x54, 0x79, 0x70, 0x65, 0x7d, 0x22, 0x0a, 0x20, 0x20,
422-
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x20,
423-
0x20, 0x20, 0x22, 0x63, 0x64, 0x20, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x20,
424-
0x26, 0x26, 0x20, 0x63, 0x6d, 0x61, 0x6b, 0x65, 0x20, 0x2d, 0x2d, 0x62,
425-
0x75, 0x69, 0x6c, 0x64, 0x20, 0x2e, 0x22, 0x0a,
418+
0x22, 0x67, 0x2b, 0x2b, 0x22, 0x3a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
419+
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x20, 0x20, 0x20, 0x22,
420+
0x6d, 0x6b, 0x64, 0x69, 0x72, 0x20, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x22,
421+
0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
422+
0x20, 0x2d, 0x20, 0x20, 0x20, 0x22, 0x63, 0x64, 0x20, 0x62, 0x75, 0x69,
423+
0x6c, 0x64, 0x20, 0x26, 0x26, 0x20, 0x63, 0x6d, 0x61, 0x6b, 0x65, 0x20,
424+
0x2e, 0x2e, 0x20, 0x2d, 0x44, 0x43, 0x4d, 0x41, 0x4b, 0x45, 0x5f, 0x42,
425+
0x55, 0x49, 0x4c, 0x44, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x3d, 0x7b, 0x42,
426+
0x75, 0x69, 0x6c, 0x64, 0x54, 0x79, 0x70, 0x65, 0x7d, 0x22, 0x0a, 0x20,
427+
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2d,
428+
0x20, 0x20, 0x20, 0x22, 0x63, 0x64, 0x20, 0x62, 0x75, 0x69, 0x6c, 0x64,
429+
0x20, 0x26, 0x26, 0x20, 0x63, 0x6d, 0x61, 0x6b, 0x65, 0x20, 0x2d, 0x2d,
430+
0x62, 0x75, 0x69, 0x6c, 0x64, 0x20, 0x2e, 0x22, 0x0a,
426431
};
427432
const size_t DefaultScriptInfo_size = sizeof(DefaultScriptInfo);

Src/runcpp2/main.cpp

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

99

1010

11+
enum class runcpp2_CmdOptions
12+
{
13+
NONE,
14+
SETUP,
15+
COUNT
16+
};
17+
18+
1119
int main(int argc, char* argv[])
1220
{
1321
#if 0
@@ -86,16 +94,48 @@ int main(int argc, char* argv[])
8694
for(int i = 0; i < compilerProfiles.size(); ++i)
8795
ssLOG_LINE("\n" << compilerProfiles[i].ToString(" "));
8896

89-
//TODO(NOW): Parse arguments
90-
9197
if(argc < 2)
9298
{
9399
ssLOG_FATAL("An input file is required");
94100
return 1;
95101
}
96102

97-
std::string script = argv[1];
98-
if(!runcpp2::RunScript(script, compilerProfiles, preferredProfile))
103+
std::unordered_map<std::string, runcpp2_CmdOptions> optionsMap =
104+
{
105+
{"--setup", runcpp2_CmdOptions::SETUP}
106+
};
107+
108+
runcpp2_CmdOptions currentOption = runcpp2_CmdOptions::NONE;
109+
int currentArgIndex = 1;
110+
if(optionsMap.find(std::string(argv[currentArgIndex])) != optionsMap.end())
111+
{
112+
static_assert((int)runcpp2_CmdOptions::COUNT == 2, "Add a case for the new runcpp2_CmdOptions");
113+
114+
switch(optionsMap.at(std::string(argv[1])))
115+
{
116+
case runcpp2_CmdOptions::NONE:
117+
case runcpp2_CmdOptions::COUNT:
118+
break;
119+
case runcpp2_CmdOptions::SETUP:
120+
currentOption = runcpp2_CmdOptions::SETUP;
121+
++currentArgIndex;
122+
break;
123+
}
124+
}
125+
126+
std::string scriptArgs = "";
127+
if(currentArgIndex >= argc)
128+
{
129+
ssLOG_FATAL("An input file is required");
130+
return 1;
131+
}
132+
133+
std::string script = argv[currentArgIndex++];
134+
135+
for(; currentArgIndex < argc; ++currentArgIndex)
136+
scriptArgs += " " + std::string(argv[currentArgIndex]);
137+
138+
if(!runcpp2::RunScript(script, compilerProfiles, preferredProfile, scriptArgs))
99139
{
100140
ssLOG_FATAL("Failed to run script: " << script);
101141
return 2;

0 commit comments

Comments
 (0)