mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-16 17:12:23 -07:00
move rsp unwrapper to config
This commit is contained in:
committed by
Ryan Fleury
parent
3875b057d7
commit
c56cfefe09
@@ -187,46 +187,6 @@ lnk_cmd_line_has_option(LNK_CmdLine cmd_line, char *string)
|
||||
return lnk_cmd_line_has_option_string(cmd_line, str8_cstring(string));
|
||||
}
|
||||
|
||||
internal String8List
|
||||
lnk_unwrap_rsp(Arena *arena, String8List arg_list)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
|
||||
String8List result = {0};
|
||||
|
||||
for (String8Node *curr = arg_list.first; curr != 0; curr = curr->next) {
|
||||
B32 is_rsp = str8_match_lit("@", curr->string, StringMatchFlag_RightSideSloppy);
|
||||
if (is_rsp) {
|
||||
// remove "@"
|
||||
String8 name = str8_skip(curr->string, 1);
|
||||
|
||||
if (os_file_path_exists(name)) {
|
||||
// read rsp from disk
|
||||
String8 file = lnk_read_data_from_file_path(scratch.arena, name);
|
||||
|
||||
// parse rsp
|
||||
String8List rsp_args = lnk_arg_list_parse_windows_rules(scratch.arena, file);
|
||||
|
||||
// handle case where rsp references another rsp
|
||||
String8List list = lnk_unwrap_rsp(arena, rsp_args);
|
||||
|
||||
// push arguments from rsp
|
||||
list = str8_list_copy(arena, &list);
|
||||
str8_list_concat_in_place(&result, &list);
|
||||
} else {
|
||||
lnk_error(LNK_Error_Cmdl, "unable to find rsp: %S", name);
|
||||
}
|
||||
} else {
|
||||
// push regular argument
|
||||
String8 str = push_str8_copy(arena, curr->string);
|
||||
str8_list_push(arena, &result, str);
|
||||
}
|
||||
}
|
||||
|
||||
scratch_end(scratch);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal String8List
|
||||
lnk_data_from_cmd_line(Arena *arena, LNK_CmdLine cmd_line)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,5 @@ internal B32 lnk_cmd_line_has_option(LNK_CmdLine cmd_line, char *str
|
||||
internal LNK_CmdOption * lnk_cmd_line_push_option(Arena *arena, LNK_CmdLine *cmd_line, char *string, char *value);
|
||||
internal LNK_CmdOption * lnk_cmd_line_push_option_if_not_present(Arena *arena, LNK_CmdLine *cmd_line, char *string, char *value);
|
||||
|
||||
internal String8List lnk_unwrap_rsp(Arena *arena, String8List arg_list);
|
||||
|
||||
internal String8List lnk_data_from_cmd_line(Arena *arena, LNK_CmdLine cmd_line);
|
||||
|
||||
|
||||
@@ -1806,6 +1806,46 @@ lnk_apply_cmd_option_to_config(Arena *arena, LNK_Config *config, String8 cmd_nam
|
||||
scratch_end(scratch);
|
||||
}
|
||||
|
||||
internal String8List
|
||||
lnk_unwrap_rsp(Arena *arena, String8List arg_list)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
|
||||
String8List result = {0};
|
||||
|
||||
for (String8Node *curr = arg_list.first; curr != 0; curr = curr->next) {
|
||||
B32 is_rsp = str8_match_lit("@", curr->string, StringMatchFlag_RightSideSloppy);
|
||||
if (is_rsp) {
|
||||
// remove "@"
|
||||
String8 name = str8_skip(curr->string, 1);
|
||||
|
||||
if (os_file_path_exists(name)) {
|
||||
// read rsp from disk
|
||||
String8 file = lnk_read_data_from_file_path(scratch.arena, name);
|
||||
|
||||
// parse rsp
|
||||
String8List rsp_args = lnk_arg_list_parse_windows_rules(scratch.arena, file);
|
||||
|
||||
// handle case where rsp references another rsp
|
||||
String8List list = lnk_unwrap_rsp(arena, rsp_args);
|
||||
|
||||
// push arguments from rsp
|
||||
list = str8_list_copy(arena, &list);
|
||||
str8_list_concat_in_place(&result, &list);
|
||||
} else {
|
||||
lnk_error(LNK_Error_Cmdl, "unable to find rsp: %S", name);
|
||||
}
|
||||
} else {
|
||||
// push regular argument
|
||||
String8 str = push_str8_copy(arena, curr->string);
|
||||
str8_list_push(arena, &result, str);
|
||||
}
|
||||
}
|
||||
|
||||
scratch_end(scratch);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal LNK_Config *
|
||||
lnk_config_from_cmd_line(Arena *arena, String8List raw_cmd_line)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user