From b22f5892032545fbdb1a344ed1934202765de27a Mon Sep 17 00:00:00 2001 From: Ed_ Date: Tue, 24 Oct 2023 12:46:59 -0400 Subject: [PATCH] Progress on preparing raylib for usage --- .vscode/launch.json | 9 + .../dependencies/raylib/include/config.h | 175 +++++++++--------- .../dependencies/raylib/raylib_refactor.cpp | 56 ++++++ project/auxillary/vis_ast/update_deps.ps1 | 103 +++++++---- 4 files changed, 223 insertions(+), 120 deletions(-) create mode 100644 project/auxillary/vis_ast/dependencies/raylib/raylib_refactor.cpp diff --git a/.vscode/launch.json b/.vscode/launch.json index ae30b68..0790fd6 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -40,6 +40,15 @@ "args": [], "cwd": "${workspaceFolder}/singleheader/", "visualizerFile": "${workspaceFolder}/scripts/gencpp.natvis" + }, + { + "type": "cppvsdbg", + "request": "launch", + "name": "Debug raylib refactor vsdbg", + "program": "${workspaceFolder}/project/auxillary/vis_ast/dependencies/raylib/build/raylib_refactor.exe", + "args": [], + "cwd": "${workspaceFolder}/project/auxillary/vis_ast/dependencies/temp/raylib-master/src/", + "visualizerFile": "${workspaceFolder}/scripts/gencpp.natvis" } ] } diff --git a/project/auxillary/vis_ast/dependencies/raylib/include/config.h b/project/auxillary/vis_ast/dependencies/raylib/include/config.h index 7886aee..6de2784 100644 --- a/project/auxillary/vis_ast/dependencies/raylib/include/config.h +++ b/project/auxillary/vis_ast/dependencies/raylib/include/config.h @@ -26,42 +26,42 @@ **********************************************************************************************/ #ifndef CONFIG_H -#define CONFIG_H +#define RL_CONFIG_H //------------------------------------------------------------------------------------ // Module selection - Some modules could be avoided // Mandatory modules: rcore, rlgl, utils //------------------------------------------------------------------------------------ -#define SUPPORT_MODULE_RSHAPES 1 -#define SUPPORT_MODULE_RTEXTURES 1 -#define SUPPORT_MODULE_RTEXT 1 // WARNING: It requires SUPPORT_MODULE_RTEXTURES to load sprite font textures -#define SUPPORT_MODULE_RMODELS 1 -#define SUPPORT_MODULE_RAUDIO 1 +#define RL_SUPPORT_MODULE_RSHAPES 1 +#define RL_SUPPORT_MODULE_RTEXTURES 1 +#define RL_SUPPORT_MODULE_RTEXT 1 // WARNING: It requires SUPPORT_MODULE_RTEXTURES to load sprite font textures +#define RL_SUPPORT_MODULE_RMODELS 1 +#define RL_SUPPORT_MODULE_RAUDIO 1 //------------------------------------------------------------------------------------ // Module: rcore - Configuration Flags //------------------------------------------------------------------------------------ // Camera module is included (rcamera.h) and multiple predefined cameras are available: free, 1st/3rd person, orbital -#define SUPPORT_CAMERA_SYSTEM 1 +#define RL_SUPPORT_CAMERA_SYSTEM 1 // Gestures module is included (rgestures.h) to support gestures detection: tap, hold, swipe, drag -#define SUPPORT_GESTURES_SYSTEM 1 +#define RL_SUPPORT_GESTURES_SYSTEM 1 // Mouse gestures are directly mapped like touches and processed by gestures system -#define SUPPORT_MOUSE_GESTURES 1 +#define RL_SUPPORT_MOUSE_GESTURES 1 // Reconfigure standard input to receive key inputs, works with SSH connection. -#define SUPPORT_SSH_KEYBOARD_RPI 1 +#define RL_SUPPORT_SSH_KEYBOARD_RPI 1 // Setting a higher resolution can improve the accuracy of time-out intervals in wait functions. // However, it can also reduce overall system performance, because the thread scheduler switches tasks more often. -#define SUPPORT_WINMM_HIGHRES_TIMER 1 +#define RL_SUPPORT_WINMM_HIGHRES_TIMER 1 // Use busy wait loop for timing sync, if not defined, a high-resolution timer is set up and used //#define SUPPORT_BUSY_WAIT_LOOP 1 // Use a partial-busy wait loop, in this case frame sleeps for most of the time, but then runs a busy loop at the end for accuracy -#define SUPPORT_PARTIALBUSY_WAIT_LOOP 1 +#define RL_SUPPORT_PARTIALBUSY_WAIT_LOOP 1 // Allow automatic screen capture of current screen pressing F12, defined in KeyCallback() -#define SUPPORT_SCREEN_CAPTURE 1 +#define RL_SUPPORT_SCREEN_CAPTURE 1 // Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback() -#define SUPPORT_GIF_RECORDING 1 +#define RL_SUPPORT_GIF_RECORDING 1 // Support CompressData() and DecompressData() functions -#define SUPPORT_COMPRESSION_API 1 +#define RL_SUPPORT_COMPRESSION_API 1 // Support automatic generated events, loading and recording of those events when required //#define SUPPORT_EVENTS_AUTOMATION 1 // Support custom frame control, only for advance users @@ -71,19 +71,19 @@ // rcore: Configuration values //------------------------------------------------------------------------------------ -#define MAX_FILEPATH_CAPACITY 8192 // Maximum file paths capacity -#define MAX_FILEPATH_LENGTH 4096 // Maximum length for filepaths (Linux PATH_MAX default value) +#define RL_MAX_FILEPATH_CAPACITY 8192 // Maximum file paths capacity +#define RL_MAX_FILEPATH_LENGTH 4096 // Maximum length for filepaths (Linux PATH_MAX default value) -#define MAX_KEYBOARD_KEYS 512 // Maximum number of keyboard keys supported -#define MAX_MOUSE_BUTTONS 8 // Maximum number of mouse buttons supported -#define MAX_GAMEPADS 4 // Maximum number of gamepads supported -#define MAX_GAMEPAD_AXIS 8 // Maximum number of axis supported (per gamepad) -#define MAX_GAMEPAD_BUTTONS 32 // Maximum number of buttons supported (per gamepad) -#define MAX_TOUCH_POINTS 8 // Maximum number of touch points supported -#define MAX_KEY_PRESSED_QUEUE 16 // Maximum number of keys in the key input queue -#define MAX_CHAR_PRESSED_QUEUE 16 // Maximum number of characters in the char input queue +#define RL_MAX_KEYBOARD_KEYS 512 // Maximum number of keyboard keys supported +#define RL_MAX_MOUSE_BUTTONS 8 // Maximum number of mouse buttons supported +#define RL_MAX_GAMEPADS 4 // Maximum number of gamepads supported +#define RL_MAX_GAMEPAD_AXIS 8 // Maximum number of axis supported (per gamepad) +#define RL_MAX_GAMEPAD_BUTTONS 32 // Maximum number of buttons supported (per gamepad) +#define RL_MAX_TOUCH_POINTS 8 // Maximum number of touch points supported +#define RL_MAX_KEY_PRESSED_QUEUE 16 // Maximum number of keys in the key input queue +#define RL_MAX_CHAR_PRESSED_QUEUE 16 // Maximum number of characters in the char input queue -#define MAX_DECOMPRESSION_SIZE 64 // Max size allocated for decompression in MB +#define RL_MAX_DECOMPRESSION_SIZE 64 // Max size allocated for decompression in MB //------------------------------------------------------------------------------------ @@ -97,35 +97,35 @@ //#define RLGL_SHOW_GL_DETAILS_INFO 1 //#define RL_DEFAULT_BATCH_BUFFER_ELEMENTS 4096 // Default internal render batch elements limits -#define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering) -#define RL_DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture) -#define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture()) +#define RL_DEFAULT_BATCH_BUFFERS 1 // Default number of batch buffers (multi-buffering) +#define RL_DEFAULT_BATCH_DRAWCALLS 256 // Default number of batch draw calls (by state changes: mode, texture) +#define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture()) -#define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack +#define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack -#define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported +#define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported -#define RL_CULL_DISTANCE_NEAR 0.01 // Default projection matrix near cull distance -#define RL_CULL_DISTANCE_FAR 1000.0 // Default projection matrix far cull distance +#define RL_CULL_DISTANCE_NEAR 0.01 // Default projection matrix near cull distance +#define RL_CULL_DISTANCE_FAR 1000.0 // Default projection matrix far cull distance // Default shader vertex attribute names to set location points // NOTE: When a new shader is loaded, the following locations are tried to be set for convenience -#define RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Bound by default to shader location: 0 -#define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Bound by default to shader location: 1 -#define RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Bound by default to shader location: 2 -#define RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Bound by default to shader location: 3 -#define RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT "vertexTangent" // Bound by default to shader location: 4 -#define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 "vertexTexCoord2" // Bound by default to shader location: 5 +#define RL_DEFAULT_SHADER_ATTRIB_NAME_POSITION "vertexPosition" // Bound by default to shader location: 0 +#define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD "vertexTexCoord" // Bound by default to shader location: 1 +#define RL_DEFAULT_SHADER_ATTRIB_NAME_NORMAL "vertexNormal" // Bound by default to shader location: 2 +#define RL_DEFAULT_SHADER_ATTRIB_NAME_COLOR "vertexColor" // Bound by default to shader location: 3 +#define RL_DEFAULT_SHADER_ATTRIB_NAME_TANGENT "vertexTangent" // Bound by default to shader location: 4 +#define RL_DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2 "vertexTexCoord2" // Bound by default to shader location: 5 -#define RL_DEFAULT_SHADER_UNIFORM_NAME_MVP "mvp" // model-view-projection matrix -#define RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW "matView" // view matrix -#define RL_DEFAULT_SHADER_UNIFORM_NAME_PROJECTION "matProjection" // projection matrix -#define RL_DEFAULT_SHADER_UNIFORM_NAME_MODEL "matModel" // model matrix -#define RL_DEFAULT_SHADER_UNIFORM_NAME_NORMAL "matNormal" // normal matrix (transpose(inverse(matModelView)) -#define RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR "colDiffuse" // color diffuse (base tint color, multiplied by texture color) -#define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0 "texture0" // texture0 (texture slot active 0) -#define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1 "texture1" // texture1 (texture slot active 1) -#define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2 "texture2" // texture2 (texture slot active 2) +#define RL_DEFAULT_SHADER_UNIFORM_NAME_MVP "mvp" // model-view-projection matrix +#define RL_DEFAULT_SHADER_UNIFORM_NAME_VIEW "matView" // view matrix +#define RL_DEFAULT_SHADER_UNIFORM_NAME_PROJECTION "matProjection" // projection matrix +#define RL_DEFAULT_SHADER_UNIFORM_NAME_MODEL "matModel" // model matrix +#define RL_DEFAULT_SHADER_UNIFORM_NAME_NORMAL "matNormal" // normal matrix (transpose(inverse(matModelView)) +#define RL_DEFAULT_SHADER_UNIFORM_NAME_COLOR "colDiffuse" // color diffuse (base tint color, multiplied by texture color) +#define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE0 "texture0" // texture0 (texture slot active 0) +#define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1 "texture1" // texture1 (texture slot active 1) +#define RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2 "texture2" // texture2 (texture slot active 2) //------------------------------------------------------------------------------------ @@ -133,21 +133,21 @@ //------------------------------------------------------------------------------------ // Use QUADS instead of TRIANGLES for drawing when possible // Some lines-based shapes could still use lines -#define SUPPORT_QUADS_DRAW_MODE 1 +#define RL_SUPPORT_QUADS_DRAW_MODE 1 //------------------------------------------------------------------------------------ // Module: rtextures - Configuration Flags //------------------------------------------------------------------------------------ // Selecte desired fileformats to be supported for image data loading -#define SUPPORT_FILEFORMAT_PNG 1 +#define RL_SUPPORT_FILEFORMAT_PNG 1 //#define SUPPORT_FILEFORMAT_BMP 1 //#define SUPPORT_FILEFORMAT_TGA 1 //#define SUPPORT_FILEFORMAT_JPG 1 -#define SUPPORT_FILEFORMAT_GIF 1 -#define SUPPORT_FILEFORMAT_QOI 1 +#define RL_SUPPORT_FILEFORMAT_GIF 1 +#define RL_SUPPORT_FILEFORMAT_QOI 1 //#define SUPPORT_FILEFORMAT_PSD 1 -#define SUPPORT_FILEFORMAT_DDS 1 +#define RL_SUPPORT_FILEFORMAT_DDS 1 //#define SUPPORT_FILEFORMAT_HDR 1 //#define SUPPORT_FILEFORMAT_PIC 1 //#define SUPPORT_FILEFORMAT_KTX 1 @@ -157,12 +157,12 @@ //#define SUPPORT_FILEFORMAT_SVG 1 // Support image export functionality (.png, .bmp, .tga, .jpg, .qoi) -#define SUPPORT_IMAGE_EXPORT 1 +#define RL_SUPPORT_IMAGE_EXPORT 1 // Support procedural image generation functionality (gradient, spot, perlin-noise, cellular) -#define SUPPORT_IMAGE_GENERATION 1 +#define RL_SUPPORT_IMAGE_GENERATION 1 // Support multiple image editing functions to scale, adjust colors, flip, draw on images, crop... // If not defined, still some functions are supported: ImageFormat(), ImageCrop(), ImageToPOT() -#define SUPPORT_IMAGE_MANIPULATION 1 +#define RL_SUPPORT_IMAGE_MANIPULATION 1 //------------------------------------------------------------------------------------ @@ -170,78 +170,79 @@ //------------------------------------------------------------------------------------ // Default font is loaded on window initialization to be available for the user to render simple text // NOTE: If enabled, uses external module functions to load default raylib font -#define SUPPORT_DEFAULT_FONT 1 +#define RL_SUPPORT_DEFAULT_FONT 1 // Selected desired font fileformats to be supported for loading -#define SUPPORT_FILEFORMAT_FNT 1 -#define SUPPORT_FILEFORMAT_TTF 1 +#define RL_SUPPORT_FILEFORMAT_FNT 1 +#define RL_SUPPORT_FILEFORMAT_TTF 1 // Support text management functions // If not defined, still some functions are supported: TextLength(), TextFormat() -#define SUPPORT_TEXT_MANIPULATION 1 +#define RL_SUPPORT_TEXT_MANIPULATION 1 // On font atlas image generation [GenImageFontAtlas()], add a 3x3 pixels white rectangle // at the bottom-right corner of the atlas. It can be useful to for shapes drawing, to allow // drawing text and shapes with a single draw call [SetShapesTexture()]. -#define SUPPORT_FONT_ATLAS_WHITE_REC 1 +#define RL_SUPPORT_FONT_ATLAS_WHITE_REC 1 // rtext: Configuration values //------------------------------------------------------------------------------------ -#define MAX_TEXT_BUFFER_LENGTH 1024 // Size of internal static buffers used on some functions: - // TextFormat(), TextSubtext(), TextToUpper(), TextToLower(), TextToPascal(), TextSplit() -#define MAX_TEXTSPLIT_COUNT 128 // Maximum number of substrings to split: TextSplit() +#define RL_MAX_TEXT_BUFFER_LENGTH 1024 // Size of internal static buffers used on some functions: +// TextFormat(), TextSubtext(), TextToUpper(), TextToLower(), TextToPascal(), TextSplit() +#define RL_MAX_TEXTSPLIT_COUNT 128 // Maximum number of substrings to split: TextSplit() //------------------------------------------------------------------------------------ // Module: rmodels - Configuration Flags //------------------------------------------------------------------------------------ // Selected desired model fileformats to be supported for loading -#define SUPPORT_FILEFORMAT_OBJ 1 -#define SUPPORT_FILEFORMAT_MTL 1 -#define SUPPORT_FILEFORMAT_IQM 1 -#define SUPPORT_FILEFORMAT_GLTF 1 -#define SUPPORT_FILEFORMAT_VOX 1 -#define SUPPORT_FILEFORMAT_M3D 1 +#define RL_SUPPORT_FILEFORMAT_OBJ 1 +#define RL_SUPPORT_FILEFORMAT_MTL 1 +#define RL_SUPPORT_FILEFORMAT_IQM 1 +#define RL_SUPPORT_FILEFORMAT_GLTF 1 +#define RL_SUPPORT_FILEFORMAT_VOX 1 +#define RL_SUPPORT_FILEFORMAT_M3D 1 // Support procedural mesh generation functions, uses external par_shapes.h library // NOTE: Some generated meshes DO NOT include generated texture coordinates -#define SUPPORT_MESH_GENERATION 1 +#define RL_SUPPORT_MESH_GENERATION 1 // rmodels: Configuration values //------------------------------------------------------------------------------------ -#define MAX_MATERIAL_MAPS 12 // Maximum number of shader maps supported -#define MAX_MESH_VERTEX_BUFFERS 7 // Maximum vertex buffers (VBO) per mesh +#define RL_MAX_MATERIAL_MAPS 12 // Maximum number of shader maps supported +#define RL_MAX_MESH_VERTEX_BUFFERS 7 // Maximum vertex buffers (VBO) per mesh //------------------------------------------------------------------------------------ // Module: raudio - Configuration Flags //------------------------------------------------------------------------------------ // Desired audio fileformats to be supported for loading -#define SUPPORT_FILEFORMAT_WAV 1 -#define SUPPORT_FILEFORMAT_OGG 1 -#define SUPPORT_FILEFORMAT_MP3 1 -#define SUPPORT_FILEFORMAT_QOA 1 +#define RL_SUPPORT_FILEFORMAT_WAV 1 +#define RL_SUPPORT_FILEFORMAT_OGG 1 +#define RL_SUPPORT_FILEFORMAT_MP3 1 +#define RL_SUPPORT_FILEFORMAT_QOA 1 //#define SUPPORT_FILEFORMAT_FLAC 1 -#define SUPPORT_FILEFORMAT_XM 1 -#define SUPPORT_FILEFORMAT_MOD 1 +#define RL_SUPPORT_FILEFORMAT_XM 1 +#define RL_SUPPORT_FILEFORMAT_MOD 1 // raudio: Configuration values //------------------------------------------------------------------------------------ -#define AUDIO_DEVICE_FORMAT ma_format_f32 // Device output format (miniaudio: float-32bit) -#define AUDIO_DEVICE_CHANNELS 2 // Device output channels: stereo -#define AUDIO_DEVICE_SAMPLE_RATE 0 // Device sample rate (device default) +#define RL_AUDIO_DEVICE_FORMAT ma_format_f32 // Device output format (miniaudio: float-32bit) +#define RL_AUDIO_DEVICE_CHANNELS 2 // Device output channels: stereo +#define RL_AUDIO_DEVICE_SAMPLE_RATE 0 // Device sample rate (device default) -#define MAX_AUDIO_BUFFER_POOL_CHANNELS 16 // Maximum number of audio pool channels +#define RL_MAX_AUDIO_BUFFER_POOL_CHANNELS 16 // Maximum number of audio pool channels //------------------------------------------------------------------------------------ // Module: utils - Configuration Flags //------------------------------------------------------------------------------------ // Standard file io library (stdio.h) included -#define SUPPORT_STANDARD_FILEIO 1 +#define RL_SUPPORT_STANDARD_FILEIO 1 // Show TRACELOG() output messages // NOTE: By default LOG_DEBUG traces not shown -#define SUPPORT_TRACELOG 1 +#define RL_SUPPORT_TRACELOG 1 //#define SUPPORT_TRACELOG_DEBUG 1 // utils: Configuration values //------------------------------------------------------------------------------------ -#define MAX_TRACELOG_MSG_LENGTH 256 // Max length of one trace-log message +#define RL_MAX_TRACELOG_MSG_LENGTH 256 // Max length of one trace-log message -#endif // CONFIG_H +#endif +// CONFIG_H diff --git a/project/auxillary/vis_ast/dependencies/raylib/raylib_refactor.cpp b/project/auxillary/vis_ast/dependencies/raylib/raylib_refactor.cpp new file mode 100644 index 0000000..5995fa6 --- /dev/null +++ b/project/auxillary/vis_ast/dependencies/raylib/raylib_refactor.cpp @@ -0,0 +1,56 @@ +#define GEN_DEFINE_LIBRARY_CODE_CONSTANTS +#define GEN_BENCHMARK +#define GEN_ENFORCE_STRONG_CODE_TYPES +#define GEN_IMPLEMENTATION +#include "gen.hpp" + + +constexpr char const* path_config = "config.h"; +constexpr char const* path_raylib = "raylib.h"; +constexpr char const* path_raymath = "raymath.h"; +constexpr char const* path_rcore = "rcore.h"; +constexpr char const* path_rgestures = "rgestures.h"; +constexpr char const* path_rgl = "rgl.h"; +constexpr char const* path_rtext = "rtext.h"; + + +using namespace gen; + + +void refactor_file( CodeBody code_file ) +{ + String name_scratch = String::make_reserve( GlobalAllocator, kilobytes(1) ); + for ( Code elem : code_file ) + { + if ( elem->Type == ECode::Preprocess_Define ) + { + if ( str_compare( elem->Name, txt("RL_"), 2 ) == 0 ) + continue; + + name_scratch.append_fmt( "%RL_%S", elem->Name ); + elem->Name = get_cached_string( name_scratch ); + name_scratch.clear(); + } + } +} + +int gen_main() +{ + gen::init(); + + FileContents config_file_content = file_read_contents( GlobalAllocator, true, path_config ); + CodeBody config_code = parse_global_body( { config_file_content.size, rcast(char const*, config_file_content.data) } ); + refactor_file( config_code ); + Builder config_builder = Builder::open( path_config ); + config_builder.print( config_code ); + config_builder.write(); + + FileContents raylib_file_content = file_read_contents( GlobalAllocator, true, path_raylib ); + CodeBody raylib_code = parse_global_body( { raylib_file_content.size, rcast(char const*, raylib_file_content.data) } ); + refactor_file( raylib_code ); + Builder raylib_builder = Builder::open( path_raylib ); + config_builder.print( raylib_code ); + config_builder.write(); + + return 0; +} diff --git a/project/auxillary/vis_ast/update_deps.ps1 b/project/auxillary/vis_ast/update_deps.ps1 index ff6d64e..22106b0 100644 --- a/project/auxillary/vis_ast/update_deps.ps1 +++ b/project/auxillary/vis_ast/update_deps.ps1 @@ -49,8 +49,8 @@ switch ($_){ . $incremental_checks # Clear out the current content first -remove-item $path_temp -Recurse -New-Item -ItemType Directory -Path $path_temp +# remove-item $path_temp -Recurse +# New-Item -ItemType Directory -Path $path_temp if ( -not (Test-Path $path_binaries) ) { New-Item -ItemType Directory -Path $path_binaries @@ -70,13 +70,14 @@ function setup-raylib { $url_raylib_zip = 'https://github.com/raysan5/raylib/archive/refs/heads/master.zip' $path_raylib_zip = join-path $path_temp 'raylib.zip' - invoke-webrequest -uri $url_raylib_zip -outfile $path_raylib_zip - expand-archive -path $path_raylib_zip -destinationpath $path_temp - $path_raylib_master = join-path $path_temp 'raylib-master' $path_raylib_src = join-path $path_raylib_master 'src' $path_raylib_glfw_inc = join-path $path_raylib_src 'external/glfw/include' + remove-item $path_raylib_master -Recurse + # invoke-webrequest -uri $url_raylib_zip -outfile $path_raylib_zip + expand-archive -path $path_raylib_zip -destinationpath $path_temp + write-host "Building raylib with $vendor" $path_build = Join-Path $path_raylib 'build' @@ -84,41 +85,77 @@ function setup-raylib { New-Item $path_build -ItemType Directory } - # Microsoft - $lib_gdi32 = 'Gdi32.lib' - $lib_shell32 = 'Shell32.lib' - $lib_xinput = 'Xinput.lib' - $lib_user32 = 'User32.lib' - $lib_winmm = 'Winmm.lib' + # Refactor raylib + if ( $true ) { + $path_gencpp = join-path $path_root 'singleheader/gen' - $includes = @( - $path_raylib_src, - $path_raylib_glfw_inc - ) - foreach ($include in $includes) { - write-host $include + $includes = @( + $path_gencpp + ) + + $compiler_args = @( + ($flag_define + 'GEN_TIME') + ) + + $linker_args = @( + + ) + + $unit = join-path $path_raylib 'raylib_refactor.cpp' + $executable = join-path $path_build 'raylib_refactor.exe' + + $build_result = build-simple $path_build $includes $compiler_args $linker_args $unit $executable + Push-Location $path_raylib_src + if ( Test-Path( $executable ) ) { + $time_taken = Measure-Command { & $executable + | ForEach-Object { + write-host `t $_ -ForegroundColor Green + } + } + } + Pop-Location } - $compiler_args = @( - ($flag_define + 'PLATFORM_DESKTOP') - ) - $linker_args = @( - $flag_link_dll, + # Build raylib + if ( $false ) { + # Microsoft + $lib_gdi32 = 'Gdi32.lib' + $lib_shell32 = 'Shell32.lib' + $lib_xinput = 'Xinput.lib' + $lib_user32 = 'User32.lib' + $lib_winmm = 'Winmm.lib' - # $lib_xinput, - $lib_gdi32, - $lib_shell32, - $lib_user32, - $lib_winmm - ) + $includes = @( + $path_raylib_src, + $path_raylib_glfw_inc + ) + foreach ($include in $includes) { + write-host $include + } - # $unit = join-path $path_raylib 'raylib.c' - $dll = join-path $path_raylib_lib 'raylib.dll' - # $build_result = build-simple $path_build $includes $compiler_args $linker_args $unit $dll + $compiler_args = @( + ($flag_define + 'PLATFORM_DESKTOP'), + ($flag_define + 'BUILD_LIBTYPE_SHARED') + ) + $linker_args = @( + $flag_link_dll, - $raylib_modules = get-childitem -path $path_raylib_src -filter "*.c" -file - $build_result = build $path_build $includes $compiler_args $linker_args $raylib_modules $dll + # $lib_xinput, + $lib_gdi32, + $lib_shell32, + $lib_user32, + $lib_winmm + ) + # $unit = join-path $path_raylib 'raylib.c' + $dll = join-path $path_raylib_lib 'raylib.dll' + # $build_result = build-simple $path_build $includes $compiler_args $linker_args $unit $dll + + $raylib_modules = get-childitem -path $path_raylib_src -filter "*.c" -file + $build_result = build $path_build $includes $compiler_args $linker_args $raylib_modules $dll + } + + # Move headers to used include $raylib_headers = Get-ChildItem -Path $path_raylib_src -Filter "*.h" -File foreach ($header in $raylib_headers) { Copy-Item -Path $header -Destination (join-path $path_raylib_inc (split-path $header -Leaf))