Package script updated

master
Allen Webster 2019-11-06 21:58:08 -08:00
parent 0bae74aa48
commit 6e97a504a9
9 changed files with 811 additions and 847 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,3 @@
@echo off
build.bat /DPACKAGE
bin\build.bat /DPACKAGE

View File

@ -57,7 +57,7 @@ internal void fm_make_folder_if_missing(Arena *arena, char *dir);
internal void fm_clear_folder(char *folder);
internal void fm_delete_file(char *file);
internal void fm_copy_file(char *file, char *newname);
internal void fm_copy_all(char *source, char *tag, char *folder);
internal void fm_copy_all(char *source, char *folder);
internal void fm_copy_folder(Arena *arena, char *src_dir, char *dst_dir, char *src_folder);
// File Reading and Writing
@ -352,6 +352,7 @@ fm_make_folder_if_missing(Arena *arena, char *dir){
internal void
fm_clear_folder(char *folder){
fprintf(stdout, "clearing folder %s\n", folder);
fflush(stdout);
systemf("del /S /Q /F %s\\* > nul & rmdir /S /Q %s > nul & mkdir %s > nul", folder, folder, folder);
}
@ -362,19 +363,16 @@ fm_delete_file(char *file){
internal void
fm_copy_file(char *file, char *newname){
printf("copy %s to %s\n", file, newname);
fflush(stdout);
CopyFileA(file, newname, 0);
}
internal void
fm_copy_all(char *source, char *tag, char *folder){
if (source){
fprintf(stdout, "copy %s\\%s to %s\n", source, tag, folder);
systemf("copy %s\\%s %s\\* > nul", source, tag, folder);
}
else{
fprintf(stdout, "copy %s to %s\n", tag, folder);
systemf("copy %s %s\\* > nul", tag, folder);
}
fm_copy_all(char *source, char *folder){
fprintf(stdout, "copy %s to %s\n", source, folder);
fflush(stdout);
systemf("xcopy /s /e /y /q %s %s > nul", source, folder);
}
internal void
@ -396,14 +394,17 @@ fm_write_file(char *file_name, char *data, u32 size){
internal void
fm_zip(char *parent, char *folder, char *dest){
printf("zipping %s\\%s to %s\n", parent, folder, dest);
fflush(stdout);
char cdir[512];
fm_get_current_directory(cdir, sizeof(cdir));
Temp_Dir temp = fm_pushdir(parent);
systemf("%s\\zip %s\\4ed_gobble.zip", cdir, cdir);
systemf("%s\\bin\\zip %s\\4ed_gobble.zip > nul", cdir, cdir);
fm_popdir(temp);
systemf("copy %s\\4ed_gobble.zip %s & del %s\\4ed_gobble.zip", cdir, dest, cdir);
systemf("copy %s\\4ed_gobble.zip %s > nul & del %s\\4ed_gobble.zip > nul", cdir, dest, cdir);
}
//
@ -492,6 +493,7 @@ fm_make_folder_if_missing(Partition *part, char *dir){
internal void
fm_clear_folder(char *folder){
fprintf(stdout, "clearing folder %s\n", folder);
fflush(stdout);
systemf("rm -rf %s* > /dev/null", folder);
}
@ -544,7 +546,7 @@ fm_copy_folder(Arena *arena, char *src_dir, char *dst_dir, char *src_folder){
Temp_Dir temp = fm_pushdir(src_dir);
fm_make_folder_if_missing(arena, fm_str(arena, dst_dir, "/", src_folder));
char *copy_name = fm_str(arena, dst_dir, "/", src_folder);
fm_copy_all(src_folder, "*", copy_name);
fm_copy_all(src_folder, copy_name);
fm_popdir(temp);
}

View File

@ -136,11 +136,7 @@ get_standard_blacklist(Arena *arena){
}
function void
open_files_pattern_match(Application_Links *app,
String_Const_u8 dir,
Project_File_Pattern_Array whitelist,
Project_File_Pattern_Array blacklist,
u32 flags){
open_files_pattern_match(Application_Links *app, String_Const_u8 dir, Project_File_Pattern_Array whitelist, Project_File_Pattern_Array blacklist, u32 flags){
ProfileScope(app, "open all files in directory pattern");
Scratch_Block scratch(app);
String_Const_u8 directory = dir;
@ -181,79 +177,6 @@ open_all_files_in_hot_with_extension(Application_Links *app, String_Const_u8_Arr
# error no project configuration names for this platform
#endif
function Project*
parse_project__config_data__version_0(Application_Links *app, Arena *arena,
String_Const_u8 file_dir, Config *parsed){
Project *project = push_array_zero(arena, Project, 1);
// Set new project directory
{
project->dir = push_string_copy(arena, file_dir);
project->load_path_array.paths = push_array(arena, Project_File_Load_Path, 1);
project->load_path_array.count = 1;
project->load_path_array.paths[0].path = project->dir;
project->load_path_array.paths[0].recursive = false;
project->load_path_array.paths[0].relative = false;
project->name = project->dir;
}
// Read the settings from project.4coder
String_Const_u8 str = {};
if (config_string_var(parsed, "extensions", 0, &str)){
String_Const_u8_Array extension_list =
parse_extension_line_to_extension_list(app, arena, str);
project->pattern_array = get_pattern_array_from_string_array(arena, extension_list);
project->blacklist_pattern_array = get_standard_blacklist(arena);
}
b32 open_recursively = false;
if (config_bool_var(parsed, "open_recursively", 0, &open_recursively)){
project->load_path_array.paths[0].recursive = open_recursively;
}
char fkey_command_name[] = "fkey_command_" PlatformName;
project->command_array.commands = push_array(arena, Project_Command, 16);
project->command_array.count = 16;
Project_Command *command = project->command_array.commands;
for (i32 j = 1; j <= 16; ++j, ++command){
project->fkey_commands[j - 1] = j - 1;
block_zero_struct(command);
command->name = push_u8_stringf(arena, "%d", j);
Config_Compound *compound = 0;
if (config_compound_var(parsed, fkey_command_name, j, &compound)){
String_Const_u8 cmd = {};
if (config_compound_string_member(parsed, compound, "cmd", 0, &cmd)){
command->cmd = push_string_copy(arena, cmd);
}
String_Const_u8 out = {};
if (config_compound_string_member(parsed, compound, "out", 1, &out)){
command->out = push_string_copy(arena, out);
}
b32 footer_panel = false;
if (config_compound_bool_member(parsed, compound, "footer_panel", 2, &footer_panel)){
command->footer_panel = footer_panel;
}
b32 save_dirty_files = false;
if (config_compound_bool_member(parsed, compound, "save_dirty_files", 3, &save_dirty_files)){
command->save_dirty_files = save_dirty_files;
}
}
}
project->loaded = true;
return(project);
}
function void
parse_project__extract_pattern_array(Arena *arena, Config *parsed, char *root_variable_name, Project_File_Pattern_Array *array_out){
Config_Compound *compound = 0;
@ -288,8 +211,7 @@ parse_project__version_1__os_match(String_Const_u8 str, String_Const_u8 this_os_
}
function Project*
parse_project__config_data__version_1(Application_Links *app, Arena *arena,
String_Const_u8 root_dir, Config *parsed){
parse_project__config_data__version_1(Application_Links *app, Arena *arena, String_Const_u8 root_dir, Config *parsed){
Project *project = push_array_zero(arena, Project, 1);
// Set new project directory
@ -502,34 +424,25 @@ parse_project__config_data__version_1(Application_Links *app, Arena *arena,
}
function Project*
parse_project__config_data(Application_Links *app, Arena *arena,
String_Const_u8 file_dir, Config *parsed){
parse_project__config_data(Application_Links *app, Arena *arena, String_Const_u8 file_dir, Config *parsed){
i32 version = 0;
if (parsed->version != 0){
version = *parsed->version;
}
Project *result = 0;
switch (version){
case 0:
{
return(parse_project__config_data__version_0(app, arena, file_dir, parsed));
}break;
case 1:
{
return(parse_project__config_data__version_1(app, arena, file_dir, parsed));
}break;
default:
{
return(0);
result = parse_project__config_data__version_1(app, arena, file_dir, parsed);
}break;
}
return(result);
}
function Project_Parse_Result
parse_project__data(Application_Links *app, Arena *arena, String_Const_u8 file_name,
Data raw_data, String_Const_u8 file_dir){
parse_project__data(Application_Links *app, Arena *arena, String_Const_u8 file_name, Data raw_data, String_Const_u8 file_dir){
String_Const_u8 data = SCu8(raw_data);
Project_Parse_Result result = {};
Token_Array array = token_array_from_text(app, arena, data);

View File

@ -1,34 +1,52 @@
@echo off
REM This stores the path of the buildsuper.bat script
REM in CODE_HOME. This way you can always include the
REM default files no matter where you store your code.
REM And no matter how you call buildsuper.bat.
set code_home=%~dp0
if %code_home:~-1%==\ (set code_home=%code_home:~0,-1%)
REM usage: <script> [target [mode]]
REM works from any directory, but must remain in custom/bin path to work
REM target : if specified determines the file that acts as the build target
REM when not specified the build target is 4coder_default_bindings.cpp
REM mode : if set to "release" builds with optimizations
REM The build steps are:
REM 1. preprocess the build target
REM 2. build the metadata generator
REM 3. run the metadata generator on the result from (1)
REM 4. build the build target
REM 5. cleanup after the metadata generator
REM All output files are generated in the current directory when the script is run
if NOT "%Platform%" == "X86" IF NOT "%Platform%" == "x86" (call "%code_home%\windows_scripts\setup_cl_x86.bat")
set location=%cd%
set me="%~dp0"
cd %me%
cd ..
set custom_root=%cd%
set custom_bin=%custom_root%\bin
cd %location%
set src=%1
if "%src%" == "" set src=4coder_default_bindings.cpp
if NOT "%Platform%" == "X86" IF NOT "%Platform%" == "x86" (call "%custom_bin%\setup_cl_x86.bat")
set target=%1
if "%target%" == "" set target=%custom_root%\4coder_default_bindings.cpp
set opts=/W4 /wd4310 /wd4100 /wd4201 /wd4505 /wd4996 /wd4127 /wd4510 /wd4512 /wd4610 /wd4457 /WX
set opts=%opts% /GR- /nologo /FC
set debug=/Zi
set release=/O2 /Zi
set build_dll=/LD /link /INCREMENTAL:NO /OPT:REF
set build_dll=%build_dll% /EXPORT:get_version /EXPORT:init_apis
set mode=%debug%
if "%2" == "release" (set mode=%release%)
set preproc_file=4coder_command_metadata.i
set meta_macros=/DMETA_PASS
cl /I"%code_home%" %opts% %mode% %src% /P /Fi%preproc_file% %meta_macros%
cl /I"%code_home%" %opts% %mode% "%code_home%\4coder_metadata_generator.cpp" /Femetadata_generator
metadata_generator -R "%code_home%" "%cd%\\%preproc_file%"
set opts=/W4 /wd4310 /wd4100 /wd4201 /wd4505 /wd4996 /wd4127 /wd4510 /wd4512 /wd4610 /wd4457 /WX
set opts=%opts% /GR- /nologo /FC
set opts=%opts% -I%custom_root%
set opts=%opts% %mode%
cl %opts% /I"%code_home%" %mode% "%src%" /Fecustom_4coder %build_dll% %exports%
set preproc_file=4coder_command_metadata.i
set meta_opts=/P /Fi%preproc_file% /DMETA_PASS
set build_dll=/LD /link /INCREMENTAL:NO /OPT:REF /RELEASE /PDBALTPATH:%%%%_PDB%%%%
set build_dll=%build_dll% /EXPORT:get_version /EXPORT:init_apis
call cl %opts% %meta_opts% %target%
call cl %opts% "%custom_root%\4coder_metadata_generator.cpp" /Femetadata_generator
metadata_generator -R "%custom_root%" "%cd%\%preproc_file%"
call cl %opts% %target% /Fecustom_4coder %build_dll%
REM file spammation preventation
del metadata_generator*

View File

@ -405,17 +405,17 @@ static Command_Metadata fcoder_metacmd_table[214] = {
{ PROC_LINKS(build_in_build_panel, 0), false, "build_in_build_panel", 20, "Looks for a build.bat, build.sh, or makefile in the current and parent directories. Runs the first that it finds and prints the output to *compilation*. Puts the *compilation* buffer in a panel at the footer of the current view.", 230, "w:\\4ed\\code\\custom\\4coder_build_commands.cpp", 44, 163 },
{ 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, 178 },
{ PROC_LINKS(change_to_build_panel, 0), false, "change_to_build_panel", 21, "If the special build panel is open, makes the build panel the active panel.", 75, "w:\\4ed\\code\\custom\\4coder_build_commands.cpp", 44, 184 },
{ 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, 930 },
{ 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, 936 },
{ 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, 942 },
{ 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, 950 },
{ 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, 958 },
{ 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, 984 },
{ 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, 1318 },
{ 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, 1325 },
{ 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, 1331 },
{ 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, 1337 },
{ 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, 1377 },
{ 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, 843 },
{ 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, 849 },
{ 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, 855 },
{ 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, 863 },
{ 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, 871 },
{ 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, 897 },
{ 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, 1231 },
{ 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, 1238 },
{ 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, 1244 },
{ 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, 1250 },
{ 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, 1290 },
{ PROC_LINKS(list_all_functions_current_buffer, 0), false, "list_all_functions_current_buffer", 33, "Creates a jump list of lines of the current buffer that appear to define or declare functions.", 94, "w:\\4ed\\code\\custom\\4coder_function_list.cpp", 43, 267 },
{ PROC_LINKS(list_all_functions_current_buffer_lister, 0), false, "list_all_functions_current_buffer_lister", 40, "Creates a lister of locations that look like function definitions and declarations in the buffer.", 97, "w:\\4ed\\code\\custom\\4coder_function_list.cpp", 43, 277 },
{ PROC_LINKS(list_all_functions_all_buffers, 0), false, "list_all_functions_all_buffers", 30, "Creates a jump list of lines from all buffers that appear to define or declare functions.", 89, "w:\\4ed\\code\\custom\\4coder_function_list.cpp", 43, 295 },

View File

@ -1,5 +1,6 @@
version(1);
project_name = "4coder";
patterns = {
"*.c",
"*.cpp",
@ -23,15 +24,20 @@ load_paths = {
};
build_x64_win32 = "echo build: x64 & bin\\build.bat";
build_x64_linux = "echo build: x64 & bin/build.sh";
build_x64_mac = "echo build: x64 & bin/build.sh";
build_x64_unix = "echo build: x64 & bin/build.sh";
command_list = {
{ .name = "build x64",
.out = "*compilation*", .footer_panel = true, .save_dirty_files = true,
.cmd = { {build_x64_win32, .os = "win" },
{build_x64_linux, .os = "linux"},
{build_x64_max , .os = "mac" }, }, },
{build_x64_unix , .os = "linux"},
{build_x64_unix , .os = "mac" }, }, },
{ .name = "package",
.out = "*compilation*", .footer_panel = false, .save_dirty_files = true,
.cmd = { {"echo package & bin\\package.bat", .os = "win" },
{"echo package & bin/package.sh" , .os = "linux"},
{"echo package & bin/package.sh" , .os = "mac" }, }, },
{ .name = "run one time",
.out = "*run*", .footer_panel = false, .save_dirty_files = false,
@ -74,10 +80,11 @@ command_list = {
.cmd = { { "..\\build\\api_parser 4ed_api_implementation.cpp", .os = "win" }, }, },
};
fkey_command[1] = "build x64";
fkey_command[2] = "build keycode generator";
fkey_command[4] = "run one time";
fkey_command[5] = "build C++ lexer generator";
fkey_command[6] = "build token tester";
fkey_command[1] = "build x64";
fkey_command[2] = "build keycode generator";
fkey_command[4] = "run one time";
fkey_command[5] = "build C++ lexer generator";
fkey_command[6] = "build token tester";
fkey_command[11] = "package";

View File

@ -0,0 +1,64 @@
version(1);
project_name = "4coder custom";
patterns = {
"*.c",
"*.cpp",
"*.h",
"*.m",
"*.bat",
"*.sh",
"*.4coder",
"*.txt",
};
blacklist_patterns = {
".*",
};
load_paths_only = {
{"."},
};
load_paths = {
{ load_paths_only, .os = "win" },
{ load_paths_only, .os = "linux"},
{ load_paths_only, .os = "mac" },
};
build_super_x64_win32 = "custom\\bin\\buildsuper_x64.bat";
build_super_x86_win32 = "custom\\bin\\buildsuper_x86.bat";
build_super_x64_unix = "custom/bin/buildsuper_x64.sh";
build_super_x86_unix = "custom/bin/buildsuper_x86.sh";
command_list = {
{ .name = "build super x64",
.out = "*compilation*", .footer_panel = true, .save_dirty_files = true,
.cmd = { {build_super_x64_win32, .os ="win" },
{build_super_x64_unix , .os ="linux"},
{build_super_x64_unix , .os ="mac" }, }, },
{ .name = "build super x86",
.out = "*compilation*", .footer_panel = true, .save_dirty_files = true,
.cmd = { {build_super_x86_win32, .os ="win" },
{build_super_x86_unix, .os ="linux" },
{build_super_x86_unix, .os ="mac" }, }, },
{ .name = "build C++ lexer generator",
.out = "*compilation*", .footer_panel = true, .save_dirty_files = true,
.cmd = { {"custom\\bin\\build_one_time custom\\languages\\4coder_cpp_lexer_gen.cpp ..\\build", .os ="win" },
}, },
{ .name = "build token tester",
.out = "*compilation*", .footer_panel = true, .save_dirty_files = true,
.cmd = { {"custom\\bin\\build_one_time custom\\languages\\4coder_cpp_lexer_test.cpp ..\\build", .os = "win" },
}, },
{ .name = "run one time",
.out = "*run*", .footer_panel = false, .save_dirty_files = false,
.cmd = { {"pushd ..\\build & one_time", .os = "win" },
}, },
};
fkey_command[1] = "build super x64";
fkey_command[2] = "build C++ lexer generator";
fkey_command[3] = "build token tester";
fkey_command[4] = "run one time";
fkey_command[5] = "build super x86";