diff --git a/build.bat b/build.bat index 56121a31..e925bcad 100644 --- a/build.bat +++ b/build.bat @@ -43,18 +43,16 @@ if "%asan%"=="1" set auto_compile_flags=%auto_compile_flags% -fsanitize=add :: --- Compile/Link Line Definitions ------------------------------------------ set cl_common= /I..\src\ /I..\local\ /nologo /FC /Z7 set clang_common= -I..\src\ -I..\local\ -gcodeview -fdiagnostics-absolute-paths -Wall -Wno-unknown-warning-option -Wno-missing-braces -Wno-unused-function -Wno-writable-strings -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-register -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-single-bit-bitfield-constant-conversion -Xclang -flto-visibility-public-std -D_USE_MATH_DEFINES -Dstrdup=_strdup -Dgnu_printf=printf -set cl_debug= call cl /Od %cl_common% %auto_compile_flags% -set cl_release= call cl /O2 /DNDEBUG %cl_common% %auto_compile_flags% -set clang_debug= call clang -g -O0 %clang_common% %auto_compile_flags% -set clang_release= call clang -g -O2 -DNDEBUG %clang_common% %auto_compile_flags% +set cl_debug= call cl /Od /DBUILD_DEBUG=1 %cl_common% %auto_compile_flags% +set cl_release= call cl /O2 /DBUILD_DEBUG=0 %cl_common% %auto_compile_flags% +set clang_debug= call clang -g -O0 /DBUILD_DEBUG=1 %clang_common% %auto_compile_flags% +set clang_release= call clang -g -O2 -DBUILD_DEBUG=0 %clang_common% %auto_compile_flags% set cl_link= /link /MANIFEST:EMBED /INCREMENTAL:NO /natvis:"%~dp0\src\natvis\base.natvis" logo.res set clang_link= -fuse-ld=lld -Xlinker /MANIFEST:EMBED -Xlinker /natvis:"%~dp0\src\natvis\base.natvis" logo.res set cl_out= /out: set clang_out= -o :: --- Per-Build Settings ----------------------------------------------------- -set gfx=-DOS_FEATURE_GRAPHICAL=1 -set net=-DOS_FEATURE_SOCKET=1 set link_dll=-DLL if "%msvc%"=="1" set only_compile=/c if "%clang%"=="1" set only_compile=-c diff --git a/src/base/base_context_cracking.h b/src/base/base_context_cracking.h index b918cfdf..e9b2b8cc 100644 --- a/src/base/base_context_cracking.h +++ b/src/base/base_context_cracking.h @@ -4,6 +4,9 @@ #ifndef BASE_CONTEXT_CRACKING_H #define BASE_CONTEXT_CRACKING_H +//////////////////////////////// +//~ rjf: Clang OS/Arch Cracking + #if defined(__clang__) # define COMPILER_CLANG 1 @@ -15,7 +18,7 @@ # elif defined(__APPLE__) && defined(__MACH__) # define OS_MAC 1 # else -# error This compiler/platform combo is not supported yet +# error This compiler/OS combo is not supported. # endif # if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) @@ -27,9 +30,12 @@ # elif defined(__arm__) # define ARCH_ARM32 1 # else -# error architecture not supported yet +# error Architecture not supported. # endif +//////////////////////////////// +//~ rjf: MSVC OS/Arch Cracking + #elif defined(_MSC_VER) # define COMPILER_MSVC 1 @@ -57,7 +63,7 @@ # if defined(_WIN32) # define OS_WINDOWS 1 # else -# error This compiler/platform combo is not supported yet +# error This compiler/OS combo is not supported. # endif # if defined(_M_AMD64) @@ -69,9 +75,12 @@ # elif defined(_M_ARM) # define ARCH_ARM32 1 # else -# error architecture not supported yet +# error Architecture not supported. # endif +//////////////////////////////// +//~ rjf: GCC OS/Arch Cracking + #elif defined(__GNUC__) || defined(__GNUG__) # define COMPILER_GCC 1 @@ -79,7 +88,7 @@ # if defined(__gnu_linux__) || defined(__linux__) # define OS_LINUX 1 # else -# error This compiler/platform combo is not supported yet +# error This compiler/OS combo is not supported. # endif # if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) @@ -91,26 +100,54 @@ # elif defined(__arm__) # define ARCH_ARM32 1 # else -# error architecture not supported yet +# error Architecture not supported. # endif #else -# error This compiler is not supported yet +# error Compiler not supported. #endif +//////////////////////////////// +//~ rjf: Arch Cracking + #if defined(ARCH_X64) # define ARCH_64BIT 1 #elif defined(ARCH_X86) # define ARCH_32BIT 1 #endif +#if ARCH_ARM32 || ARCH_ARM64 || ARCH_X64 || ARCH_X86 +# define ARCH_LITTLE_ENDIAN 1 +#else +# error Endianness of this architecture not understood by context cracker. +#endif + +//////////////////////////////// +//~ rjf: Language Cracking + #if defined(__cplusplus) # define LANG_CPP 1 #else # define LANG_C 1 #endif -// zeroify +//////////////////////////////// +//~ rjf: Build Option Cracking + +#if !defined(BUILD_DEBUG) +# define BUILD_DEBUG 1 +#endif + +#if !defined(BUILD_SUPPLEMENTARY_UNIT) +# define BUILD_SUPPLEMENTARY_UNIT 0 +#endif + +#if !defined(BUILD_CONSOLE_INTERFACE) +# define BUILD_CONSOLE_INTERFACE 0 +#endif + +//////////////////////////////// +//~ rjf: Zero All Undefined Options #if !defined(ARCH_32BIT) # define ARCH_32BIT 0 @@ -155,10 +192,4 @@ # define LANG_C 0 #endif -#if ARCH_ARM32 || ARCH_ARM64 || ARCH_X64 || ARCH_X86 -# define ARCH_LITTLE_ENDIAN 1 -#else -# error Endianness of this architecture not understood by context cracker -#endif - #endif // BASE_CONTEXT_CRACKING_H diff --git a/src/base/base_string.c b/src/base/base_string.c index 4959dbb7..f213187b 100644 --- a/src/base/base_string.c +++ b/src/base/base_string.c @@ -4,7 +4,7 @@ //////////////////////////////// //~ rjf: Third Party Includes -#if !SUPPLEMENT_UNIT +#if !BUILD_SUPPLEMENTARY_UNIT # define STB_SPRINTF_IMPLEMENTATION # define STB_SPRINTF_STATIC # include "third_party/stb/stb_sprintf.h" diff --git a/src/base/base_thread_context.c b/src/base/base_thread_context.c index 33ae9e50..45ab7afe 100644 --- a/src/base/base_thread_context.c +++ b/src/base/base_thread_context.c @@ -5,7 +5,7 @@ // NOTE(allen): Thread Context Functions C_LINKAGE thread_static TCTX* tctx_thread_local; -#if !SUPPLEMENT_UNIT +#if !BUILD_SUPPLEMENTARY_UNIT C_LINKAGE thread_static TCTX* tctx_thread_local = 0; #endif diff --git a/src/base/base_types.h b/src/base/base_types.h index d91358c6..3eb1f78f 100644 --- a/src/base/base_types.h +++ b/src/base/base_types.h @@ -13,17 +13,6 @@ #include #include -//////////////////////////////// -//~ rjf: Build Configuration - -#if !defined(ENABLE_DEV) -# define ENABLE_DEV 0 -#endif - -#if !defined(SUPPLEMENT_UNIT) -# define SUPPLEMENT_UNIT 0 -#endif - //////////////////////////////// //~ rjf: Codebase Keywords @@ -93,7 +82,7 @@ #endif #define AssertAlways(x) do{if(!(x)) {Trap();}}while(0) -#if !defined(NDEBUG) +#if BUILD_DEBUG # define Assert(x) AssertAlways(x) #else # define Assert(x) (void)(x) diff --git a/src/df/gfx/df_gfx.c b/src/df/gfx/df_gfx.c index 938269ff..a7a8e9ad 100644 --- a/src/df/gfx/df_gfx.c +++ b/src/df/gfx/df_gfx.c @@ -1012,7 +1012,7 @@ df_window_from_os_handle(OS_Handle os) return result; } -#if defined(_MSC_VER) && !defined(__clang__) && defined(NDEBUG) +#if COMPILER_MSVC && !BUILD_DEBUG #pragma optimize("", off) #endif @@ -6807,7 +6807,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D ProfEnd(); } -#if defined(_MSC_VER) && !defined(__clang__) && defined(NDEBUG) +#if COMPILER_MSVC && !BUILD_DEBUG #pragma optimize("", on) #endif diff --git a/src/font_provider/dwrite/font_provider_dwrite_main.cpp b/src/font_provider/dwrite/font_provider_dwrite_main.cpp index e145de25..4ebbb9b2 100644 --- a/src/font_provider/dwrite/font_provider_dwrite_main.cpp +++ b/src/font_provider/dwrite/font_provider_dwrite_main.cpp @@ -1,4 +1,4 @@ -#define SUPPLEMENT_UNIT 1 +#define BUILD_SUPPLEMENTARY_UNIT 1 #include "base/base_inc.h" #include "os/os_inc.h" diff --git a/src/metagen/metagen_main.c b/src/metagen/metagen_main.c index 1ab89502..7ad38268 100644 --- a/src/metagen/metagen_main.c +++ b/src/metagen/metagen_main.c @@ -1,6 +1,11 @@ // Copyright (c) 2024 Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) +//////////////////////////////// +//~ rjf: Build Options + +#define BUILD_CONSOLE_INTERFACE 1 + //////////////////////////////// //~ rjf: Includes diff --git a/src/raddbg/raddbg.h b/src/raddbg/raddbg.h index 777c2b15..0f72cb57 100644 --- a/src/raddbg/raddbg.h +++ b/src/raddbg/raddbg.h @@ -407,10 +407,10 @@ #define RADDBG_VERSION_MINOR 9 #define RADDBG_VERSION_PATCH 8 #define RADDBG_VERSION_STRING_LITERAL Stringify(RADDBG_VERSION_MAJOR) "." Stringify(RADDBG_VERSION_MINOR) "." Stringify(RADDBG_VERSION_PATCH) -#if defined(NDEBUG) -# define RADDBG_BUILD_STR "" -#else +#if BUILD_DEBUG # define RADDBG_BUILD_STR " [Debug]" +#else +# define RADDBG_BUILD_STR "" #endif #if defined(RADDBG_GIT) # define RADDBG_GIT_STR " [" RADDBG_GIT "]" diff --git a/src/raddbg/raddbg_main.cpp b/src/raddbg/raddbg_main.cpp index b8db5c55..fef04980 100644 --- a/src/raddbg/raddbg_main.cpp +++ b/src/raddbg/raddbg_main.cpp @@ -1,6 +1,11 @@ // Copyright (c) 2024 Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) +//////////////////////////////// +//~ rjf: Build Settings + +#define OS_FEATURE_GRAPHICAL 1 + //////////////////////////////// //~ rjf: Includes diff --git a/src/raddbgi_dump/raddbgi_dump_main.c b/src/raddbgi_dump/raddbgi_dump_main.c index 75177ba6..3b154a09 100644 --- a/src/raddbgi_dump/raddbgi_dump_main.c +++ b/src/raddbgi_dump/raddbgi_dump_main.c @@ -1,6 +1,11 @@ // Copyright (c) 2024 Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) +//////////////////////////////// +//~ rjf: Build Options + +#define BUILD_CONSOLE_INTERFACE 1 + //////////////////////////////// //~ rjf: Includes diff --git a/src/raddbgi_from_pdb/raddbgi_from_pdb_main.c b/src/raddbgi_from_pdb/raddbgi_from_pdb_main.c index c3b53afd..dcb6e420 100644 --- a/src/raddbgi_from_pdb/raddbgi_from_pdb_main.c +++ b/src/raddbgi_from_pdb/raddbgi_from_pdb_main.c @@ -1,6 +1,14 @@ // Copyright (c) 2024 Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) +//////////////////////////////// +//~ rjf: Build Options + +#define BUILD_CONSOLE_INTERFACE 1 + +//////////////////////////////// +//~ rjf: Includes + //- rjf: [lib] #include "lib_raddbgi_format/raddbgi_format.h" #include "lib_raddbgi_format/raddbgi_format.c" @@ -31,7 +39,8 @@ #include "pdb/pdb_stringize.c" #include "raddbgi_from_pdb.c" -//- rjf: entry point +//////////////////////////////// +//~ rjf: Entry Point int main(int argc, char **argv) @@ -110,5 +119,5 @@ main(int argc, char **argv) ProfEndCapture(); } - return(0); + return 0; } diff --git a/src/render/d3d11/render_d3d11.cpp b/src/render/d3d11/render_d3d11.cpp index c03573e5..4599433c 100644 --- a/src/render/d3d11/render_d3d11.cpp +++ b/src/render/d3d11/render_d3d11.cpp @@ -142,7 +142,7 @@ r_init(CmdLine *cmdln) //- rjf: create base device UINT creation_flags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; -#if !defined(NDEBUG) +#if BUILD_DEBUG if(cmd_line_has_flag(cmdln, str8_lit("d3d11_debug"))) { creation_flags |= D3D11_CREATE_DEVICE_DEBUG; @@ -182,7 +182,7 @@ r_init(CmdLine *cmdln) } //- rjf: enable break-on-error -#if !defined(NDEBUG) +#if BUILD_DEBUG if(cmd_line_has_flag(cmdln, str8_lit("d3d11_debug"))) { ID3D11InfoQueue *info = 0; diff --git a/src/render/d3d11/render_d3d11_main.cpp b/src/render/d3d11/render_d3d11_main.cpp index 94367153..1a9e6b0d 100644 --- a/src/render/d3d11/render_d3d11_main.cpp +++ b/src/render/d3d11/render_d3d11_main.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2024 Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) -#define SUPPLEMENT_UNIT 1 +#define BUILD_SUPPLEMENTARY_UNIT 1 #define OS_FEATURE_GRAPHICAL 1 #include "base/base_inc.h"