From 6275df55b31fe454689a3c98e898254b832653fb Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Fri, 8 Jan 2021 22:58:05 -0800 Subject: [PATCH] Simplify some of the project code; clean up project type names --- custom/4coder_project_commands.cpp | 241 ++++++++++++++-------------- custom/4coder_project_commands.h | 52 +++--- custom/generated/command_metadata.h | 22 +-- 3 files changed, 159 insertions(+), 156 deletions(-) diff --git a/custom/4coder_project_commands.cpp b/custom/4coder_project_commands.cpp index 22c6d0c3..a9cb88e4 100644 --- a/custom/4coder_project_commands.cpp +++ b/custom/4coder_project_commands.cpp @@ -186,24 +186,24 @@ prj_parse_pattern_list(Arena *arena, Config *parsed, char *root_variable_name, M } } -function Project_OS_Match_Level +function Prj_OS_Match_Level prj_parse_v1_os_match(String8 str, String8 this_os_str){ - Project_OS_Match_Level result = ProjectOSMatchLevel_NoMatch; + Prj_OS_Match_Level result = PrjOSMatchLevel_NoMatch; if (string_match(str, this_os_str)){ - result = ProjectOSMatchLevel_ActiveMatch; + result = PrjOSMatchLevel_ActiveMatch; } else if (string_match(str, string_u8_litexpr("all"))){ - result = ProjectOSMatchLevel_ActiveMatch; + result = PrjOSMatchLevel_ActiveMatch; } else if (string_match(str, string_u8_litexpr("default"))){ - result = ProjectOSMatchLevel_PassiveMatch; + result = PrjOSMatchLevel_PassiveMatch; } return(result); } -function Project* +function Prj* prj_parse_from_v1_config_data(Application_Links *app, Arena *arena, String8 root_dir, Config *parsed){ - Project *project = push_array_zero(arena, Project, 1); + Prj *project = push_array_zero(arena, Prj, 1); // Set new project directory project->dir = push_string_copy(arena, root_dir); @@ -246,13 +246,13 @@ prj_parse_from_v1_config_data(Application_Links *app, Arena *arena, String8 root if (config_compound_compound_member(parsed, paths_option, "paths", 0, &paths)){ String8 str = {}; if (config_compound_string_member(parsed, paths_option, "os", 1, &str)){ - Project_OS_Match_Level r = prj_parse_v1_os_match(str, string_u8_litexpr(OS_NAME)); - if (r == ProjectOSMatchLevel_ActiveMatch){ + Prj_OS_Match_Level r = prj_parse_v1_os_match(str, string_u8_litexpr(OS_NAME)); + if (r == PrjOSMatchLevel_ActiveMatch){ found_match = true; best_paths = paths; break; } - else if (r == ProjectOSMatchLevel_PassiveMatch){ + else if (r == PrjOSMatchLevel_PassiveMatch){ if (!found_match){ found_match = true; best_paths = paths; @@ -265,10 +265,10 @@ prj_parse_from_v1_config_data(Application_Links *app, Arena *arena, String8 root if (found_match){ Config_Get_Result_List list = typed_compound_array_reference_list(arena, parsed, best_paths); - project->load_path_array.paths = push_array(arena, Project_File_Load_Path, list.count); + project->load_path_array.paths = push_array(arena, Prj_File_Load_Path, list.count); project->load_path_array.count = list.count; - Project_File_Load_Path *dst = project->load_path_array.paths; + Prj_File_Load_Path *dst = project->load_path_array.paths; for (Config_Get_Result_Node *node = list.first; node != 0; node = node->next, ++dst){ @@ -295,10 +295,10 @@ prj_parse_from_v1_config_data(Application_Links *app, Arena *arena, String8 root if (config_compound_var(parsed, "command_list", 0, &compound)){ Config_Get_Result_List list = typed_compound_array_reference_list(arena, parsed, compound); - project->command_array.commands = push_array(arena, Project_Command, list.count); + project->command_array.commands = push_array(arena, Prj_Command, list.count); project->command_array.count = list.count; - Project_Command *dst = project->command_array.commands; + Prj_Command *dst = project->command_array.commands; for (Config_Get_Result_Node *node = list.first; node != 0; node = node->next, ++dst){ @@ -350,13 +350,13 @@ prj_parse_from_v1_config_data(Application_Links *app, Arena *arena, String8 root if (config_compound_string_member(parsed, cmd_option, "cmd", 0, &cmd)){ String8 str = {}; if (config_compound_string_member(parsed, cmd_option, "os", 1, &str)){ - Project_OS_Match_Level r = prj_parse_v1_os_match(str, string_u8_litexpr(OS_NAME)); - if (r == ProjectOSMatchLevel_ActiveMatch){ + Prj_OS_Match_Level r = prj_parse_v1_os_match(str, string_u8_litexpr(OS_NAME)); + if (r == PrjOSMatchLevel_ActiveMatch){ can_emit_command = true; cmd_str = cmd; break; } - else if (r == ProjectOSMatchLevel_PassiveMatch){ + else if (r == PrjOSMatchLevel_PassiveMatch){ if (!can_emit_command){ can_emit_command = true; cmd_str = cmd; @@ -397,7 +397,7 @@ prj_parse_from_v1_config_data(Application_Links *app, Arena *arena, String8 root i32 index = -1; if (config_string_var(parsed, "fkey_command", i, &name)){ i32 count = project->command_array.count; - Project_Command *command_ptr = project->command_array.commands; + Prj_Command *command_ptr = project->command_array.commands; for (i32 j = 0; j < count; ++j, ++command_ptr){ if (string_match(command_ptr->name, name)){ index = j; @@ -431,9 +431,9 @@ project_deep_copy__pattern_list(Arena *arena, Match_Pattern_List *src_list, Matc } } -function Project -project_deep_copy__inner(Arena *arena, Project *project){ - Project result = {}; +function Prj +project_deep_copy__inner(Arena *arena, Prj *project){ + Prj result = {}; result.dir = push_string_copy(arena, project->dir); result.name = push_string_copy(arena, project->name); project_deep_copy__pattern_list(arena, &project->pattern_list, &result.pattern_list); @@ -441,11 +441,11 @@ project_deep_copy__inner(Arena *arena, Project *project){ { i32 path_count = project->load_path_array.count; - result.load_path_array.paths = push_array(arena, Project_File_Load_Path, path_count); + result.load_path_array.paths = push_array(arena, Prj_File_Load_Path, path_count); result.load_path_array.count = path_count; - Project_File_Load_Path *dst = result.load_path_array.paths; - Project_File_Load_Path *src = project->load_path_array.paths; + Prj_File_Load_Path *dst = result.load_path_array.paths; + Prj_File_Load_Path *src = project->load_path_array.paths; for (i32 i = 0; i < path_count; ++i, ++dst, ++src){ dst->path = push_string_copy(arena, src->path); dst->recursive = src->recursive; @@ -455,11 +455,11 @@ project_deep_copy__inner(Arena *arena, Project *project){ { i32 command_count = project->command_array.count; - result.command_array.commands = push_array_zero(arena, Project_Command, command_count); + result.command_array.commands = push_array_zero(arena, Prj_Command, command_count); result.command_array.count = command_count; - Project_Command *dst = result.command_array.commands; - Project_Command *src = project->command_array.commands; + Prj_Command *dst = result.command_array.commands; + Prj_Command *src = project->command_array.commands; for (i32 i = 0; i < command_count; ++i, ++dst, ++src){ if (src->name.str != 0){ dst->name = push_string_copy(arena, src->name); @@ -482,10 +482,10 @@ project_deep_copy__inner(Arena *arena, Project *project){ return(result); } -function Project -project_deep_copy(Arena *arena, Project *project){ +function Prj +project_deep_copy(Arena *arena, Prj *project){ Temp_Memory restore_point = begin_temp(arena); - Project result = project_deep_copy__inner(arena, project); + Prj result = project_deep_copy__inner(arena, project); if (!result.loaded){ end_temp(restore_point); block_zero_struct(&result); @@ -549,7 +549,7 @@ prj_sanitize_string(Arena *arena, String8 string){ } function Variable_Handle -prj_version_1_to_version_2(Application_Links *app, Config *parsed, Project *project){ +prj_version_1_to_version_2(Application_Links *app, Config *parsed, Prj *project){ Scratch_Block scratch(app); String_ID project_id = vars_save_string_lit("prj_config"); @@ -615,7 +615,7 @@ prj_version_1_to_version_2(Application_Links *app, Config *parsed, Project *proj Variable_Handle load_paths = vars_new_variable(proj_var, load_paths_id); Variable_Handle os_var = vars_new_variable(load_paths, os_id); i32 count = project->load_path_array.count; - Project_File_Load_Path *load_path = project->load_path_array.paths; + Prj_File_Load_Path *load_path = project->load_path_array.paths; for (i32 i = 0; i < count; i += 1, load_path += 1){ String_ID key = vars_save_string(push_stringf(scratch, "%d", i)); Variable_Handle path_var = vars_new_variable(os_var, key); @@ -629,7 +629,7 @@ prj_version_1_to_version_2(Application_Links *app, Config *parsed, Project *proj { Variable_Handle cmd_list_var = vars_new_variable(proj_var, commands_id); i32 count = project->command_array.count; - Project_Command *cmd = project->command_array.commands; + Prj_Command *cmd = project->command_array.commands; for (i32 i = 0; i < count; i += 1, cmd += 1){ String8 cmd_name = prj_sanitize_string(scratch, cmd->name); Variable_Handle cmd_var = vars_new_variable(cmd_list_var, vars_save_string(cmd_name)); @@ -647,7 +647,7 @@ prj_version_1_to_version_2(Application_Links *app, Config *parsed, Project *proj for (i32 i = 0; i < 16; i += 1){ i32 cmd_index = project->fkey_commands[i]; if (0 <= cmd_index && cmd_index < project->command_array.count){ - Project_Command *cmd = project->command_array.commands + cmd_index; + Prj_Command *cmd = project->command_array.commands + cmd_index; if (cmd->name.size > 0){ String8 cmd_name = prj_sanitize_string(scratch, cmd->name); String_ID key = vars_save_string(push_stringf(scratch, "%d", i)); @@ -664,9 +664,9 @@ prj_version_1_to_version_2(Application_Links *app, Config *parsed, Project *proj //////////////////////////////// // NOTE(allen): Project Files -function Project_Setup_Status +function Prj_Setup_Status prj_file_is_setup(Application_Links *app, String8 script_path, String8 script_file){ - Project_Setup_Status result = {}; + Prj_Setup_Status result = {}; { Scratch_Block scratch(app); String8 bat_path = push_u8_stringf(scratch, "%.*s/%.*s.bat", @@ -691,62 +691,6 @@ prj_file_is_setup(Application_Links *app, String8 script_path, String8 script_fi return(result); } -function Project_Key_Strings -prj_get_key_strings(Application_Links *app, - b32 get_script_file, b32 get_code_file, - u8 *script_file_space, i32 script_file_cap, - u8 *code_file_space, i32 code_file_cap, - u8 *output_dir_space, i32 output_dir_cap, - u8 *binary_file_space, i32 binary_file_cap){ - Project_Key_Strings keys = {}; - - Query_Bar_Group bar_group(app); - - Query_Bar script_file_bar = {}; - Query_Bar code_file_bar = {}; - Query_Bar output_dir_bar = {}; - Query_Bar binary_file_bar = {}; - - if (get_script_file){ - script_file_bar.prompt = string_u8_litexpr("Script Name: "); - script_file_bar.string = SCu8(script_file_space, (u64)0); - script_file_bar.string_capacity = script_file_cap; - if (!query_user_string(app, &script_file_bar)) return(keys); - if (script_file_bar.string.size == 0) return(keys); - } - - if (get_code_file){ - code_file_bar.prompt = string_u8_litexpr("Build Target: "); - code_file_bar.string = SCu8(code_file_space, (u64)0); - code_file_bar.string_capacity = code_file_cap; - if (!query_user_string(app, &code_file_bar)) return(keys); - if (code_file_bar.string.size == 0) return(keys); - } - - output_dir_bar.prompt = string_u8_litexpr("Output Directory: "); - output_dir_bar.string = SCu8(output_dir_space, (u64)0); - output_dir_bar.string_capacity = output_dir_cap; - if (!query_user_string(app, &output_dir_bar)) return(keys); - if (output_dir_bar.string.size == 0 && output_dir_cap > 0){ - output_dir_bar.string.str[0] = '.'; - output_dir_bar.string.size = 1; - } - - binary_file_bar.prompt = string_u8_litexpr("Binary Output: "); - binary_file_bar.string = SCu8(binary_file_space, (u64)0); - binary_file_bar.string_capacity = binary_file_cap; - if (!query_user_string(app, &binary_file_bar)) return(keys); - if (binary_file_bar.string.size == 0) return(keys); - - keys.success = true; - keys.script_file = script_file_bar.string; - keys.code_file = code_file_bar.string; - keys.output_dir = output_dir_bar.string; - keys.binary_file = binary_file_bar.string; - - return(keys); -} - function b32 prj_generate_bat(Arena *scratch, String8 opts, String8 compiler, String8 script_path, String8 script_file, String8 code_file, String8 output_dir, String8 binary_file){ @@ -884,12 +828,16 @@ prj_generate_project(Arena *scratch, String8 script_path, String8 script_file, S } function void -prj_setup_scripts(Application_Links *app, b32 do_project_file, b32 do_bat_script, b32 do_sh_script){ +prj_setup_scripts(Application_Links *app, Prj_Setup_Script_Flags flags){ Scratch_Block scratch(app); String8 script_path = push_hot_directory(app, scratch); + b32 do_project_file = (flags & PrjSetupScriptFlag_Project); + b32 do_bat_script = (flags & PrjSetupScriptFlag_Bat); + b32 do_sh_script = (flags & PrjSetupScriptFlag_Sh); + b32 needs_to_do_work = false; - Project_Setup_Status status = {}; + Prj_Setup_Status status = {}; if (do_project_file){ status = prj_file_is_setup(app, script_path, string_u8_litexpr("build")); needs_to_do_work = @@ -903,33 +851,84 @@ prj_setup_scripts(Application_Links *app, b32 do_project_file, b32 do_bat_script if (needs_to_do_work){ // Query the User for Key File Names - u8 script_file_space[1024]; - u8 code_file_space [1024]; - u8 output_dir_space [1024]; - u8 binary_file_space[1024]; - b32 get_script_file = !do_project_file; - b32 get_code_file = - (do_bat_script && !status.bat_exists) || - (do_sh_script && !status.sh_exists); + b32 finished_queries = false; + local_const i32 text_field_cap = 1024; - Project_Key_Strings keys = {}; - keys = prj_get_key_strings(app, get_script_file, get_code_file, - script_file_space, sizeof(script_file_space), - code_file_space, sizeof(code_file_space), - output_dir_space, sizeof(output_dir_space), - binary_file_space, sizeof(binary_file_space)); + String8 script_file = {}; + String8 code_file = {}; + String8 output_dir = {}; + String8 binary_file = {}; - if (!keys.success){ + { + Query_Bar_Group bar_group(app); + + Query_Bar script_file_bar = {}; + Query_Bar code_file_bar = {}; + Query_Bar output_dir_bar = {}; + Query_Bar binary_file_bar = {}; + + b32 get_script_file = !do_project_file; + b32 get_code_file = ((do_bat_script && !status.bat_exists) || (do_sh_script && !status.sh_exists)); + + if (get_script_file){ + script_file_bar.prompt = string_u8_litexpr("Script Name: "); + script_file_bar.string.str = push_array(scratch, u8, text_field_cap); + script_file_bar.string_capacity = text_field_cap; + if (!query_user_string(app, &script_file_bar) || + script_file_bar.string.size == 0){ + goto fail_out; + } + } + + if (get_code_file){ + code_file_bar.prompt = string_u8_litexpr("Build Target: "); + code_file_bar.string.str = push_array(scratch, u8, text_field_cap); + code_file_bar.string_capacity = text_field_cap; + if (!query_user_string(app, &code_file_bar) || + code_file_bar.string.size == 0){ + goto fail_out; + } + } + + output_dir_bar.prompt = string_u8_litexpr("Output Directory: "); + output_dir_bar.string.str = push_array(scratch, u8, text_field_cap); + output_dir_bar.string_capacity = text_field_cap; + if (!query_user_string(app, &output_dir_bar)){ + goto fail_out; + } + if (output_dir_bar.string.size == 0){ + output_dir_bar.string.str[0] = '.'; + output_dir_bar.string.size = 1; + } + + binary_file_bar.prompt = string_u8_litexpr("Binary Output: "); + binary_file_bar.string.str = push_array(scratch, u8, text_field_cap); + binary_file_bar.string_capacity = text_field_cap; + if (!query_user_string(app, &binary_file_bar) || + binary_file_bar.string.size == 0){ + goto fail_out; + } + + finished_queries = true; + script_file = script_file_bar.string; + code_file = code_file_bar.string; + output_dir = output_dir_bar.string; + binary_file = binary_file_bar.string; + + fail_out:; + } + + if (!finished_queries){ return; } if (do_project_file){ - keys.script_file = string_u8_litexpr("build"); + script_file = string_u8_litexpr("build"); } if (!do_project_file){ - status = prj_file_is_setup(app, script_path, keys.script_file); + status = prj_file_is_setup(app, script_path, script_file); } // Generate Scripts @@ -938,9 +937,8 @@ prj_setup_scripts(Application_Links *app, b32 do_project_file, b32 do_bat_script String8 default_flags_bat = def_get_config_string(scratch, vars_save_string_lit("default_flags_bat")); String8 default_compiler_bat = def_get_config_string(scratch, vars_save_string_lit("default_compiler_bat")); - if (!prj_generate_bat(scratch, default_flags_bat, default_compiler_bat, - script_path, keys.script_file, - keys.code_file, keys.output_dir, keys.binary_file)){ + if (!prj_generate_bat(scratch, default_flags_bat, default_compiler_bat, script_path, + script_file, code_file, output_dir, binary_file)){ print_message(app, string_u8_litexpr("could not create build.bat for new project\n")); } } @@ -954,8 +952,7 @@ prj_setup_scripts(Application_Links *app, b32 do_project_file, b32 do_bat_script String8 default_flags_sh = def_get_config_string(scratch, vars_save_string_lit("default_flags_sh")); String8 default_compiler_sh = def_get_config_string(scratch, vars_save_string_lit("default_compiler_sh")); if (!prj_generate_sh(scratch, default_flags_sh, default_compiler_sh, - script_path, keys.script_file, - keys.code_file, keys.output_dir, keys.binary_file)){ + script_path, script_file, code_file, output_dir, binary_file)){ print_message(app, string_u8_litexpr("could not create build.sh for new project\n")); } } @@ -966,7 +963,7 @@ prj_setup_scripts(Application_Links *app, b32 do_project_file, b32 do_bat_script if (do_project_file){ if (!status.project_exists){ - if (!prj_generate_project(scratch, script_path, keys.script_file, keys.output_dir, keys.binary_file)){ + if (!prj_generate_project(scratch, script_path, script_file, output_dir, binary_file)){ print_message(app, string_u8_litexpr("could not create project.4coder for new project\n")); } } @@ -1183,7 +1180,7 @@ CUSTOM_DOC("Looks for a project.4coder file in the current directory and tries t case 0: case 1: { - Project *project = prj_parse_from_v1_config_data(app, scratch, project_root, config_parse); + Prj *project = prj_parse_from_v1_config_data(app, scratch, project_root, config_parse); proj_var = prj_version_1_to_version_2(app, config_parse, project); }break; default: @@ -1307,26 +1304,26 @@ CUSTOM_DOC("Changes 4coder's hot directory to the root directory of the currentl CUSTOM_COMMAND_SIG(setup_new_project) CUSTOM_DOC("Queries the user for several configuration options and initializes a new 4coder project with build scripts for every OS.") { - prj_setup_scripts(app, true, true, true); + prj_setup_scripts(app, PrjSetupScriptFlag_Project|PrjSetupScriptFlag_Bat|PrjSetupScriptFlag_Sh); load_project(app); } CUSTOM_COMMAND_SIG(setup_build_bat) CUSTOM_DOC("Queries the user for several configuration options and initializes a new build batch script.") { - prj_setup_scripts(app, false, true, false); + prj_setup_scripts(app, PrjSetupScriptFlag_Bat); } CUSTOM_COMMAND_SIG(setup_build_sh) CUSTOM_DOC("Queries the user for several configuration options and initializes a new build shell script.") { - prj_setup_scripts(app, false, false, true); + prj_setup_scripts(app, PrjSetupScriptFlag_Sh); } CUSTOM_COMMAND_SIG(setup_build_bat_and_sh) CUSTOM_DOC("Queries the user for several configuration options and initializes a new build batch script.") { - prj_setup_scripts(app, false, true, true); + prj_setup_scripts(app, PrjSetupScriptFlag_Bat|PrjSetupScriptFlag_Sh); } CUSTOM_COMMAND_SIG(project_command_lister) diff --git a/custom/4coder_project_commands.h b/custom/4coder_project_commands.h index bd3bbb4b..61789798 100644 --- a/custom/4coder_project_commands.h +++ b/custom/4coder_project_commands.h @@ -7,8 +7,6 @@ #if !defined(FCODER_PROJECT_COMMANDS_H) #define FCODER_PROJECT_COMMANDS_H -// TODO(allen): names pass - //////////////////////////////// // NOTE(allen): Match Pattern Types @@ -35,18 +33,18 @@ enum{ /////////////////////////////// // NOTE(allen): Project v0-v1 Structure -struct Project_File_Load_Path{ +struct Prj_File_Load_Path{ String8 path; b32 recursive; b32 relative; }; -struct Project_File_Load_Path_Array{ - Project_File_Load_Path *paths; +struct Prj_File_Load_Path_Array{ + Prj_File_Load_Path *paths; i32 count; }; -struct Project_Command{ +struct Prj_Command{ String8 name; String8 cmd; String8 out; @@ -55,12 +53,12 @@ struct Project_Command{ b32 cursor_at_end; }; -struct Project_Command_Array{ - Project_Command *commands; +struct Prj_Command_Array{ + Prj_Command *commands; i32 count; }; -struct Project{ +struct Prj{ b32 loaded; String8 dir; @@ -68,29 +66,29 @@ struct Project{ Match_Pattern_List pattern_list; Match_Pattern_List blacklist_pattern_list; - Project_File_Load_Path_Array load_path_array; - Project_Command_Array command_array; + Prj_File_Load_Path_Array load_path_array; + Prj_Command_Array command_array; i32 fkey_commands[16]; }; -enum Project_OS_Match_Level{ - ProjectOSMatchLevel_NoMatch = 0, - ProjectOSMatchLevel_PassiveMatch = 1, - ProjectOSMatchLevel_ActiveMatch = 2, +enum Prj_OS_Match_Level{ + PrjOSMatchLevel_NoMatch = 0, + PrjOSMatchLevel_PassiveMatch = 1, + PrjOSMatchLevel_ActiveMatch = 2, }; /////////////////////////////// // NOTE(allen): Project Files -struct Project_Setup_Status{ +struct Prj_Setup_Status{ b32 bat_exists; b32 sh_exists; b32 project_exists; b32 everything_exists; }; -struct Project_Key_Strings{ +struct Prj_Key_Strings{ b32 success; String8 script_file; String8 code_file; @@ -98,6 +96,13 @@ struct Project_Key_Strings{ String8 binary_file; }; +typedef u32 Prj_Setup_Script_Flags; +enum{ + PrjSetupScriptFlag_Project = 0x1, + PrjSetupScriptFlag_Bat = 0x2, + PrjSetupScriptFlag_Sh = 0x4, +}; + //////////////////////////////// // NOTE(allen): File Pattern Operators @@ -115,22 +120,23 @@ function void prj_open_all_files_with_ext_in_hot(Application_Links *app, String8 // NOTE(allen): Project Parse function void prj_parse_pattern_list(Arena *arena, Config *parsed, char *root_variable_name, Match_Pattern_List *list_out); -function Project_OS_Match_Level prj_parse_v1_os_match(String8 str, String8 this_os_str); -function Project *prj_parse_from_v1_config_data(Application_Links *app, Arena *arena, String8 root_dir, Config *parsed); +function Prj_OS_Match_Level prj_parse_v1_os_match(String8 str, String8 this_os_str); +function Prj *prj_parse_from_v1_config_data(Application_Links *app, Arena *arena, String8 root_dir, Config *parsed); function String8 prj_join_pattern_string(Arena *arena, String8List list); function String8 prj_sanitize_string(Arena *arena, String8 string); -function Variable_Handle prj_version_1_to_version_2(Application_Links *app, Config *parsed, Project *project); +function Variable_Handle prj_version_1_to_version_2(Application_Links *app, Config *parsed, Prj *project); //////////////////////////////// // NOTE(allen): Project Files -function Project_Setup_Status prj_file_is_setup(Application_Links *app, String8 script_path, String8 script_file); -function Project_Key_Strings prj_get_key_strings(Application_Links *app, b32 get_script_file, b32 get_code_file, u8* script_file_space, i32 script_file_cap, u8* code_file_space, i32 code_file_cap, u8* output_dir_space, i32 output_dir_cap, u8* binary_file_space, i32 binary_file_cap); +function Prj_Setup_Status prj_file_is_setup(Application_Links *app, String8 script_path, String8 script_file); function b32 prj_generate_bat(Arena *scratch, String8 opts, String8 compiler, String8 script_path, String8 script_file, String8 code_file, String8 output_dir, String8 binary_file); function b32 prj_generate_sh(Arena *scratch, String8 opts, String8 compiler, String8 script_path, String8 script_file, String8 code_file, String8 output_dir, String8 binary_file); function b32 prj_generate_project(Arena *scratch, String8 script_path, String8 script_file, String8 output_dir, String8 binary_file); +function void prj_setup_scripts(Application_Links *app, Prj_Setup_Script_Flags flags); + //////////////////////////////// // NOTE(allen): Project Operations @@ -139,7 +145,7 @@ function Variable_Handle prj_command_from_name(Application_Links *app, String8 c function void prj_exec_command_name(Application_Links *app, String8 cmd_name); function void prj_exec_command_fkey_index(Application_Links *app, i32 fkey_index); -function String8 prj_path_from_project(Arena *arena, Variable_Handle project); +function String8 prj_path_from_project(Arena *arena, Variable_Handle project); function Variable_Handle prj_cmd_from_user(Application_Links *app, Variable_Handle prj_var, String8 query); #endif diff --git a/custom/generated/command_metadata.h b/custom/generated/command_metadata.h index bca96942..24edc22a 100644 --- a/custom/generated/command_metadata.h +++ b/custom/generated/command_metadata.h @@ -295,7 +295,7 @@ static Command_Metadata fcoder_metacmd_table[250] = { { PROC_LINKS(click_set_cursor_if_lbutton, 0), false, "click_set_cursor_if_lbutton", 27, "If the mouse left button is pressed, sets the cursor position to the mouse position.", 84, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 243 }, { PROC_LINKS(click_set_mark, 0), false, "click_set_mark", 14, "Sets the mark position to the mouse position.", 45, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 256 }, { PROC_LINKS(clipboard_record_clip, 0), false, "clipboard_record_clip", 21, "In response to a new clipboard contents events, saves the new clip onto the clipboard history", 93, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 7 }, -{ PROC_LINKS(close_all_code, 0), false, "close_all_code", 14, "Closes any buffer with a filename ending with an extension configured to be recognized as a code file type.", 107, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1126 }, +{ PROC_LINKS(close_all_code, 0), false, "close_all_code", 14, "Closes any buffer with a filename ending with an extension configured to be recognized as a code file type.", 107, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1123 }, { PROC_LINKS(close_build_panel, 0), false, "close_build_panel", 17, "If the special build panel is open, closes it.", 46, "W:\\4ed\\code\\custom\\4coder_build_commands.cpp", 44, 175 }, { PROC_LINKS(close_panel, 0), false, "close_panel", 11, "Closes the currently active panel if it is not the only panel open.", 67, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 674 }, { PROC_LINKS(command_documentation, 0), true, "command_documentation", 21, "Prompts the user to select a command then loads a doc buffer for that item", 74, "W:\\4ed\\code\\custom\\4coder_docs.cpp", 34, 190 }, @@ -371,7 +371,7 @@ static Command_Metadata fcoder_metacmd_table[250] = { { PROC_LINKS(list_all_locations_of_type_definition_of_identifier, 0), false, "list_all_locations_of_type_definition_of_identifier", 51, "Reads a token or word under the cursor and lists all locations of strings that appear to define a type whose name matches it.", 125, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 224 }, { PROC_LINKS(list_all_substring_locations, 0), false, "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 174 }, { PROC_LINKS(list_all_substring_locations_case_insensitive, 0), false, "list_all_substring_locations_case_insensitive", 45, "Queries the user for a string and lists all case-insensitive substring matches found in all open buffers.", 105, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 186 }, -{ PROC_LINKS(load_project, 0), false, "load_project", 12, "Looks for a project.4coder file in the current directory and tries to load it. Looks in parent directories until a project file is found or there are no more parents.", 167, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1153 }, +{ PROC_LINKS(load_project, 0), false, "load_project", 12, "Looks for a project.4coder file in the current directory and tries to load it. Looks in parent directories until a project file is found or there are no more parents.", 167, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1150 }, { PROC_LINKS(load_theme_current_buffer, 0), false, "load_theme_current_buffer", 25, "Parse the current buffer as a theme file and add the theme to the theme list. If the buffer has a .4coder postfix in it's name, it is removed when the name is saved.", 165, "W:\\4ed\\code\\custom\\4coder_config.cpp", 36, 1583 }, { PROC_LINKS(load_themes_default_folder, 0), false, "load_themes_default_folder", 26, "Loads all the theme files in the default theme folder.", 54, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 535 }, { PROC_LINKS(load_themes_hot_directory, 0), false, "load_themes_hot_directory", 25, "Loads all the theme files in the current hot directory.", 55, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 547 }, @@ -414,8 +414,8 @@ static Command_Metadata fcoder_metacmd_table[250] = { { PROC_LINKS(multi_paste_interactive_quick, 0), false, "multi_paste_interactive_quick", 29, "Paste multiple lines from the clipboard history, controlled by inputing the number of lines to paste", 100, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 380 }, { PROC_LINKS(music_start, 0), false, "music_start", 11, "Starts the music.", 17, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 213 }, { PROC_LINKS(music_stop, 0), false, "music_stop", 10, "Stops the music.", 16, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 232 }, -{ PROC_LINKS(open_all_code, 0), false, "open_all_code", 13, "Open all code in the current directory. File types are determined by extensions. An extension is considered code based on the extensions specified in 4coder.config.", 164, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1135 }, -{ PROC_LINKS(open_all_code_recursive, 0), false, "open_all_code_recursive", 23, "Works as open_all_code but also runs in all subdirectories.", 59, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1144 }, +{ PROC_LINKS(open_all_code, 0), false, "open_all_code", 13, "Open all code in the current directory. File types are determined by extensions. An extension is considered code based on the extensions specified in 4coder.config.", 164, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1132 }, +{ PROC_LINKS(open_all_code_recursive, 0), false, "open_all_code_recursive", 23, "Works as open_all_code but also runs in all subdirectories.", 59, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1141 }, { PROC_LINKS(open_file_in_quotes, 0), false, "open_file_in_quotes", 19, "Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.", 94, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1576 }, { PROC_LINKS(open_in_other, 0), false, "open_in_other", 13, "Interactively opens a file in the other panel.", 46, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 2059 }, { PROC_LINKS(open_long_braces, 0), false, "open_long_braces", 16, "At the cursor, insert a '{' and '}' separated by a blank line.", 62, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 46 }, @@ -436,9 +436,9 @@ static Command_Metadata fcoder_metacmd_table[250] = { { PROC_LINKS(profile_disable, 0), false, "profile_disable", 15, "Prevent 4coder's self profiler from gathering new profiling information.", 72, "W:\\4ed\\code\\custom\\4coder_profile.cpp", 37, 219 }, { PROC_LINKS(profile_enable, 0), false, "profile_enable", 14, "Allow 4coder's self profiler to gather new profiling information.", 65, "W:\\4ed\\code\\custom\\4coder_profile.cpp", 37, 212 }, { PROC_LINKS(profile_inspect, 0), true, "profile_inspect", 15, "Inspect all currently collected profiling information in 4coder's self profiler.", 80, "W:\\4ed\\code\\custom\\4coder_profile_inspect.cpp", 45, 886 }, -{ PROC_LINKS(project_command_lister, 0), false, "project_command_lister", 22, "Open a lister of all commands in the currently loaded project.", 62, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1332 }, -{ PROC_LINKS(project_fkey_command, 0), false, "project_fkey_command", 20, "Run an 'fkey command' configured in a project.4coder file. Determines the index of the 'fkey command' by which function key or numeric key was pressed to trigger the command.", 175, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1270 }, -{ PROC_LINKS(project_go_to_root_directory, 0), false, "project_go_to_root_directory", 28, "Changes 4coder's hot directory to the root directory of the currently loaded project. With no loaded project nothing hapepns.", 125, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1296 }, +{ PROC_LINKS(project_command_lister, 0), false, "project_command_lister", 22, "Open a lister of all commands in the currently loaded project.", 62, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1329 }, +{ PROC_LINKS(project_fkey_command, 0), false, "project_fkey_command", 20, "Run an 'fkey command' configured in a project.4coder file. Determines the index of the 'fkey command' by which function key or numeric key was pressed to trigger the command.", 175, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1267 }, +{ PROC_LINKS(project_go_to_root_directory, 0), false, "project_go_to_root_directory", 28, "Changes 4coder's hot directory to the root directory of the currently loaded project. With no loaded project nothing hapepns.", 125, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1293 }, { PROC_LINKS(query_replace, 0), false, "query_replace", 13, "Queries the user for two strings, and incrementally replaces every occurence of the first string with the second string.", 120, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1282 }, { PROC_LINKS(query_replace_identifier, 0), false, "query_replace_identifier", 24, "Queries the user for a string, and incrementally replace every occurence of the word or token found at the cursor with the specified string.", 140, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1303 }, { PROC_LINKS(query_replace_selection, 0), false, "query_replace_selection", 23, "Queries the user for a string, and incrementally replace every occurence of the string found in the selected range with the specified string.", 141, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1319 }, @@ -477,10 +477,10 @@ static Command_Metadata fcoder_metacmd_table[250] = { { PROC_LINKS(set_mark, 0), false, "set_mark", 8, "Sets the mark to the current position of the cursor.", 52, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 115 }, { PROC_LINKS(set_mode_to_notepad_like, 0), false, "set_mode_to_notepad_like", 24, "Sets the edit mode to Notepad like.", 35, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 499 }, { PROC_LINKS(set_mode_to_original, 0), false, "set_mode_to_original", 20, "Sets the edit mode to 4coder original.", 38, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 493 }, -{ PROC_LINKS(setup_build_bat, 0), false, "setup_build_bat", 15, "Queries the user for several configuration options and initializes a new build batch script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1314 }, -{ PROC_LINKS(setup_build_bat_and_sh, 0), false, "setup_build_bat_and_sh", 22, "Queries the user for several configuration options and initializes a new build batch script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1326 }, -{ PROC_LINKS(setup_build_sh, 0), false, "setup_build_sh", 14, "Queries the user for several configuration options and initializes a new build shell script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1320 }, -{ PROC_LINKS(setup_new_project, 0), false, "setup_new_project", 17, "Queries the user for several configuration options and initializes a new 4coder project with build scripts for every OS.", 120, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1307 }, +{ PROC_LINKS(setup_build_bat, 0), false, "setup_build_bat", 15, "Queries the user for several configuration options and initializes a new build batch script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1311 }, +{ PROC_LINKS(setup_build_bat_and_sh, 0), false, "setup_build_bat_and_sh", 22, "Queries the user for several configuration options and initializes a new build batch script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1323 }, +{ PROC_LINKS(setup_build_sh, 0), false, "setup_build_sh", 14, "Queries the user for several configuration options and initializes a new build shell script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1317 }, +{ PROC_LINKS(setup_new_project, 0), false, "setup_new_project", 17, "Queries the user for several configuration options and initializes a new 4coder project with build scripts for every OS.", 120, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1304 }, { PROC_LINKS(show_filebar, 0), false, "show_filebar", 12, "Sets the current view to show it's filebar.", 43, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 697 }, { PROC_LINKS(show_scrollbar, 0), false, "show_scrollbar", 14, "Sets the current view to show it's scrollbar.", 45, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 683 }, { PROC_LINKS(show_the_log_graph, 0), true, "show_the_log_graph", 18, "Parses *log* and displays the 'log graph' UI", 44, "W:\\4ed\\code\\custom\\4coder_log_parser.cpp", 40, 991 },