pull out & organize build configuration options, including entry point style, to context cracker

This commit is contained in:
Ryan Fleury
2024-02-25 13:30:15 -08:00
parent c4b8916bcf
commit d8cf83b4d7
14 changed files with 87 additions and 45 deletions
+4 -6
View File
@@ -43,18 +43,16 @@ if "%asan%"=="1" set auto_compile_flags=%auto_compile_flags% -fsanitize=add
:: --- Compile/Link Line Definitions ------------------------------------------ :: --- Compile/Link Line Definitions ------------------------------------------
set cl_common= /I..\src\ /I..\local\ /nologo /FC /Z7 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 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_debug= call cl /Od /DBUILD_DEBUG=1 %cl_common% %auto_compile_flags%
set cl_release= call cl /O2 /DNDEBUG %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 %clang_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 -DNDEBUG %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 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 clang_link= -fuse-ld=lld -Xlinker /MANIFEST:EMBED -Xlinker /natvis:"%~dp0\src\natvis\base.natvis" logo.res
set cl_out= /out: set cl_out= /out:
set clang_out= -o set clang_out= -o
:: --- Per-Build Settings ----------------------------------------------------- :: --- Per-Build Settings -----------------------------------------------------
set gfx=-DOS_FEATURE_GRAPHICAL=1
set net=-DOS_FEATURE_SOCKET=1
set link_dll=-DLL set link_dll=-DLL
if "%msvc%"=="1" set only_compile=/c if "%msvc%"=="1" set only_compile=/c
if "%clang%"=="1" set only_compile=-c if "%clang%"=="1" set only_compile=-c
+45 -14
View File
@@ -4,6 +4,9 @@
#ifndef BASE_CONTEXT_CRACKING_H #ifndef BASE_CONTEXT_CRACKING_H
#define BASE_CONTEXT_CRACKING_H #define BASE_CONTEXT_CRACKING_H
////////////////////////////////
//~ rjf: Clang OS/Arch Cracking
#if defined(__clang__) #if defined(__clang__)
# define COMPILER_CLANG 1 # define COMPILER_CLANG 1
@@ -15,7 +18,7 @@
# elif defined(__APPLE__) && defined(__MACH__) # elif defined(__APPLE__) && defined(__MACH__)
# define OS_MAC 1 # define OS_MAC 1
# else # else
# error This compiler/platform combo is not supported yet # error This compiler/OS combo is not supported.
# endif # endif
# if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) # if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64)
@@ -27,9 +30,12 @@
# elif defined(__arm__) # elif defined(__arm__)
# define ARCH_ARM32 1 # define ARCH_ARM32 1
# else # else
# error architecture not supported yet # error Architecture not supported.
# endif # endif
////////////////////////////////
//~ rjf: MSVC OS/Arch Cracking
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
# define COMPILER_MSVC 1 # define COMPILER_MSVC 1
@@ -57,7 +63,7 @@
# if defined(_WIN32) # if defined(_WIN32)
# define OS_WINDOWS 1 # define OS_WINDOWS 1
# else # else
# error This compiler/platform combo is not supported yet # error This compiler/OS combo is not supported.
# endif # endif
# if defined(_M_AMD64) # if defined(_M_AMD64)
@@ -69,9 +75,12 @@
# elif defined(_M_ARM) # elif defined(_M_ARM)
# define ARCH_ARM32 1 # define ARCH_ARM32 1
# else # else
# error architecture not supported yet # error Architecture not supported.
# endif # endif
////////////////////////////////
//~ rjf: GCC OS/Arch Cracking
#elif defined(__GNUC__) || defined(__GNUG__) #elif defined(__GNUC__) || defined(__GNUG__)
# define COMPILER_GCC 1 # define COMPILER_GCC 1
@@ -79,7 +88,7 @@
# if defined(__gnu_linux__) || defined(__linux__) # if defined(__gnu_linux__) || defined(__linux__)
# define OS_LINUX 1 # define OS_LINUX 1
# else # else
# error This compiler/platform combo is not supported yet # error This compiler/OS combo is not supported.
# endif # endif
# if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) # if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64)
@@ -91,26 +100,54 @@
# elif defined(__arm__) # elif defined(__arm__)
# define ARCH_ARM32 1 # define ARCH_ARM32 1
# else # else
# error architecture not supported yet # error Architecture not supported.
# endif # endif
#else #else
# error This compiler is not supported yet # error Compiler not supported.
#endif #endif
////////////////////////////////
//~ rjf: Arch Cracking
#if defined(ARCH_X64) #if defined(ARCH_X64)
# define ARCH_64BIT 1 # define ARCH_64BIT 1
#elif defined(ARCH_X86) #elif defined(ARCH_X86)
# define ARCH_32BIT 1 # define ARCH_32BIT 1
#endif #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) #if defined(__cplusplus)
# define LANG_CPP 1 # define LANG_CPP 1
#else #else
# define LANG_C 1 # define LANG_C 1
#endif #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) #if !defined(ARCH_32BIT)
# define ARCH_32BIT 0 # define ARCH_32BIT 0
@@ -155,10 +192,4 @@
# define LANG_C 0 # define LANG_C 0
#endif #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 #endif // BASE_CONTEXT_CRACKING_H
+1 -1
View File
@@ -4,7 +4,7 @@
//////////////////////////////// ////////////////////////////////
//~ rjf: Third Party Includes //~ rjf: Third Party Includes
#if !SUPPLEMENT_UNIT #if !BUILD_SUPPLEMENTARY_UNIT
# define STB_SPRINTF_IMPLEMENTATION # define STB_SPRINTF_IMPLEMENTATION
# define STB_SPRINTF_STATIC # define STB_SPRINTF_STATIC
# include "third_party/stb/stb_sprintf.h" # include "third_party/stb/stb_sprintf.h"
+1 -1
View File
@@ -5,7 +5,7 @@
// NOTE(allen): Thread Context Functions // NOTE(allen): Thread Context Functions
C_LINKAGE thread_static TCTX* tctx_thread_local; C_LINKAGE thread_static TCTX* tctx_thread_local;
#if !SUPPLEMENT_UNIT #if !BUILD_SUPPLEMENTARY_UNIT
C_LINKAGE thread_static TCTX* tctx_thread_local = 0; C_LINKAGE thread_static TCTX* tctx_thread_local = 0;
#endif #endif
+1 -12
View File
@@ -13,17 +13,6 @@
#include <string.h> #include <string.h>
#include <stdint.h> #include <stdint.h>
////////////////////////////////
//~ rjf: Build Configuration
#if !defined(ENABLE_DEV)
# define ENABLE_DEV 0
#endif
#if !defined(SUPPLEMENT_UNIT)
# define SUPPLEMENT_UNIT 0
#endif
//////////////////////////////// ////////////////////////////////
//~ rjf: Codebase Keywords //~ rjf: Codebase Keywords
@@ -93,7 +82,7 @@
#endif #endif
#define AssertAlways(x) do{if(!(x)) {Trap();}}while(0) #define AssertAlways(x) do{if(!(x)) {Trap();}}while(0)
#if !defined(NDEBUG) #if BUILD_DEBUG
# define Assert(x) AssertAlways(x) # define Assert(x) AssertAlways(x)
#else #else
# define Assert(x) (void)(x) # define Assert(x) (void)(x)
+2 -2
View File
@@ -1012,7 +1012,7 @@ df_window_from_os_handle(OS_Handle os)
return result; return result;
} }
#if defined(_MSC_VER) && !defined(__clang__) && defined(NDEBUG) #if COMPILER_MSVC && !BUILD_DEBUG
#pragma optimize("", off) #pragma optimize("", off)
#endif #endif
@@ -6807,7 +6807,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D
ProfEnd(); ProfEnd();
} }
#if defined(_MSC_VER) && !defined(__clang__) && defined(NDEBUG) #if COMPILER_MSVC && !BUILD_DEBUG
#pragma optimize("", on) #pragma optimize("", on)
#endif #endif
@@ -1,4 +1,4 @@
#define SUPPLEMENT_UNIT 1 #define BUILD_SUPPLEMENTARY_UNIT 1
#include "base/base_inc.h" #include "base/base_inc.h"
#include "os/os_inc.h" #include "os/os_inc.h"
+5
View File
@@ -1,6 +1,11 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
////////////////////////////////
//~ rjf: Build Options
#define BUILD_CONSOLE_INTERFACE 1
//////////////////////////////// ////////////////////////////////
//~ rjf: Includes //~ rjf: Includes
+3 -3
View File
@@ -407,10 +407,10 @@
#define RADDBG_VERSION_MINOR 9 #define RADDBG_VERSION_MINOR 9
#define RADDBG_VERSION_PATCH 8 #define RADDBG_VERSION_PATCH 8
#define RADDBG_VERSION_STRING_LITERAL Stringify(RADDBG_VERSION_MAJOR) "." Stringify(RADDBG_VERSION_MINOR) "." Stringify(RADDBG_VERSION_PATCH) #define RADDBG_VERSION_STRING_LITERAL Stringify(RADDBG_VERSION_MAJOR) "." Stringify(RADDBG_VERSION_MINOR) "." Stringify(RADDBG_VERSION_PATCH)
#if defined(NDEBUG) #if BUILD_DEBUG
# define RADDBG_BUILD_STR ""
#else
# define RADDBG_BUILD_STR " [Debug]" # define RADDBG_BUILD_STR " [Debug]"
#else
# define RADDBG_BUILD_STR ""
#endif #endif
#if defined(RADDBG_GIT) #if defined(RADDBG_GIT)
# define RADDBG_GIT_STR " [" RADDBG_GIT "]" # define RADDBG_GIT_STR " [" RADDBG_GIT "]"
+5
View File
@@ -1,6 +1,11 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
////////////////////////////////
//~ rjf: Build Settings
#define OS_FEATURE_GRAPHICAL 1
//////////////////////////////// ////////////////////////////////
//~ rjf: Includes //~ rjf: Includes
+5
View File
@@ -1,6 +1,11 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
////////////////////////////////
//~ rjf: Build Options
#define BUILD_CONSOLE_INTERFACE 1
//////////////////////////////// ////////////////////////////////
//~ rjf: Includes //~ rjf: Includes
+11 -2
View File
@@ -1,6 +1,14 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
////////////////////////////////
//~ rjf: Build Options
#define BUILD_CONSOLE_INTERFACE 1
////////////////////////////////
//~ rjf: Includes
//- rjf: [lib] //- rjf: [lib]
#include "lib_raddbgi_format/raddbgi_format.h" #include "lib_raddbgi_format/raddbgi_format.h"
#include "lib_raddbgi_format/raddbgi_format.c" #include "lib_raddbgi_format/raddbgi_format.c"
@@ -31,7 +39,8 @@
#include "pdb/pdb_stringize.c" #include "pdb/pdb_stringize.c"
#include "raddbgi_from_pdb.c" #include "raddbgi_from_pdb.c"
//- rjf: entry point ////////////////////////////////
//~ rjf: Entry Point
int int
main(int argc, char **argv) main(int argc, char **argv)
@@ -110,5 +119,5 @@ main(int argc, char **argv)
ProfEndCapture(); ProfEndCapture();
} }
return(0); return 0;
} }
+2 -2
View File
@@ -142,7 +142,7 @@ r_init(CmdLine *cmdln)
//- rjf: create base device //- rjf: create base device
UINT creation_flags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; UINT creation_flags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
#if !defined(NDEBUG) #if BUILD_DEBUG
if(cmd_line_has_flag(cmdln, str8_lit("d3d11_debug"))) if(cmd_line_has_flag(cmdln, str8_lit("d3d11_debug")))
{ {
creation_flags |= D3D11_CREATE_DEVICE_DEBUG; creation_flags |= D3D11_CREATE_DEVICE_DEBUG;
@@ -182,7 +182,7 @@ r_init(CmdLine *cmdln)
} }
//- rjf: enable break-on-error //- rjf: enable break-on-error
#if !defined(NDEBUG) #if BUILD_DEBUG
if(cmd_line_has_flag(cmdln, str8_lit("d3d11_debug"))) if(cmd_line_has_flag(cmdln, str8_lit("d3d11_debug")))
{ {
ID3D11InfoQueue *info = 0; ID3D11InfoQueue *info = 0;
+1 -1
View File
@@ -1,7 +1,7 @@
// Copyright (c) 2024 Epic Games Tools // Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/) // Licensed under the MIT license (https://opensource.org/license/mit/)
#define SUPPLEMENT_UNIT 1 #define BUILD_SUPPLEMENTARY_UNIT 1
#define OS_FEATURE_GRAPHICAL 1 #define OS_FEATURE_GRAPHICAL 1
#include "base/base_inc.h" #include "base/base_inc.h"