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 ------------------------------------------
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
+45 -14
View File
@@ -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
+1 -1
View File
@@ -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"
+1 -1
View File
@@ -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
+1 -12
View File
@@ -13,17 +13,6 @@
#include <string.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
@@ -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)
+2 -2
View File
@@ -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
@@ -1,4 +1,4 @@
#define SUPPLEMENT_UNIT 1
#define BUILD_SUPPLEMENTARY_UNIT 1
#include "base/base_inc.h"
#include "os/os_inc.h"
+5
View File
@@ -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
+3 -3
View File
@@ -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 "]"
+5
View File
@@ -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
+5
View File
@@ -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
+11 -2
View File
@@ -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;
}
+2 -2
View File
@@ -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;
+1 -1
View File
@@ -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"