From 10bb28bb4030908661951ce9a1c64ec40f0c84c4 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Sun, 24 Jan 2021 15:30:57 -0800 Subject: [PATCH] Fix 32 bit windows build --- bin/4ed_build.cpp | 25 ++- bin/build-x86.bat | 3 +- custom/4coder_file.cpp | 2 +- custom/4coder_project_commands.cpp | 2 +- platform_win32/win32_4ed_functions.cpp | 5 +- project.4coder | 256 ++++++++++++------------- 6 files changed, 144 insertions(+), 149 deletions(-) diff --git a/bin/4ed_build.cpp b/bin/4ed_build.cpp index d9634306..9696943b 100644 --- a/bin/4ed_build.cpp +++ b/bin/4ed_build.cpp @@ -180,17 +180,14 @@ get_defines_from_flags(Arena *arena, u32 flags){ #if COMPILER_CL #define CL_OPTS \ -"-W4 -wd4310 -wd4100 -wd4201 -wd4505 -wd4996 " \ -"-wd4127 -wd4510 -wd4512 -wd4610 -wd4390 " \ +"-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 userenv.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_LIBS_COMMON \ +"user32.lib winmm.lib gdi32.lib opengl32.lib comdlg32.lib userenv.lib " +#define CL_LIBS_X64 CL_LIBS_COMMON FOREIGN_WIN "\\x64\\freetype.lib" +#define CL_LIBS_X86 CL_LIBS_COMMON FOREIGN_WIN "\\x86\\freetype.lib" #define CL_ICON "..\\4coder-non-source\\res\\icon.res" @@ -303,19 +300,19 @@ build(Arena *arena, u32 flags, u32 arch, char *code_path, char **code_files, cha #if OS_LINUX -# define GCC_OPTS \ +# define GCC_OPTS \ "-Wno-write-strings " \ "-D_GNU_SOURCE -fPIC " \ "-fno-threadsafe-statics -pthread " \ "-Wno-unused-result " \ "-std=c++11" -#define GCC_LIBS_COMMON \ +# 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 +# define GCC_LIBS_X64 GCC_LIBS_COMMON +# define GCC_LIBS_X86 GCC_LIBS_COMMON #else # error gcc options not set for this platform @@ -597,7 +594,7 @@ get_4coder_dist_name(Arena *arena, u32 platform, char *tier, u32 arch){ function void package_for_arch(Arena *arena, u32 arch, char *cdir, char *build_dir, char *pack_dir, i32 tier, char *tier_name, char *current_dist_tier, u32 flags, char** dist_files, i32 dist_file_count){ - char *arch_name = arch_names[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); diff --git a/bin/build-x86.bat b/bin/build-x86.bat index 1c761add..3c2449c7 100644 --- a/bin/build-x86.bat +++ b/bin/build-x86.bat @@ -1,3 +1,2 @@ @echo off - -build.bat /DDEV_BUILD_X86 +bin\build.bat /DDEV_BUILD_X86 diff --git a/custom/4coder_file.cpp b/custom/4coder_file.cpp index c702e51a..bc4dda64 100644 --- a/custom/4coder_file.cpp +++ b/custom/4coder_file.cpp @@ -19,7 +19,7 @@ data_from_file(Arena *arena, FILE *file){ result.size = ftell(file); fseek(file, 0, SEEK_SET); result.str = push_array(arena, u8, result.size + 1); - fread(result.str, 1, result.size, file); + fread(result.str, 1, (size_t)result.size, file); result.str[result.size] = 0; } return(result); diff --git a/custom/4coder_project_commands.cpp b/custom/4coder_project_commands.cpp index b451e636..3efe8821 100644 --- a/custom/4coder_project_commands.cpp +++ b/custom/4coder_project_commands.cpp @@ -1032,7 +1032,7 @@ CUSTOM_DOC("Prints the current project to the file it was loaded from; prints in for (String8Node *node = prj_string.first; node != 0; node = node->next){ - fwrite(node->string.str, 1, node->string.size, file); + fwrite(node->string.str, 1, (size_t)node->string.size, file); } fclose(file); print_message(app, str8_lit("Reloading project buffer\n")); diff --git a/platform_win32/win32_4ed_functions.cpp b/platform_win32/win32_4ed_functions.cpp index 379d5b60..339cd3bf 100644 --- a/platform_win32/win32_4ed_functions.cpp +++ b/platform_win32/win32_4ed_functions.cpp @@ -122,9 +122,8 @@ system_memory_annotation_sig(){ // 4ed path // -extern "C" { - BOOL GetUserProfileDirectoryW(HANDLE hToken, LPWSTR lpProfileDir, LPDWORD lpcchSize); -} +extern "C" BOOL CALL_CONVENTION +GetUserProfileDirectoryW(HANDLE hToken, LPWSTR lpProfileDir, LPDWORD lpcchSize); internal system_get_path_sig(){ diff --git a/project.4coder b/project.4coder index de392f9d..025616e5 100644 --- a/project.4coder +++ b/project.4coder @@ -2,146 +2,146 @@ version(2); project_name = "4coder"; patterns = { -"*.c", -"*.cpp", -"*.h", -"*.m", -"*.mm", -"*.bat", -"*.sh", -"*.4coder", -"*.txt", + "*.c", + "*.cpp", + "*.h", + "*.m", + "*.mm", + "*.bat", + "*.sh", + "*.4coder", + "*.txt", }; blacklist_patterns = { -".*", + ".*", }; load_path_shared = { .path = ".", .recursive = true, .relative = true, }; load_paths = { -.win = { load_path_shared }, -.linux = { load_path_shared }, -.mac = { load_path_shared }, + .win = { load_path_shared }, + .linux = { load_path_shared }, + .mac = { load_path_shared }, }; commands = { -.build_x64 = { -.win = "echo build: x64 & bin\\build.bat", -.linux = "echo build: x64 & bin/build-linux.sh", -.out = "*compilation*", -.footer_panel = true, -.save_dirty_files = true, -.cursor_at_end = false, -}, -.build_x86 = { -.win = "echo build: x86 & bin\\build.bat /DDEV_BUILD_X86", -.linux = "echo build: x86 & bin/build-linux.sh /DDEV_BUILD_X86", -.out = "*compilation*", -.footer_panel = true, -.save_dirty_files = true, -.cursor_at_end = false, -}, -.package = { -.win = "echo package & bin\\package.bat", -.linux = "echo package & bin/package.sh", -.out = "*compilation*", -.footer_panel = false, -.save_dirty_files = true, -.cursor_at_end = false, -}, -.run_one_time = { -.win = "pushd ..\\build & one_time", -.linux = "pushd ../build & one_time", -.out = "*run*", -.footer_panel = false, -.save_dirty_files = false, -.cursor_at_end = false, -}, -.build_custom_api_docs = { -.win = "custom\\bin\\build_one_time docs\\4ed_doc_custom_api_main.cpp ..\\build", -.out = "*compilation*", -.footer_panel = true, -.save_dirty_files = true, -.cursor_at_end = false, -}, -.build_C___lexer_generator = { -.win = "custom\bin\build_one_time custom\languages\4coder_cpp_lexer_gen.cpp ..\build", -.out = "*compilation*", -.footer_panel = true, -.save_dirty_files = true, -.cursor_at_end = false, -}, -.build_token_tester = { -.win = "custom\bin\build_one_time custom\languages\4coder_cpp_lexer_test.cpp ..\build", -.out = "*compilation*", -.footer_panel = true, -.save_dirty_files = true, -.cursor_at_end = false, -}, -.build_system_api = { -.win = "custom\bin\build_one_time 4ed_system_api.cpp ..\build", -.out = "*compilation*", -.footer_panel = true, -.save_dirty_files = true, -.cursor_at_end = false, -}, -.build_font_api = { -.win = "custom\bin\build_one_time 4ed_font_api.cpp ..\build", -.out = "*compilation*", -.footer_panel = true, -.save_dirty_files = true, -.cursor_at_end = false, -}, -.build_graphics_api = { -.win = "custom\bin\build_one_time 4ed_graphics_api.cpp ..\build", -.out = "*compilation*", -.footer_panel = true, -.save_dirty_files = true, -.cursor_at_end = false, -}, -.build_api_parser = { -.win = "custom\bin\build_one_time 4ed_api_parser_main.cpp ..\build & copy /B ..\build\one_time.exe ..\build\api_parser.exe", -.out = "*compilation*", -.footer_panel = true, -.save_dirty_files = true, -.cursor_at_end = false, -}, -.build_api_checker = { -.win = "custom\bin\build_one_time 4ed_api_check.cpp ..\build & copy /B ..\build\one_time.exe ..\build\api_checker.exe", -.out = "*compilation*", -.footer_panel = true, -.save_dirty_files = true, -.cursor_at_end = false, -}, -.build_keycode_generator = { -.win = "custom\bin\build_one_time 4ed_generate_keycodes.cpp ..\build", -.out = "*compilation*", -.footer_panel = true, -.save_dirty_files = true, -.cursor_at_end = false, -}, -.build_site_render = { -.win = "custom\bin\build_one_time site/4ed_site_render_main.cpp ..\build", -.out = "*compilation*", -.footer_panel = true, -.save_dirty_files = true, -.cursor_at_end = false, -}, -.generate_custom_api_master_list = { -.win = "..\build\api_parser 4ed_api_implementation.cpp", -.out = "*run*", -.footer_panel = false, -.save_dirty_files = false, -.cursor_at_end = false, -}, + .build_x64 = { + .win = "echo build: x64 & bin\\build.bat", + .linux = "echo build: x64 & bin/build-linux.sh", + .out = "*compilation*", + .footer_panel = true, + .save_dirty_files = true, + .cursor_at_end = false, + }, + .build_x86 = { + .win = "echo build: x86 & bin\\build.bat /DDEV_BUILD_X86", + .linux = "echo build: x86 & bin/build-linux.sh /DDEV_BUILD_X86", + .out = "*compilation*", + .footer_panel = true, + .save_dirty_files = true, + .cursor_at_end = false, + }, + .package = { + .win = "echo package & bin\\package.bat", + .linux = "echo package & bin/package.sh", + .out = "*compilation*", + .footer_panel = false, + .save_dirty_files = true, + .cursor_at_end = false, + }, + .run_one_time = { + .win = "pushd ..\\build & one_time", + .linux = "pushd ../build & one_time", + .out = "*run*", + .footer_panel = false, + .save_dirty_files = false, + .cursor_at_end = false, + }, + .build_custom_api_docs = { + .win = "custom\\bin\\build_one_time docs\\4ed_doc_custom_api_main.cpp ..\\build", + .out = "*compilation*", + .footer_panel = true, + .save_dirty_files = true, + .cursor_at_end = false, + }, + .build_C___lexer_generator = { + .win = "custom\bin\build_one_time custom\languages\4coder_cpp_lexer_gen.cpp ..\build", + .out = "*compilation*", + .footer_panel = true, + .save_dirty_files = true, + .cursor_at_end = false, + }, + .build_token_tester = { + .win = "custom\bin\build_one_time custom\languages\4coder_cpp_lexer_test.cpp ..\build", + .out = "*compilation*", + .footer_panel = true, + .save_dirty_files = true, + .cursor_at_end = false, + }, + .build_system_api = { + .win = "custom\bin\build_one_time 4ed_system_api.cpp ..\build", + .out = "*compilation*", + .footer_panel = true, + .save_dirty_files = true, + .cursor_at_end = false, + }, + .build_font_api = { + .win = "custom\bin\build_one_time 4ed_font_api.cpp ..\build", + .out = "*compilation*", + .footer_panel = true, + .save_dirty_files = true, + .cursor_at_end = false, + }, + .build_graphics_api = { + .win = "custom\bin\build_one_time 4ed_graphics_api.cpp ..\build", + .out = "*compilation*", + .footer_panel = true, + .save_dirty_files = true, + .cursor_at_end = false, + }, + .build_api_parser = { + .win = "custom\bin\build_one_time 4ed_api_parser_main.cpp ..\build & copy /B ..\build\one_time.exe ..\build\api_parser.exe", + .out = "*compilation*", + .footer_panel = true, + .save_dirty_files = true, + .cursor_at_end = false, + }, + .build_api_checker = { + .win = "custom\bin\build_one_time 4ed_api_check.cpp ..\build & copy /B ..\build\one_time.exe ..\build\api_checker.exe", + .out = "*compilation*", + .footer_panel = true, + .save_dirty_files = true, + .cursor_at_end = false, + }, + .build_keycode_generator = { + .win = "custom\bin\build_one_time 4ed_generate_keycodes.cpp ..\build", + .out = "*compilation*", + .footer_panel = true, + .save_dirty_files = true, + .cursor_at_end = false, + }, + .build_site_render = { + .win = "custom\bin\build_one_time site/4ed_site_render_main.cpp ..\build", + .out = "*compilation*", + .footer_panel = true, + .save_dirty_files = true, + .cursor_at_end = false, + }, + .generate_custom_api_master_list = { + .win = "..\build\api_parser 4ed_api_implementation.cpp", + .out = "*run*", + .footer_panel = false, + .save_dirty_files = false, + .cursor_at_end = false, + }, }; fkey_command = { -.F1 = "build_x64", -.F3 = "build_site_render", -.F4 = "run_one_time", -.F5 = "build_C___lexer_generator", -.F6 = "build_token_tester", -.F11 = "package", + .F1 = "build_x64", + .F3 = "build_site_render", + .F4 = "run_one_time", + .F5 = "build_C___lexer_generator", + .F6 = "build_token_tester", + .F11 = "package", };