Project version up-converter
parent
c153a05de2
commit
f0339a9eb7
|
@ -624,6 +624,30 @@ config_feedback_command_array(Arena *arena, List_String_Const_u8 *list, char *na
|
|||
string_list_push_u8_lit(arena, list, "};\n");
|
||||
}
|
||||
|
||||
// NOTE(allen): string list join ("flatten") doesn't really work... :(
|
||||
function String_Const_u8
|
||||
prj_join_pattern_string(Arena *arena, List_String_Const_u8 list){
|
||||
String_Const_u8 pattern_string = {};
|
||||
pattern_string.size = list.total_size + list.node_count - 1;
|
||||
pattern_string.str = push_array(arena, u8, pattern_string.size + 1);
|
||||
u8 *ptr = pattern_string.str;
|
||||
Node_String_Const_u8 *node = list.first;
|
||||
if (node != 0){
|
||||
for (;;){
|
||||
block_copy(ptr, node->string.str, node->string.size);
|
||||
ptr += node->string.size;
|
||||
node = node->next;
|
||||
if (node == 0){
|
||||
break;
|
||||
}
|
||||
*ptr = '*';
|
||||
ptr += 1;
|
||||
}
|
||||
}
|
||||
pattern_string.str[pattern_string.size] = 0;
|
||||
return(pattern_string);
|
||||
}
|
||||
|
||||
function void
|
||||
set_current_project(Application_Links *app, Project *project, Config *parsed){
|
||||
b32 print_feedback = false;
|
||||
|
@ -690,6 +714,116 @@ set_current_project(Application_Links *app, Project *project, Config *parsed){
|
|||
print_feedback = true;
|
||||
}
|
||||
|
||||
if (project != 0){
|
||||
Variable_Handle proj_var = {};
|
||||
|
||||
if (parsed->version == 0 || *parsed->version < 2){
|
||||
#if 0
|
||||
struct Project{
|
||||
b32 loaded;
|
||||
|
||||
String_Const_u8 dir;
|
||||
String_Const_u8 name;
|
||||
|
||||
Project_File_Pattern_Array pattern_array;
|
||||
Project_File_Pattern_Array blacklist_pattern_array;
|
||||
Project_File_Load_Path_Array load_path_array;
|
||||
Project_Command_Array command_array;
|
||||
|
||||
i32 fkey_commands[16];
|
||||
};
|
||||
#endif
|
||||
|
||||
print_message(app, string_u8_litexpr("Project variables converted from version 1 to version 2\n"));
|
||||
|
||||
String_ID project_id = vars_save_string(string_litinit("project"));
|
||||
String_ID version_id = vars_save_string(string_litinit("version"));
|
||||
String_ID project_name_id = vars_save_string(string_litinit("project_name"));
|
||||
String_ID patterns_id = vars_save_string(string_litinit("patterns"));
|
||||
String_ID blacklist_patterns_id = vars_save_string(string_litinit("blacklist_patterns"));
|
||||
|
||||
String_ID load_paths_id = vars_save_string(string_litinit("load_paths"));
|
||||
String_ID path_id = vars_save_string(string_litinit("path"));
|
||||
String_ID recursive_id = vars_save_string(string_litinit("recursive"));
|
||||
String_ID relative_id = vars_save_string(string_litinit("relative"));
|
||||
String_ID true_id = vars_save_string(string_litinit("true"));
|
||||
String_ID false_id = vars_save_string(string_litinit("false"));
|
||||
|
||||
String_ID command_list_id = vars_save_string(string_litinit("command_list"));
|
||||
String_ID out_id = vars_save_string(string_litinit("out"));
|
||||
String_ID footer_panel_id = vars_save_string(string_litinit("footer_panel"));
|
||||
String_ID save_dirty_files_id = vars_save_string(string_litinit("save_dirty_files"));
|
||||
String_ID cursor_at_end_id = vars_save_string(string_litinit("cursor_at_end"));
|
||||
|
||||
String_ID os_id = vars_save_string(string_litinit("win"));;
|
||||
|
||||
proj_var = vars_new_variable(vars_get_root(), project_id, vars_save_string(parsed->file_name));
|
||||
|
||||
if (parsed->version != 0){
|
||||
String_Const_u8 version_str = push_stringf(scratch, "%d", *parsed->version);
|
||||
vars_new_variable(proj_var, version_id, vars_save_string(version_str));
|
||||
}
|
||||
|
||||
vars_new_variable(proj_var, project_name_id, vars_save_string(project->name));
|
||||
|
||||
struct PatternVars{
|
||||
String_ID id;
|
||||
Project_File_Pattern_Array array;
|
||||
};
|
||||
PatternVars pattern_vars[] = {
|
||||
{ patterns_id, project-> pattern_array},
|
||||
{blacklist_patterns_id, project->blacklist_pattern_array},
|
||||
};
|
||||
|
||||
PatternVars *pattern_var = pattern_vars;
|
||||
PatternVars *opl = pattern_vars + ArrayCount(pattern_vars);
|
||||
for (; pattern_var < opl; pattern_var += 1){
|
||||
Variable_Handle patterns = vars_new_variable(proj_var, pattern_var->id);
|
||||
i32 count = pattern_var->array.count;
|
||||
Project_File_Pattern *pattern = pattern_var->array.patterns;
|
||||
for (i32 i = 0; i < count; i += 1, pattern += 1){
|
||||
String_Const_u8 pattern_string = prj_join_pattern_string(scratch, pattern->absolutes);
|
||||
String_ID key = vars_save_string(push_stringf(scratch, "%d", i));
|
||||
String_ID pattern_id = vars_save_string(pattern_string);
|
||||
vars_new_variable(patterns, key, pattern_id);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
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;
|
||||
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);
|
||||
vars_new_variable(path_var, path_id, vars_save_string(load_path->path));
|
||||
vars_new_variable(path_var, recursive_id, load_path->recursive?true_id:false_id);
|
||||
vars_new_variable(path_var, relative_id, load_path->recursive?true_id:false_id);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
Variable_Handle cmds_var = vars_new_variable(proj_var, command_list_id);
|
||||
i32 count = project->command_array.count;
|
||||
Project_Command *cmd = project->command_array.commands;
|
||||
for (i32 i = 0; i < count; i += 1, cmd += 1){
|
||||
Variable_Handle cmd_var = vars_new_variable(cmds_var, vars_save_string(cmd->name));
|
||||
vars_new_variable(cmd_var, os_id, vars_save_string(cmd->cmd));
|
||||
vars_new_variable(cmd_var, out_id, vars_save_string(cmd->out));
|
||||
vars_new_variable(cmd_var, footer_panel_id, cmd->footer_panel?true_id:false_id);
|
||||
vars_new_variable(cmd_var, save_dirty_files_id, cmd->save_dirty_files?true_id:false_id);
|
||||
vars_new_variable(cmd_var, cursor_at_end_id, cmd->cursor_at_end?true_id:false_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
proj_var = def_var_from_config(app, vars_get_root(), string_litinit("project"), parsed);
|
||||
}
|
||||
|
||||
vars_print(app, proj_var);
|
||||
}
|
||||
|
||||
if (print_feedback){
|
||||
Temp_Memory temp = begin_temp(scratch);
|
||||
|
||||
|
@ -698,21 +832,12 @@ set_current_project(Application_Links *app, Project *project, Config *parsed){
|
|||
if (project == 0){
|
||||
print_message(app, string_u8_litexpr("Could not instantiate project\n"));
|
||||
}
|
||||
else if (error_text.size > 0){
|
||||
if (error_text.size > 0){
|
||||
print_message(app, string_u8_litexpr("Project errors:\n"));
|
||||
print_message(app, error_text);
|
||||
print_message(app, string_u8_litexpr("\n"));
|
||||
}
|
||||
|
||||
// NOTE(allen): save project
|
||||
else{
|
||||
// TODO(allen): if version <= 1 convert by hand
|
||||
// otherwise do direct drop like so:
|
||||
|
||||
Variable_Handle proj_var = def_var_from_config(app, vars_get_root(), string_litinit("project"), parsed);
|
||||
vars_print(app, proj_var);
|
||||
}
|
||||
|
||||
end_temp(temp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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, 834 },
|
||||
{ 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, 959 },
|
||||
{ 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, 174 },
|
||||
{ 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, 854 },
|
||||
{ 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, 979 },
|
||||
{ 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, 1661 },
|
||||
{ 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, 533 },
|
||||
{ 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, 545 },
|
||||
|
@ -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, 840 },
|
||||
{ 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, 846 },
|
||||
{ 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, 965 },
|
||||
{ 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, 971 },
|
||||
{ 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, 1574 },
|
||||
{ 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, 2056 },
|
||||
{ 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, 1280 },
|
||||
{ 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, 862 },
|
||||
{ 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, 888 },
|
||||
{ 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, 1405 },
|
||||
{ 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, 987 },
|
||||
{ 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, 1013 },
|
||||
{ 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, 1280 },
|
||||
{ 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, 1301 },
|
||||
{ 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, 1317 },
|
||||
|
@ -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, 503 },
|
||||
{ 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, 497 },
|
||||
{ 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, 1229 },
|
||||
{ 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, 1241 },
|
||||
{ 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, 1235 },
|
||||
{ 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, 1222 },
|
||||
{ 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, 1354 },
|
||||
{ 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, 1366 },
|
||||
{ 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, 1360 },
|
||||
{ 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, 1347 },
|
||||
{ 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, 993 },
|
||||
|
|
|
@ -34,7 +34,7 @@ build_x86_mac = "echo build: x86 & bin/build-mac.sh -DDEV_BUILD_X86";
|
|||
command_list = {
|
||||
{ .name = "build x64",
|
||||
.out = "*compilation*", .footer_panel = true, .save_dirty_files = true,
|
||||
.cmd = { {build_x64_win32, .os = "win" },
|
||||
.cmd = { {build_x64_win32, .os = "win" },
|
||||
{build_x64_linux, .os = "linux"},
|
||||
{build_x64_mac , .os = "mac" }, }, },
|
||||
|
||||
|
|
Loading…
Reference in New Issue