From 6e97a504a9a9acf70e52445bb7af68c9403c39b6 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Wed, 6 Nov 2019 21:58:08 -0800 Subject: [PATCH] Package script updated --- bin/4ed_build.cpp | 1356 ++++++++--------- bin/package.bat | 2 +- custom/4coder_file_moving.h | 28 +- custom/4coder_project_commands.cpp | 103 +- custom/bin/buildsuper_x86.bat | 58 +- custom/generated/command_metadata.h | 22 +- project.4coder | 25 +- .../{release-config.4coder => config.4coder} | 0 ship_files_super/project.4coder | 64 + 9 files changed, 811 insertions(+), 847 deletions(-) rename ship_files/{release-config.4coder => config.4coder} (100%) create mode 100644 ship_files_super/project.4coder diff --git a/bin/4ed_build.cpp b/bin/4ed_build.cpp index 1798a2b0..48405695 100644 --- a/bin/4ed_build.cpp +++ b/bin/4ed_build.cpp @@ -1,698 +1,658 @@ -/* - * Mr. 4th Dimention - Allen Webster - * - * ??.??.???? - * - * 4coder development build rule. - * - */ - -// TOP - -//#define FM_PRINT_COMMANDS - -#include "4coder_base_types.h" -#include "4coder_version.h" - -#include "4coder_base_types.cpp" -#include "4coder_malloc_allocator.cpp" - -#define FTECH_FILE_MOVING_IMPLEMENTATION -#include "4coder_file_moving.h" - - -// -// OS and compiler index -// - -enum{ - Platform_Windows, - Platform_Linux, - Platform_Mac, - // - Platform_COUNT, - Platform_None = Platform_COUNT, -}; - -char *platform_names[] = { - "win", - "linux", - "mac", -}; - -enum{ - Compiler_CL, - Compiler_GCC, - // - Compiler_COUNT, - Compiler_None = Compiler_COUNT, -}; - -char *compiler_names[] = { - "cl", - "gcc", -}; - -#if OS_WINDOWS -# define This_OS Platform_Windows -#elif OS_LINUX -# define This_OS Platform_Linux -#elif OS_MAC -# define This_OS Platform_Mac -#else -# error This platform is not enumerated. -#endif - -#if COMPILER_CL -# define This_Compiler Compiler_CL -#elif COMPILER_GCC -# define This_Compiler Compiler_GCC -#else -# error This compilers is not enumerated. -#endif - -// -// Universal directories -// - -#define BUILD_DIR "../build" -#define PACK_DIR "../distributions" -#define SITE_DIR "../site" - -#define FOREIGN "../4coder-non-source/foreign" -#define FOREIGN_WIN "..\\4coder-non-source\\foreign" - -char *includes[] = { "custom", FOREIGN "/freetype2", 0, }; - -// -// Platform layer file tables -// - -char *windows_platform_layer[] = { "platform_win32/win32_4ed.cpp", 0 }; -char *linux_platform_layer[] = { "platform_linux/linux_4ed.cpp", 0 }; -char *mac_platform_layer[] = { "platform_mac/mac_4ed.m", "platform_mac/mac_4ed.cpp", 0 }; - -char **platform_layers[Platform_COUNT] = { - windows_platform_layer, - linux_platform_layer , - mac_platform_layer , -}; - -char *windows_cl_platform_inc[] = { "platform_all", 0 }; -char *linux_gcc_platform_inc[] = { "platform_all", "platform_unix", 0 }; -char *mac_gcc_platform_inc[] = { "platform_all", "platform_unix", 0 }; - -char **platform_includes[Platform_COUNT][Compiler_COUNT] = { - {windows_cl_platform_inc, 0 }, - {0 , linux_gcc_platform_inc}, - {0 , mac_gcc_platform_inc }, -}; - -// -// Custom targets -// - -enum{ - Custom_Default, - // - Custom_COUNT -}; - -char *custom_files[] = { - "../code/custom/4coder_default_bindings.cpp", -}; - -// -// Architectures -// - -enum{ - Arch_X64, - Arch_X86, - // - Arch_COUNT, - Arch_None = Arch_COUNT, -}; - -char *arch_names[] = { - "x64", - "x86", -}; - -// -// Build flags -// - -enum{ - OPTS = 0x1, - LIBS = 0x2, - ICON = 0x4, - SHARED_CODE = 0x8, - DEBUG_INFO = 0x10, - OPTIMIZATION = 0x20, - SUPER = 0x40, - INTERNAL = 0x80, - KEEP_ASSERT = 0x100, -}; - -internal char** -get_defines_from_flags(Arena *arena, u32 flags){ - char **result = 0; - if (HasFlag(flags, KEEP_ASSERT)){ - result = fm_list(arena, fm_list_one_item(arena, "FRED_KEEP_ASSERT"), result); - } - if (HasFlag(flags, INTERNAL)){ - result = fm_list(arena, fm_list_one_item(arena, "FRED_INTERNAL"), result); - } - if (HasFlag(flags, SUPER)){ - result = fm_list(arena, fm_list_one_item(arena, "FRED_SUPER"), result); - } - return(result); -} - -// -// build implementation: cl -// - -#if COMPILER_CL - -#define CL_OPTS \ -"-W4 -wd4310 -wd4100 -wd4201 -wd4505 -wd4996 " \ -"-wd4127 -wd4510 -wd4512 -wd4610 -wd4390 " \ -"-wd4611 -wd4189 -WX -GR- -EHa- -nologo -FC" - -#define CL_LIBS_X64 \ -"user32.lib winmm.lib gdi32.lib opengl32.lib comdlg32.lib " \ -FOREIGN_WIN "\\x64\\freetype.lib" - -#define CL_LIBS_X86 \ -"user32.lib winmm.lib gdi32.lib opengl32.lib comdlg32.lib " \ -FOREIGN_WIN "\\x86\\freetype.lib" - -#define CL_ICON "..\\4coder-non-source\\res\\icon.res" - -internal void -build(Arena *arena, u32 flags, u32 arch, char *code_path, char **code_files, char *out_path, char *out_file, char **defines, char **exports, char **inc_folders){ - Temp_Dir temp = fm_pushdir(out_path); - - Build_Line line; - fm_init_build_line(&line); - - if (arch == Arch_X86){ - fm_add_to_line(line, "%s\\windows_scripts\\setup_cl_x86.bat &", code_path); - } - - fm_add_to_line(line, "cl"); - - if (flags & OPTS){ - fm_add_to_line(line, CL_OPTS); - } - - switch (arch){ - case Arch_X64: fm_add_to_line(line, "-DFTECH_64_BIT"); break; - case Arch_X86: fm_add_to_line(line, "-DFTECH_32_BIT"); break; - default: InvalidPath; - } - - fm_add_to_line(line, "-I%s", code_path); - if (inc_folders != 0){ - for (u32 i = 0; inc_folders[i] != 0; ++i){ - char *str = fm_str(arena, code_path, "/", inc_folders[i]); - fm_add_to_line(line, "-I%s", str); - } - } - - if (flags & LIBS){ - switch (arch){ - case Arch_X64: fm_add_to_line(line, CL_LIBS_X64); break; - case Arch_X86: fm_add_to_line(line, CL_LIBS_X86); break; - default: InvalidPath; - } - } - - if (flags & ICON){ - fm_add_to_line(line, CL_ICON); - } - - if (flags & DEBUG_INFO){ - fm_add_to_line(line, "-Zi"); - fm_add_to_line(line, "-DDO_CRAZY_EXPENSIVE_ASSERTS"); - } - - if (flags & OPTIMIZATION){ - fm_add_to_line(line, "-O2"); - } - - if (flags & SHARED_CODE){ - fm_add_to_line(line, "-LD"); - } - - if (defines != 0){ - for (u32 i = 0; defines[i] != 0; ++i){ - char *define_flag = fm_str(arena, "-D", defines[i]); - fm_add_to_line(line, "%s", define_flag); - } - } - - for (u32 i = 0; code_files[i]; ++i){ - fm_add_to_line(line, "\"%s\\%s\"", code_path, code_files[i]); - } - - fm_add_to_line(line, "-Fe%s", out_file); - - fm_add_to_line(line, "-link -INCREMENTAL:NO -RELEASE -PDBALTPATH:%%_PDB%%"); - switch (arch){ - case Arch_X64: fm_add_to_line(line, "-MACHINE:X64"); break; - case Arch_X86: fm_add_to_line(line, "-MACHINE:X86"); break; - default: InvalidPath; - } - - if (flags & DEBUG_INFO){ - fm_add_to_line(line, "-DEBUG"); - } - - if (flags & SHARED_CODE){ - Assert(exports != 0); - fm_add_to_line(line, "-OPT:REF"); - for (u32 i = 0; exports[i] != 0; ++i){ - char *str = fm_str(arena, "-EXPORT:", exports[i]); - fm_add_to_line(line, "%s", str); - } - } - else{ - fm_add_to_line(line, "-NODEFAULTLIB:library"); - } - - fm_finish_build_line(&line); - - systemf("%s", line.build_options); - fm_popdir(temp); -} - -// -// build implementation: gcc -// - -#elif COMPILER_GCC - -#if OS_LINUX - -# define GCC_OPTS \ -"-Wno-write-strings " \ -"-D_GNU_SOURCE -fPIC " \ -"-fno-threadsafe-statics -pthread " \ -"-Wno-unused-result" - -#define GCC_LIBS_COMMON \ -"-lX11 -lpthread -lm -lrt " \ -"-lGL -ldl -lXfixes -lfreetype -lfontconfig" - -#define GCC_LIBS_X64 GCC_LIBS_COMMON -#define GCC_LIBS_X86 GCC_LIBS_COMMON - -#elif OS_MAC - -# define GCC_OPTS \ -"-Wno-write-strings -Wno-deprecated-declarations " \ -"-Wno-comment -Wno-switch -Wno-null-dereference " \ -"-Wno-tautological-compare " \ -"-Wno-unused-result " - -#define GCC_LIBS_COMMON \ -"-framework Cocoa -framework QuartzCore " \ -"-framework CoreServices " \ -"-framework OpenGL -framework IOKit " - -#define GCC_LIBS_X64 GCC_LIBS_COMMON \ -FOREIGN "/x64/libfreetype-mac.a" - -#define GCC_LIBS_X86 GCC_LIBS_COMMON \ -FOREIGN "/x86/libfreetype-mac.a" - -#else -# error gcc options not set for this platform -#endif - -internal void -build(Partition *part, u32 flags, u32 arch, char *code_path, char **code_files, char *out_path, char *out_file, char **defines, char **exports, char **inc_folders){ - Build_Line line; - fm_init_build_line(&line); - - switch (arch){ - case Arch_X64: - fm_add_to_line(line, "-m64"); - fm_add_to_line(line, "-DFTECH_64_BIT"); break; - - case Arch_X86: - fm_add_to_line(line, "-m32"); - fm_add_to_line(line, "-DFTECH_32_BIT"); break; - - default: InvalidCodePath; - } - - if (flags & OPTS){ - fm_add_to_line(line, GCC_OPTS); - } - - fm_add_to_line(line, "-I%s", code_path); - if (inc_folders != 0){ - for (u32 i = 0; inc_folders[i] != 0; ++i){ - char *str = fm_str(part, code_path, "/", inc_folders[i]); - fm_add_to_line(line, "-I%s", str); - } - } - - if (flags & DEBUG_INFO){ - fm_add_to_line(line, "-g -O0"); - } - - if (flags & OPTIMIZATION){ - fm_add_to_line(line, "-O3"); - } - - if (flags & SHARED_CODE){ - fm_add_to_line(line, "-shared"); - } - - if (defines != 0){ - for (u32 i = 0; defines[i]; ++i){ - char *define_flag = fm_str(part, "-D", defines[i]); - fm_add_to_line(line, "%s", define_flag); - } - } - - fm_add_to_line(line, "-I\"%s\"", code_path); - for (u32 i = 0; code_files[i] != 0; ++i){ - fm_add_to_line(line, "\"%s/%s\"", code_path, code_files[i]); - } - - if (flags & LIBS){ - if (arch == Arch_X64){ - fm_add_to_line(line, GCC_LIBS_X64); - } - else if (arch == Arch_X86) - { - fm_add_to_line(line, GCC_LIBS_X86); - } - } - - fm_finish_build_line(&line); - - Temp_Dir temp = fm_pushdir(out_path); - systemf("g++ %s -o %s", line.build_options, out_file); - fm_popdir(temp); -} - -#else -# error build function not defined for this compiler -#endif - -internal void -build(Arena *arena, u32 flags, u32 arch, char *code_path, char *code_file, char *out_path, char *out_file, char **defines, char **exports, char **inc_folders){ - char **code_files = fm_list_one_item(arena, code_file); - build(arena, flags, arch, code_path, code_files, out_path, out_file, defines, exports, inc_folders); -} - -// TODO(NAME): build metadata fully from C++ and eliminate build_metadata.bat and build_metadata.sh - -internal void -build_metadata(void){ - systemf(".%s%s ..%scode%s4coder_default_bindings.cpp", SLASH, "build_metadata" BAT, SLASH, SLASH); -} - -internal void -site_build(Arena *arena, char *cdir, u32 flags){ - build_metadata(); - - { - char *file = fm_str(arena, "site/4ed_sitegen.cpp"); - char *dir = fm_str(arena, BUILD_DIR); - BEGIN_TIME_SECTION(); - build(arena, OPTS | flags, Arch_X64, cdir, file, dir, "sitegen", get_defines_from_flags(arena, flags), 0, includes); - END_TIME_SECTION("build sitegen"); - } - - if (prev_error == 0){ - BEGIN_TIME_SECTION(); - char *cmd = fm_str(arena, BUILD_DIR "/sitegen"); - char *code_dir = fm_str(arena, "."); - char *asset_dir = fm_str(arena, "../4coder-non-source/site_resources"); - char *site_source_dir = fm_str(arena, "site/source_material"); - char *dest_dir = fm_str(arena, "../site"); - fm_make_folder_if_missing(arena, dest_dir); - systemf("%s %s %s %s %s", cmd, code_dir, asset_dir, site_source_dir, dest_dir); - END_TIME_SECTION("run sitegen"); - } -} - -internal void -build_and_run(Arena *arena, char *cdir, char *filename, char *name, u32 flags){ - char *dir = fm_str(arena, BUILD_DIR); - - { - char *file = fm_str(arena, filename); - BEGIN_TIME_SECTION(); - build(arena, flags, Arch_X64, cdir, file, dir, name, get_defines_from_flags(arena, flags), 0, includes); - END_TIME_SECTION(fm_str(arena, "build ", name)); - } - - if (prev_error == 0){ - char *cmd = fm_str(arena, dir, "/", name); - BEGIN_TIME_SECTION(); - fm_execute_in_dir(cdir, cmd, 0); - END_TIME_SECTION(fm_str(arena, "run ", name)); - } -} - -internal void -string_build(Arena *arena, char *cdir){ - char *dir = fm_str(arena, BUILD_DIR); - - { - char *file = fm_str(arena, "string/4ed_string_builder.cpp"); - BEGIN_TIME_SECTION(); - build(arena, OPTS | DEBUG_INFO, Arch_X64, cdir, file, dir, "string_builder", 0, 0, includes); - END_TIME_SECTION("build string_builder"); - } - - if (prev_error == 0){ - char *cmd = fm_str(arena, cdir, "/", dir, "/string_builder"); - BEGIN_TIME_SECTION(); - fm_execute_in_dir(fm_str(arena, cdir, "/string"), cmd, 0); - END_TIME_SECTION("run string_builder"); - } -} - -internal void -do_buildsuper(Arena *arena, char *cdir, char *file, u32 arch){ - BEGIN_TIME_SECTION(); - Temp_Dir temp = fm_pushdir(fm_str(arena, BUILD_DIR)); - - char *build_script = fm_str(arena, "custom/bin/buildsuper_", arch_names[arch], BAT); - - char *build_command = fm_str(arena, "\"", cdir, "/", build_script, "\" \"", file, "\""); - if (This_OS == Platform_Windows){ - build_command = fm_str(arena, "call ", build_command); - } - systemf("%s", build_command); - - fm_popdir(temp); - END_TIME_SECTION("build custom"); -} - -// TODO(allen): Remove this -internal i32 -get_freetype_include(char *out, u32 max){ - i32 size = 0; -#if 0 -#if OS_LINUX - char freetype_include[512]; - FILE *file = popen("pkg-config --cflags freetype2", "r"); - if (file != 0){ - fgets(freetype_include, sizeof(freetype_include), file); - size = strlen(freetype_include); - memcpy(out, freetype_include, size); - pclose(file); - } -#elif OS_MAC - char *freetype_include = "/usr/local/include/freetype2"; - size = strlen(freetype_include); - memcpy(out, freetype_include, size); -#endif -#endif - return(size); -} - -internal void -build_main(Arena *arena, char *cdir, b32 update_local_theme, u32 flags, u32 arch){ - char *dir = fm_str(arena, BUILD_DIR); - - { - char *file = fm_str(arena, "4ed_app_target.cpp"); - char **exports = fm_list_one_item(arena, "app_get_functions"); - - char **build_includes = includes; - - char ft_include[512]; - i32 ft_size = get_freetype_include(ft_include, sizeof(ft_include) - 1); - if (ft_size > 0){ - ft_include[ft_size] = 0; - fprintf(stdout, "FREETYPE: %s\n", ft_include); - build_includes = fm_list(arena, build_includes, fm_list_one_item(arena, ft_include)); - } - - BEGIN_TIME_SECTION(); - build(arena, OPTS | SHARED_CODE | flags, arch, cdir, file, dir, "4ed_app" DLL, get_defines_from_flags(arena, flags), exports, build_includes); - END_TIME_SECTION("build 4ed_app"); - } - - { - BEGIN_TIME_SECTION(); - char **inc = (char**)fm_list(arena, includes, platform_includes[This_OS][This_Compiler]); - build(arena, OPTS | LIBS | ICON | flags, arch, cdir, platform_layers[This_OS], dir, "4ed", get_defines_from_flags(arena, flags), 0, inc); - END_TIME_SECTION("build 4ed"); - } - - if (update_local_theme){ - BEGIN_TIME_SECTION(); - char *themes_folder = fm_str(arena, "../build/themes"); - char *source_themes_folder = fm_str(arena, "themes"); - fm_clear_folder(themes_folder); - fm_make_folder_if_missing(arena, themes_folder); - fm_copy_all(source_themes_folder, "*", themes_folder); - END_TIME_SECTION("move files"); - } -} - -internal void -standard_build(Arena *arena, char *cdir, u32 flags, u32 arch){ - do_buildsuper(arena, cdir, fm_str(arena, custom_files[Custom_Default]), arch); - - build_main(arena, cdir, true, flags, arch); -} - -internal char* -get_4coder_dist_name(Arena *arena, u32 platform, char *tier, u32 arch){ - char *name = fm_str(arena, "4coder-alpha-" MAJOR_STR "-" MINOR_STR "-" PATCH_STR); - if (strcmp(tier, "alpha") != 0){ - name = fm_str(arena, name, "-", tier); - } - if (platform != Platform_None){ - name = fm_str(arena, name, "-", platform_names[platform]); - } - if (arch != Arch_None){ - name = fm_str(arena, name, "-", arch_names[arch]); - } - return(name); -} - -internal void -package(Arena *arena, char *cdir){ - // NOTE(allen): meta - char *build_dir = fm_str(arena, BUILD_DIR); - char *pack_dir = fm_str(arena, PACK_DIR); - char *fonts_source_dir = fm_str(arena, "../4coder-non-source/dist_files/fonts"); - - char *base_package_root = "../current_dist"; - - // NOTE(allen): alpha and super builds - enum{ - Tier_Alpha = 0, - Tier_Super = 1, - Tier_COUNT = 2 - }; - - char *tiers[] = { "alpha", "super" }; - u32 base_flags = OPTIMIZATION | KEEP_ASSERT | DEBUG_INFO; - u32 tier_flags[] = { 0, SUPER, }; - - for (u32 tier_index = 0; tier_index < Tier_COUNT; ++tier_index){ - char *tier = tiers[tier_index]; - u32 flags = base_flags | tier_flags[tier_index]; - - Temp_Memory temp = begin_temp(arena); - char *tier_package_root = fm_str(arena, base_package_root, "_", tier); - for (u32 arch = 0; arch < Arch_COUNT; ++arch){ - char *par_dir = fm_str(arena, tier_package_root, "_", arch_names[arch]); - char *dir = fm_str(arena, par_dir, "/4coder"); - char *fonts_dir = fm_str(arena, dir, "/fonts"); - char *zip_dir = fm_str(arena, pack_dir, "/", tier, "_", arch_names[arch]); - - build_metadata(); - build_main(arena, cdir, false, flags, arch); - - fm_clear_folder(par_dir); - - fm_make_folder_if_missing(arena, dir); - fm_copy_file(fm_str(arena, build_dir, "/4ed" EXE), fm_str(arena, dir, "/4ed" EXE)); - fm_copy_file(fm_str(arena, build_dir, "/4ed_app" DLL), fm_str(arena, dir, "/4ed_app" DLL)); - - fm_copy_folder(arena, cdir, dir, "themes"); - fm_copy_file(fm_str(arena, cdir, "/LICENSE.txt"), fm_str(arena, dir, "/LICENSE.txt")); - fm_copy_file(fm_str(arena, cdir, "/README.txt"), fm_str(arena, dir, "/README.txt")); - fm_copy_file(fm_str(arena, cdir, "/changes.txt"), fm_str(arena, dir, "/changes.txt")); - - fm_make_folder_if_missing(arena, fonts_dir); - fm_copy_all(fonts_source_dir, "*", fonts_dir); - fm_copy_file(fm_str(arena, cdir, "/release-config.4coder"), fm_str(arena, dir, "/config.4coder")); - - if (tier_index == Tier_Super){ - fm_copy_all(0, "4coder_*", dir); - - do_buildsuper(arena, cdir, fm_str(arena, custom_files[Custom_Default]), arch); - fm_copy_file(fm_str(arena, build_dir, "/custom_4coder" DLL), fm_str(arena, dir, "/custom_4coder" DLL)); - - char *build_script = fm_str(arena, "buildsuper_", arch_names[arch], BAT); - fm_copy_file(build_script, fm_str(arena, dir, "/buildsuper" BAT)); - - if (This_OS == Platform_Windows){ - fm_copy_folder(arena, cdir, dir, "windows_scripts"); - } - - fm_copy_folder(arena, cdir, dir, "4coder_API"); - fm_copy_folder(arena, cdir, dir, "4coder_lib"); - fm_copy_folder(arena, cdir, dir, "4coder_generated"); - fm_copy_folder(arena, cdir, dir, "languages"); - } - - char *dist_name = get_4coder_dist_name(arena, This_OS, tier, arch); - char *zip_name = fm_str(arena, zip_dir, "/", dist_name, ".zip"); - fm_make_folder_if_missing(arena, zip_dir); - fm_zip(par_dir, "4coder", zip_name); - } - end_temp(temp); - } -} - -int main(int argc, char **argv){ - Arena arena = fm_init_system(); - - char cdir[256]; - BEGIN_TIME_SECTION(); - i32 n = fm_get_current_directory(cdir, sizeof(cdir)); - Assert(n < sizeof(cdir)); - END_TIME_SECTION("current directory"); - -#if defined(DEV_BUILD) || defined(OPT_BUILD) || defined(DEV_BUILD_X86) - u32 flags = DEBUG_INFO | SUPER | INTERNAL; - u32 arch = Arch_X64; -#if defined(OPT_BUILD) - flags |= OPTIMIZATION; -#endif -#if defined(DEV_BUILD_X86) - arch = Arch_X86; -#endif - standard_build(&arena, cdir, flags, arch); - -#elif defined(PACKAGE) - package(&arena, cdir); - -#else -# error No build type specified. -#endif - - return(error_state); -} - -// BOTTOM - +/* + * Mr. 4th Dimention - Allen Webster + * + * ??.??.???? + * + * 4coder development build rule. + * + */ + +// TOP + +//#define FM_PRINT_COMMANDS + +#include "4coder_base_types.h" +#include "4coder_version.h" + +#include "4coder_base_types.cpp" +#include "4coder_malloc_allocator.cpp" + +#define FTECH_FILE_MOVING_IMPLEMENTATION +#include "4coder_file_moving.h" + + +// +// OS and compiler index +// + +enum{ + Platform_Windows, + Platform_Linux, + Platform_Mac, + // + Platform_COUNT, + Platform_None = Platform_COUNT, +}; + +char *platform_names[] = { + "win", + "linux", + "mac", +}; + +enum{ + Compiler_CL, + Compiler_GCC, + // + Compiler_COUNT, + Compiler_None = Compiler_COUNT, +}; + +char *compiler_names[] = { + "cl", + "gcc", +}; + +#if OS_WINDOWS +# define This_OS Platform_Windows +#elif OS_LINUX +# define This_OS Platform_Linux +#elif OS_MAC +# define This_OS Platform_Mac +#else +# error This platform is not enumerated. +#endif + +#if COMPILER_CL +# define This_Compiler Compiler_CL +#elif COMPILER_GCC +# define This_Compiler Compiler_GCC +#else +# error This compilers is not enumerated. +#endif + +// +// Universal directories +// + +#define BUILD_DIR "../build" +#define PACK_DIR "../distributions" +#define SITE_DIR "../site" + +#define FOREIGN "../4coder-non-source/foreign" +#define FOREIGN_WIN "..\\4coder-non-source\\foreign" + +char *includes[] = { "custom", FOREIGN "/freetype2", 0, }; + +// +// Platform layer file tables +// + +char *windows_platform_layer[] = { "platform_win32/win32_4ed.cpp", 0 }; +char *linux_platform_layer[] = { "platform_linux/linux_4ed.cpp", 0 }; +char *mac_platform_layer[] = { "platform_mac/mac_4ed.m", "platform_mac/mac_4ed.cpp", 0 }; + +char **platform_layers[Platform_COUNT] = { + windows_platform_layer, + linux_platform_layer , + mac_platform_layer , +}; + +char *windows_cl_platform_inc[] = { "platform_all", 0 }; +char *linux_gcc_platform_inc[] = { "platform_all", "platform_unix", 0 }; +char *mac_gcc_platform_inc[] = { "platform_all", "platform_unix", 0 }; + +char **platform_includes[Platform_COUNT][Compiler_COUNT] = { + {windows_cl_platform_inc, 0 }, + {0 , linux_gcc_platform_inc}, + {0 , mac_gcc_platform_inc }, +}; + +char *default_custom_target = "../code/custom/4coder_default_bindings.cpp"; + +// NOTE(allen): Architectures + +enum{ + Arch_X64, + Arch_X86, + + // + Arch_COUNT, + Arch_None = Arch_COUNT, +}; + +char *arch_names[] = { + "x64", + "x86", +}; + +// NOTE(allen): Build flags + +enum{ + OPTS = 0x1, + LIBS = 0x2, + ICON = 0x4, + SHARED_CODE = 0x8, + DEBUG_INFO = 0x10, + OPTIMIZATION = 0x20, + SUPER = 0x40, + INTERNAL = 0x80, + KEEP_ASSERT = 0x100, +}; + +internal char** +get_defines_from_flags(Arena *arena, u32 flags){ + char **result = 0; + if (HasFlag(flags, KEEP_ASSERT)){ + result = fm_list(arena, fm_list_one_item(arena, "FRED_KEEP_ASSERT"), result); + } + if (HasFlag(flags, INTERNAL)){ + result = fm_list(arena, fm_list_one_item(arena, "FRED_INTERNAL"), result); + } + if (HasFlag(flags, SUPER)){ + result = fm_list(arena, fm_list_one_item(arena, "FRED_SUPER"), result); + } + return(result); +} + +// +// build implementation: cl +// + +#if COMPILER_CL + +#define CL_OPTS \ +"-W4 -wd4310 -wd4100 -wd4201 -wd4505 -wd4996 " \ +"-wd4127 -wd4510 -wd4512 -wd4610 -wd4390 " \ +"-wd4611 -wd4189 -WX -GR- -EHa- -nologo -FC" + +#define CL_LIBS_X64 \ +"user32.lib winmm.lib gdi32.lib opengl32.lib comdlg32.lib " \ +FOREIGN_WIN "\\x64\\freetype.lib" + +#define CL_LIBS_X86 \ +"user32.lib winmm.lib gdi32.lib opengl32.lib comdlg32.lib " \ +FOREIGN_WIN "\\x86\\freetype.lib" + +#define CL_ICON "..\\4coder-non-source\\res\\icon.res" + +internal void +build(Arena *arena, u32 flags, u32 arch, char *code_path, char **code_files, char *out_path, char *out_file, char **defines, char **exports, char **inc_folders){ + Temp_Dir temp = fm_pushdir(out_path); + + Build_Line line; + fm_init_build_line(&line); + + if (arch == Arch_X86){ + fm_add_to_line(line, "%s\\custom\\bin\\setup_cl_x86.bat &", code_path); + } + + fm_add_to_line(line, "cl"); + + if (flags & OPTS){ + fm_add_to_line(line, CL_OPTS); + } + + switch (arch){ + case Arch_X64: fm_add_to_line(line, "-DFTECH_64_BIT"); break; + case Arch_X86: fm_add_to_line(line, "-DFTECH_32_BIT"); break; + default: InvalidPath; + } + + fm_add_to_line(line, "-I%s", code_path); + if (inc_folders != 0){ + for (u32 i = 0; inc_folders[i] != 0; ++i){ + char *str = fm_str(arena, code_path, "/", inc_folders[i]); + fm_add_to_line(line, "-I%s", str); + } + } + + if (flags & LIBS){ + switch (arch){ + case Arch_X64: fm_add_to_line(line, CL_LIBS_X64); break; + case Arch_X86: fm_add_to_line(line, CL_LIBS_X86); break; + default: InvalidPath; + } + } + + if (flags & ICON){ + fm_add_to_line(line, CL_ICON); + } + + if (flags & DEBUG_INFO){ + fm_add_to_line(line, "-Zi"); + fm_add_to_line(line, "-DDO_CRAZY_EXPENSIVE_ASSERTS"); + } + + if (flags & OPTIMIZATION){ + fm_add_to_line(line, "-O2"); + } + + if (flags & SHARED_CODE){ + fm_add_to_line(line, "-LD"); + } + + if (defines != 0){ + for (u32 i = 0; defines[i] != 0; ++i){ + char *define_flag = fm_str(arena, "-D", defines[i]); + fm_add_to_line(line, "%s", define_flag); + } + } + + for (u32 i = 0; code_files[i]; ++i){ + fm_add_to_line(line, "\"%s\\%s\"", code_path, code_files[i]); + } + + fm_add_to_line(line, "-Fe%s", out_file); + + fm_add_to_line(line, "-link -INCREMENTAL:NO -RELEASE -PDBALTPATH:%%_PDB%%"); + switch (arch){ + case Arch_X64: fm_add_to_line(line, "-MACHINE:X64"); break; + case Arch_X86: fm_add_to_line(line, "-MACHINE:X86"); break; + default: InvalidPath; + } + + if (flags & DEBUG_INFO){ + fm_add_to_line(line, "-DEBUG"); + } + + if (flags & SHARED_CODE){ + Assert(exports != 0); + fm_add_to_line(line, "-OPT:REF"); + for (u32 i = 0; exports[i] != 0; ++i){ + char *str = fm_str(arena, "-EXPORT:", exports[i]); + fm_add_to_line(line, "%s", str); + } + } + else{ + fm_add_to_line(line, "-NODEFAULTLIB:library"); + } + + fm_finish_build_line(&line); + + systemf("%s", line.build_options); + fm_popdir(temp); + + fflush(stdout); +} + +// +// build implementation: gcc +// + +#elif COMPILER_GCC + +#if OS_LINUX + +# define GCC_OPTS \ +"-Wno-write-strings " \ +"-D_GNU_SOURCE -fPIC " \ +"-fno-threadsafe-statics -pthread " \ +"-Wno-unused-result" + +#define GCC_LIBS_COMMON \ +"-lX11 -lpthread -lm -lrt " \ +"-lGL -ldl -lXfixes -lfreetype -lfontconfig" + +#define GCC_LIBS_X64 GCC_LIBS_COMMON +#define GCC_LIBS_X86 GCC_LIBS_COMMON + +#elif OS_MAC + +# define GCC_OPTS \ +"-Wno-write-strings -Wno-deprecated-declarations " \ +"-Wno-comment -Wno-switch -Wno-null-dereference " \ +"-Wno-tautological-compare " \ +"-Wno-unused-result " + +#define GCC_LIBS_COMMON \ +"-framework Cocoa -framework QuartzCore " \ +"-framework CoreServices " \ +"-framework OpenGL -framework IOKit " + +#define GCC_LIBS_X64 GCC_LIBS_COMMON \ +FOREIGN "/x64/libfreetype-mac.a" + +#define GCC_LIBS_X86 GCC_LIBS_COMMON \ +FOREIGN "/x86/libfreetype-mac.a" + +#else +# error gcc options not set for this platform +#endif + +internal void +build(Partition *part, u32 flags, u32 arch, char *code_path, char **code_files, char *out_path, char *out_file, char **defines, char **exports, char **inc_folders){ + Build_Line line; + fm_init_build_line(&line); + + switch (arch){ + case Arch_X64: + fm_add_to_line(line, "-m64"); + fm_add_to_line(line, "-DFTECH_64_BIT"); break; + + case Arch_X86: + fm_add_to_line(line, "-m32"); + fm_add_to_line(line, "-DFTECH_32_BIT"); break; + + default: InvalidCodePath; + } + + if (flags & OPTS){ + fm_add_to_line(line, GCC_OPTS); + } + + fm_add_to_line(line, "-I%s", code_path); + if (inc_folders != 0){ + for (u32 i = 0; inc_folders[i] != 0; ++i){ + char *str = fm_str(part, code_path, "/", inc_folders[i]); + fm_add_to_line(line, "-I%s", str); + } + } + + if (flags & DEBUG_INFO){ + fm_add_to_line(line, "-g -O0"); + } + + if (flags & OPTIMIZATION){ + fm_add_to_line(line, "-O3"); + } + + if (flags & SHARED_CODE){ + fm_add_to_line(line, "-shared"); + } + + if (defines != 0){ + for (u32 i = 0; defines[i]; ++i){ + char *define_flag = fm_str(part, "-D", defines[i]); + fm_add_to_line(line, "%s", define_flag); + } + } + + fm_add_to_line(line, "-I\"%s\"", code_path); + for (u32 i = 0; code_files[i] != 0; ++i){ + fm_add_to_line(line, "\"%s/%s\"", code_path, code_files[i]); + } + + if (flags & LIBS){ + if (arch == Arch_X64){ + fm_add_to_line(line, GCC_LIBS_X64); + } + else if (arch == Arch_X86) + { + fm_add_to_line(line, GCC_LIBS_X86); + } + } + + fm_finish_build_line(&line); + + Temp_Dir temp = fm_pushdir(out_path); + systemf("g++ %s -o %s", line.build_options, out_file); + fm_popdir(temp); +} + +#else +# error build function not defined for this compiler +#endif + +internal void +build(Arena *arena, u32 flags, u32 arch, char *code_path, char *code_file, char *out_path, char *out_file, char **defines, char **exports, char **inc_folders){ + char **code_files = fm_list_one_item(arena, code_file); + build(arena, flags, arch, code_path, code_files, out_path, out_file, defines, exports, inc_folders); +} + +internal void +build_and_run(Arena *arena, char *cdir, char *filename, char *name, u32 flags){ + char *dir = fm_str(arena, BUILD_DIR); + + { + char *file = fm_str(arena, filename); + BEGIN_TIME_SECTION(); + build(arena, flags, Arch_X64, cdir, file, dir, name, get_defines_from_flags(arena, flags), 0, includes); + END_TIME_SECTION(fm_str(arena, "build ", name)); + } + + if (prev_error == 0){ + char *cmd = fm_str(arena, dir, "/", name); + BEGIN_TIME_SECTION(); + fm_execute_in_dir(cdir, cmd, 0); + END_TIME_SECTION(fm_str(arena, "run ", name)); + } +} + +internal void +string_build(Arena *arena, char *cdir){ + char *dir = fm_str(arena, BUILD_DIR); + + { + char *file = fm_str(arena, "string/4ed_string_builder.cpp"); + BEGIN_TIME_SECTION(); + build(arena, OPTS | DEBUG_INFO, Arch_X64, cdir, file, dir, "string_builder", 0, 0, includes); + END_TIME_SECTION("build string_builder"); + } + + if (prev_error == 0){ + char *cmd = fm_str(arena, cdir, "/", dir, "/string_builder"); + BEGIN_TIME_SECTION(); + fm_execute_in_dir(fm_str(arena, cdir, "/string"), cmd, 0); + END_TIME_SECTION("run string_builder"); + } +} + +internal void +buildsuper(Arena *arena, char *cdir, char *file, u32 arch){ + printf("BUILDSUPER: cdir: %s; file: %s; arch: %u\n", cdir, file, arch); + + BEGIN_TIME_SECTION(); + Temp_Dir temp = fm_pushdir(fm_str(arena, BUILD_DIR)); + + char *build_script = fm_str(arena, "custom/bin/buildsuper_", arch_names[arch], BAT); + + char *build_command = fm_str(arena, "\"", cdir, "/", build_script, "\" \"", file, "\""); + if (This_OS == Platform_Windows){ + build_command = fm_str(arena, "call ", build_command); + } + systemf("%s", build_command); + + fm_popdir(temp); + END_TIME_SECTION("build custom"); + fflush(stdout); +} + +// TODO(allen): Remove this +internal i32 +get_freetype_include(char *out, u32 max){ + i32 size = 0; +#if 0 +#if OS_LINUX + char freetype_include[512]; + FILE *file = popen("pkg-config --cflags freetype2", "r"); + if (file != 0){ + fgets(freetype_include, sizeof(freetype_include), file); + size = strlen(freetype_include); + memcpy(out, freetype_include, size); + pclose(file); + } +#elif OS_MAC + char *freetype_include = "/usr/local/include/freetype2"; + size = strlen(freetype_include); + memcpy(out, freetype_include, size); +#endif +#endif + return(size); +} + +internal void +build_main(Arena *arena, char *cdir, b32 update_local_theme, u32 flags, u32 arch){ + char *dir = fm_str(arena, BUILD_DIR); + + { + char *file = fm_str(arena, "4ed_app_target.cpp"); + char **exports = fm_list_one_item(arena, "app_get_functions"); + + char **build_includes = includes; + + char ft_include[512]; + i32 ft_size = get_freetype_include(ft_include, sizeof(ft_include) - 1); + if (ft_size > 0){ + ft_include[ft_size] = 0; + fprintf(stdout, "FREETYPE: %s\n", ft_include); + build_includes = fm_list(arena, build_includes, fm_list_one_item(arena, ft_include)); + } + + BEGIN_TIME_SECTION(); + build(arena, OPTS | SHARED_CODE | flags, arch, cdir, file, dir, "4ed_app" DLL, get_defines_from_flags(arena, flags), exports, build_includes); + END_TIME_SECTION("build 4ed_app"); + } + + { + BEGIN_TIME_SECTION(); + char **inc = (char**)fm_list(arena, includes, platform_includes[This_OS][This_Compiler]); + build(arena, OPTS | LIBS | ICON | flags, arch, cdir, platform_layers[This_OS], dir, "4ed", get_defines_from_flags(arena, flags), 0, inc); + END_TIME_SECTION("build 4ed"); + } + + if (update_local_theme){ + BEGIN_TIME_SECTION(); + char *themes_folder = fm_str(arena, "../build/themes"); + char *source_themes_folder = fm_str(arena, "themes"); + fm_clear_folder(themes_folder); + fm_make_folder_if_missing(arena, themes_folder); + fm_copy_all(source_themes_folder, themes_folder); + END_TIME_SECTION("move files"); + } + + fflush(stdout); +} + +internal void +standard_build(Arena *arena, char *cdir, u32 flags, u32 arch){ + buildsuper(arena, cdir, fm_str(arena, default_custom_target), arch); + build_main(arena, cdir, true, flags, arch); +} + +internal char* +get_4coder_dist_name(Arena *arena, u32 platform, char *tier, u32 arch){ + char *name = fm_str(arena, "4coder-" MAJOR_STR "-" MINOR_STR "-" PATCH_STR "-", tier); + if (platform != Platform_None){ + name = fm_str(arena, name, "-", platform_names[platform]); + } + if (arch != Arch_None){ + name = fm_str(arena, name, "-", arch_names[arch]); + } + return(name); +} + +enum{ + Tier_Demo, + Tier_Super, + Tier_COUNT, +}; + +internal void +package(Arena *arena, char *cdir){ + // NOTE(allen): meta + char *build_dir = fm_str(arena, BUILD_DIR); + char *pack_dir = fm_str(arena, PACK_DIR); + char *dist_files[3]; + dist_files[0] = fm_str(arena, "../4coder-non-source/dist_files"); + dist_files[1] = fm_str(arena, "ship_files"); + dist_files[2] = fm_str(arena, "ship_files_super"); + + printf("build dir: %s\n", build_dir); + printf("pack dir: %s\n", pack_dir); + printf("dist files: %s, %s, %s\n", dist_files[0], dist_files[1], dist_files[2]); + fflush(stdout); + + char *tier_names[] = { "demo", "super", }; + u32 base_flags = OPTIMIZATION | KEEP_ASSERT | DEBUG_INFO; + u32 tier_flags[] = { 0, SUPER, }; + + fm_make_folder_if_missing(arena, pack_dir); + + for (u32 i = 0; i < Tier_COUNT; i += 1){ + char *tier_name = tier_names[i]; + u32 flags = base_flags | tier_flags[i]; + + Temp_Memory temp = begin_temp(arena); + char *current_dist_tier = fm_str(arena, ".." SLASH "current_dist_", tier_name); + + for (u32 arch = 0; arch < Arch_COUNT; ++arch){ + char *arch_name = arch_names[arch]; + char *parent_dir = fm_str(arena, current_dist_tier, "_", arch_name); + char *dir = fm_str(arena, parent_dir, SLASH "4coder"); + char *zip_dir = fm_str(arena, pack_dir, SLASH, tier_name, "_", arch_name); + + printf("\nbuild: %s_%s\n", tier_name, arch_name); + printf("parent_dir: %s\n", parent_dir); + printf("dir: %s\n", dir); + printf("zip_dir: %s\n", zip_dir); + fflush(stdout); + + buildsuper(arena, cdir, fm_str(arena, default_custom_target), arch); + build_main(arena, cdir, false, flags, arch); + + fm_make_folder_if_missing(arena, parent_dir); + fm_clear_folder(parent_dir); + fm_make_folder_if_missing(arena, dir); + fm_copy_file(fm_str(arena, build_dir, "/4ed" EXE), fm_str(arena, dir, "/4ed" EXE)); + fm_copy_file(fm_str(arena, build_dir, "/4ed_app" DLL), fm_str(arena, dir, "/4ed_app" DLL)); + fm_copy_file(fm_str(arena, build_dir, "/custom_4coder" DLL), fm_str(arena, dir, "/custom_4coder" DLL)); + + i32 dist_file_count = ArrayCount(dist_files); + if (i == Tier_Demo){ + dist_file_count -= 1; + } + + for (i32 j = 0; j < dist_file_count; j += 1){ + fm_copy_all(dist_files[j], dir); + } + + if (i == Tier_Super){ + char *custom_src_dir = fm_str(arena, cdir, SLASH, "custom"); + char *custom_dst_dir = fm_str(arena, dir, SLASH, "custom"); + fm_make_folder_if_missing(arena, custom_dst_dir); + fm_copy_all(custom_src_dir, custom_dst_dir); + } + + char *dist_name = get_4coder_dist_name(arena, This_OS, tier_name, arch); + char *zip_name = fm_str(arena, zip_dir, SLASH, dist_name, ".zip"); + fm_make_folder_if_missing(arena, zip_dir); + fm_zip(parent_dir, "4coder", zip_name); + } + + end_temp(temp); + } +} + +int main(int argc, char **argv){ + Arena arena = fm_init_system(); + + char cdir[256]; + BEGIN_TIME_SECTION(); + i32 n = fm_get_current_directory(cdir, sizeof(cdir)); + Assert(n < sizeof(cdir)); + END_TIME_SECTION("current directory"); + +#if defined(DEV_BUILD) || defined(OPT_BUILD) || defined(DEV_BUILD_X86) + u32 flags = DEBUG_INFO | SUPER | INTERNAL; + u32 arch = Arch_X64; +#if defined(OPT_BUILD) + flags |= OPTIMIZATION; +#endif +#if defined(DEV_BUILD_X86) + arch = Arch_X86; +#endif + standard_build(&arena, cdir, flags, arch); + +#elif defined(PACKAGE) + package(&arena, cdir); + +#else +# error No build type specified. +#endif + + return(error_state); +} + +// BOTTOM + diff --git a/bin/package.bat b/bin/package.bat index baaf09d7..e9f0923d 100644 --- a/bin/package.bat +++ b/bin/package.bat @@ -1,3 +1,3 @@ @echo off -build.bat /DPACKAGE +bin\build.bat /DPACKAGE diff --git a/custom/4coder_file_moving.h b/custom/4coder_file_moving.h index 4a6d17fd..00c36256 100644 --- a/custom/4coder_file_moving.h +++ b/custom/4coder_file_moving.h @@ -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); } diff --git a/custom/4coder_project_commands.cpp b/custom/4coder_project_commands.cpp index ad293394..bf760b6c 100644 --- a/custom/4coder_project_commands.cpp +++ b/custom/4coder_project_commands.cpp @@ -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); diff --git a/custom/bin/buildsuper_x86.bat b/custom/bin/buildsuper_x86.bat index 934dbf68..ff76ead7 100644 --- a/custom/bin/buildsuper_x86.bat +++ b/custom/bin/buildsuper_x86.bat @@ -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: